开发者

error #1009 I know the problem - what is the best work around?

Disclaimer: I'm an AS3 noob.

Okay - I'm getting an error #1009 when I compile, and I understand why:

On my main timeline, I'm referencing a movieclipB inside movieclipA, and movieclipB doesn't begin on the first frame.

So when the timeline reaches the movieclipA(and the code simultaneously) the object its trying to reference (movieclipB) doesn't appear until a few more frames down the road.

If I put movieclipB on the first frame of movieclipA, it will work fine, but that doesn't work with the animation.

So, I ask, how can I tell flash to just calm down and wait until the object appears, and then use the code?

In AS2 days, I would have put the code inside movieclipA or B and called it a day. I looked into it and noticed talk about using an开发者_开发技巧 EnterFrame listener, but I can't seem to get that to work.

This is my code for the button. How would you put an EnterFrame inside this code?

section3.section3graph1x.addEventListener(MouseEvent.CLICK, clicktest);

function clicktest(e:MouseEvent):void
{

section3.gotoAndPlay(16);

}


I don't really know your specific case, but it should be possible to just put the code on the timeline. (if that's your approch).

If mcB is inside mcA, then simply add the eventlistener on the same frame as you add mcB. (Just create a new empty keyframe and put the AS on that frame).

An other appraoch would be to call mcB.visible = false; mcB.stop(); on frame 1, and then call mcB.visible = true; mcB.gotoAndStop(1) on the correct frame.

I would recommend that you learn how to code in classes, as it makes much more sense! (You could start at Michael James Williams avoider tutorial. Easy to follow and very good!)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜