简体   繁体   English

ActionScript-3-播放先前创建的MovieClip和Event.ENTER_FRAME之间的区别

[英]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. 我创建了一个只有一个代表球的框架的MovieClip,将其导出到类中,将其扩展为我的需要,并使用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??? 它可以正常工作,但是有个让我感到困惑的地方-舞台和球都只有一帧,所以我不太了解Event.ENTER_FRAME的工作原理...我的意思是,如果没有关键帧,动画如何制作??? If I used already animated MovieClip, I would have to add keyframes, right? 如果使用已经动画化的MovieClip,则必须添加关键帧,对吗?

Event.ENTER_FRAME is tied to the Frames Per Second rate of the .swf. Event.ENTER_FRAME与.swf的每秒帧速率有关。 It will keep firing ENTER_FRAME's regardless of whether the MovieClip is animating or not. 无论MovieClip是否设置动画,它都会继续触发ENTER_FRAME。

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. 它与MovieClip的动画帧无关,而是与之同步的,因为它绑定到相同的时间间隔,即1000ms / FPS。

So whatever you are doing to animate the balls programatically from Event.ENTER_FRAME has absolutely nothing to do with the animation . 因此,通过Event.ENTER_FRAME 编程方式对球进行动画处理的任何操作都与动画完全无关

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. 尽管您可以通过ENTER_FRAME事件进行控制,但它与动画片夹动画完全无关。

To sum up, the Event.ENTER_FRAME is supposed to provide you with an easy way to create timed code , not timed timeline animations. 总而言之,Event.ENTER_FRAME应该为您提供一种简单的方法来创建定时代码而不是定时时间线动画。

Flash Player is always playing based on a frame rate. Flash Player始终根据帧速率播放。 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. 显示对象是否真正在移动取决于这些对象是否正在侦听Event.ENTER_FRAME事件处理程序中的指令(通常是重新放置/重绘自己)。 think of the Event.ENTER_FRAME event as being a power outlet that can animate an object whenever you plug it in. 想想Event.ENTER_FRAME事件是一个电源插座,可以在插入对象时为其设置动画。

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. 帧脚本和MovieClip对象通常被视为逐帧序列,至少这是使用Flash Professional IDE的用户应该相信的,因为从概念上和视觉上都易于理解。

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). 在Flash IDE框架脚本中,似乎可以更好地控制每个框架,并且可以单独更改这些框架以显示翻书样式的逐帧序列(即:将不同的图像拖放到每个框架中) ),它们也可以进行编程动画处理(即:补间动画)。 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. 以编程方式动画的显示对象不会像您基于Flash IDE那样占用越来越多的帧,因为它们只是视觉工具。 the AVM2 runtime treats frame scripts and packaged code the same way. AVM2运行时以相同的方式对待框架脚本和打包的代码。

MovieClip extends from Sprite objects. MovieClip从Sprite对象扩展。 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. 它们基本上是相同的对象,除了Sprite不具有gotoAndStop()之类的功能。如果从帧脚本切换到程序包级编程,则不应该使用MovieClip对象,因为它们既重又实际上无用,请改用Sprite 。

The single frame will updates for each ENTER_FRAME calls. 单个帧将针对每个ENTER_FRAME调用进行更新。 like sprite container. 像精灵容器一样。

The enterFrame event is fired based on your framerate, it is actually nothing to do with the movieclips timeline. enterFrame事件是根据您的帧速率触发的,实际上与movieclips时间轴无关。 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. 至少,这就是我如何看待它,以使其变得更容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM