0

免责声明:我是 AS3 菜鸟。

好的 - 我在编译时收到错误 #1009,我明白为什么:

在我的主时间线上,我在movieclipA 中引用了一个movieclipB,而movieclipB 不是从第一帧开始的。

因此,当时间线到达movieclipA(和代码同时)时,它试图引用的对象(movieclipB)直到接下来的几帧才会出现。

如果我将movieclipB 放在movieclipA 的第一帧上,它会正常工作,但这不适用于动画。

所以,我问,我怎样才能告诉flash冷静下来,等到物体出现,然后再使用代码?

在 AS2 的日子里,我会把代码放在 movieclipA 或 B 中,然后就结束了。我查看了它并注意到谈论使用 EnterFrame 侦听器,但我似乎无法让它工作。

这是我的按钮代码。您将如何在此代码中放置一个 EnterFrame?

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

function clicktest(e:MouseEvent):void
{

section3.gotoAndPlay(16);

}
4

1 回答 1

0

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!)

于 2011-02-17T16:27:31.510 回答