开发者

ActionScript-3 -- difference between playing previously created MovieClip and Event.ENTER_FRAME

I am creating game which involves some billiard-like balls to bounce on the screen. I created a MovieClip with only one frame which represented the ball, exported it to the class, extended it to my needs and animated it using Event.ENTER_FRAME. It works fine, but there is something that confuses me -- both, the stage and the ball have only one frame each, so I don't quite understand how Event.ENTER_FRAME works... I mean, if there are no keyframes, how is done the animation??? If I used already animated MovieClip, I would have to add keyfram开发者_如何学Pythones, right?


Flash Player is always playing based on a frame rate. whether display objects are actually moving depends on if those objects are listening for instructions in an Event.ENTER_FRAME event handler, often to reposition/redraw themselves, or not. think of the Event.ENTER_FRAME event as being a power outlet that can animate an object whenever you plug it in.

moving from frame scripting to real programming can be confusing in this regard. frame scripting and the MovieClip object typically are treated as a frame-by-frame sequence, at least thats what users using Flash Professional IDE are suppose to believe since it's easy to grasp both conceptually and visually.

in Flash IDE frame scripting, it appears that you have more visual control of each frame, and while those frames can be altered individually to display a flip-book-style frame-by-frame sequence (IE: dropping a different image into each frame), they, too, can be programatically animated (IE: motion tween). programatically animated display objects don't take up more and more frames as you might think based on the Flash IDE since those are only visual tools. the AVM2 runtime treats frame scripts and packaged code the same way.

MovieClip extends from Sprite objects. they are basically the same object, except Sprite doesn't have functions like gotoAndStop(), etc. if you are switching to package level programming from frame scripting you should not use MovieClip objects since they are both heavier and practically useless - use Sprite instead.


Event.ENTER_FRAME is tied to the Frames Per Second rate of the .swf. It will keep firing ENTER_FRAME's regardless of whether the MovieClip is animating or not.

It is not related to the animation frames of the MovieClip, other then being synchronous with it because it's tied to the same time interval, ie 1000ms/FPS.

So whatever you are doing to animate the balls programatically from Event.ENTER_FRAME has absolutely nothing to do with the animation.

Programed and timeline animations are two different things.The code will fire no matter what, wherever your movieclip is. It's not related to the movieclip animation at all though you can control it from the ENTER_FRAME event.

To sum up, the Event.ENTER_FRAME is supposed to provide you with an easy way to create timed code, not timed timeline animations.


The single frame will updates for each ENTER_FRAME calls. like sprite container.


The enterFrame event is fired based on your framerate, it is actually nothing to do with the movieclips timeline. It just happens that the movieclips timeline animation is also based on the framerate. At least, this is how I look at it to make it easier.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜