简体   繁体   English

创建自己的帧动画并在动画片段中播放

[英]create own frames animation and play in movieclip


how can i create own frames animation and play in movieclip or any movieclip extends.. i have this code but is wrong - i'm flash builder beginner so i don't know how work it..i can do it in MovieClip 我如何创建自己的帧动画并在movieclip或任何movieclip扩展中播放..我有此代码,但错了-我是Flash Builder初学者,所以我不知道它是如何工作的。.我可以在MovieClip中做到这一点

<?xml version="1.0" encoding="utf-8"?>

        public var mc:MovieClip;
        protected function application1_creationCompleteHandler(event:FlexEvent):void
        {
            var comp:UIComponent = new UIComponent();
            this.addElement(comp);

            mc = new MovieClip();

            for (var i:int =0; i<100; i++)
            {   
                var rect:Sprite = new Sprite();
                rect.graphics.beginFill(0x330000);
                rect.graphics.drawCircle(0, 0, 20);
                rect.graphics.endFill();
                rect.x=30 + (i%40)*5;
                rect.y=100;
                mc.addChild(rect);
            }
            comp.addChild(mc);
        }


        protected function button1_clickHandler(event:MouseEvent):void
        {
            mc.play();
        }
    ]]>
</fx:Script>

<s:Button click="button1_clickHandler(event)"/>

thanks for help 感谢帮助

Sadly there is no way to create MovieClip animations at runtime, they can only be created using Flash Authoring (or possibly other tools that can export to swf). 遗憾的是,无法在运行时创建MovieClip动画,只能使用Flash创作(或可能使用其他可以导出到swf的工具)来创建它们。

Your options are to either create a bunch of Sprite or possibly Shape and add/remove these from the display list as you progress throught the frames. 您的选择是创建一堆Sprite或可能的Shape并在逐步浏览帧时从显示列表中添加/删除这些Sprite Another option, if your graphics are simpler, you can generate them on the fly for each frame. 另一种选择是,如果您的图形更简单,则可以为每个帧动态生成它们。

I think we'd need a bit more information about the type of animation you're hoping to create. 我想我们需要有关您希望创建的动画类型的更多信息。

Depending on what it is, it could be very possible in theory. 取决于它是什么,理论上它很有可能。 You'd be creating a separate class that extends MovieClip and instantiate that in your 'for loop'. 您将创建一个单独的类来扩展MovieClip,并在“ for循环”中实例化该类。 That class could have all sorts of animation instructions and logic. 该类可以具有各种动画指令和逻辑。 Extending 'MovieClip' isn't the only option, but it does enable you to use Event.ENTER_FRAME where with a Sprite you'd need to set up an internal Timer or use a public 'update' or 'draw' method that can be called from your main code. 扩展“ MovieClip”不是唯一的选择,但是它确实使您能够使用Event.ENTER_FRAME,在其中需要使用Sprite来设置内部Timer或使用公共的“ update”或“ draw”方法,从您的主要代码调用。

There are also 'Motion' classes that allow you to load XML animation instructions that you have a fair amount of control with. 还有“ Motion”类,这些类允许您加载具有大量控制权的XML动画指令。 Look up fl.motion.Animator. 查找fl.motion.Animator。

What are you trying to do? 你想做什么? Welcome to ActionScript! 欢迎使用ActionScript!

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

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