00:00
00:00
Newgrounds Background Image Theme

wilwz just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Actionscript 3 and frames

439 Views | 2 Replies
New Topic Respond to this Topic

Actionscript 3 and frames 2016-09-14 17:20:02


The following is broken for my assets, but if I create new ones it's fine.

So I've got a Movieclip and inside it has two frames.

I have code on the timeline as follows:

change.gotoAndStop(2);

The change MC is on stage and it changes to frame 2 because of the code. Great!

However, lets say I didn't want this MC on stage until frame 2.

I put the MC on frame 2 and keep the code on frame 1. I get the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Untitled_1_fla::MainTimeline/frame1()
didn't do this originally, only for the purpose of the explanation

Fair enough, makes sense

So I now put the code and the MC onto frame 2. It doesn't work and I get the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Untitled_1_fla::MainTimeline/frame2()
	at flash.display::Sprite/constructChildren()
	at flash.display::Sprite()
	at flash.display::MovieClip()

So the only way I've found to bypass the error is to include the MC from the very beginning. Something is off, surely? What?

I try it with a different asset, and the issue disappears.

What's up with my asset?

File if interested

Response to Actionscript 3 and frames 2016-09-18 11:28:08


If you change the first instance frame of 'attackChange' from type 'button' to 'movieclip' in the properties panel. It will work.

My guess is the instance hasn't fully loaded yet. But I cannot say why, nor how to wait for it to load properly.


SIG YOINK!

BBS Signature

Response to Actionscript 3 and frames 2016-09-18 17:59:29


At 9/18/16 11:28 AM, JPI wrote: If you change the first instance frame of 'attackChange' from type 'button' to 'movieclip' in the properties panel. It will work.

My guess is the instance hasn't fully loaded yet. But I cannot say why, nor how to wait for it to load properly.

I decided to break the MC and create a new one. Seemed to have worked. How bizarre.