1

I am looking for a way to make a Flash movie clip (animation, like the ones created with Flash Pro CS), but purely in as3 - so I can import them into Prezi.

I have done a lot of as3 programming in Flash Builder with Flex projects and I have no background in how MovieClips work.

What I have already tried is extending a MovieClip class and trying to base the animation on Timers, this failed so I tried with ENTER_FRAME event (because flash animations are based on frames - so I thought...). But all this fails, only graphics drawn in the constructor are displayed - no animation happens. (As I wrote in the first paragraph I am testing this importing the swf into Prezi, opening it in a browser works as expected)

Is there any way to do it? Like listening to specific events?

er453r
  • 211
  • 2
  • 11
  • 1
    What specifically are you trying to do? just draw something an animate it? In this case you might forget the frame concept and look into tweening the object. – The_asMan Jul 02 '12 at 19:07
  • I would like to programmatically create an animation and add objects - not only animate an existing one – er453r Jul 02 '12 at 19:20
  • The ENTER_FRAME event sounds like what you want. You are wrong about "only graphics drawn in the constructor are displayed", you can draw graphics whenever you like, but you may have to call clear() before drawing anything new. – Adam Harte Jul 02 '12 at 21:53
  • You should also keep code in the constructor to a minimum, only for setting variables etc.. – Neil Jul 03 '12 at 08:15

2 Answers2

1

Give sprite sheet a try. It's the best solution for animation in AS3, and also pretty simple to implement. for changing drawing, there are Timer and ENTER_FRAME event to do this.

wanting252
  • 1,139
  • 2
  • 16
  • 22
1

Funny thing happened. I wanted to show you a sample code I was trying out (I already tried Sprite with ENTER_FRAME), that was not working. By accident I found a solution. It looks like you need to draw something in the first frame, or else the other frames won't work (in Prezi at least).

So here is the working code:

    public class PreziTest extends Sprite{
        private var radius:uint = 10;

        public function PreziTest(){
            addEventListener(Event.ENTER_FRAME, onEnterFrame);

            onEnterFrame(null); // WITHOUT THIS IT WON'T WORK - YOU NEED TO DRAW SOMTHING IN THE FIRST FRAME
        }

        private function onEnterFrame(event:Event):void{
            radius += 10;

            if(radius > 200)
                radius = 10;

            graphics.clear();
            graphics.beginFill(0xff0000);
            graphics.drawCircle(radius, radius, radius);
        }
    }

Thanks for all your help!

er453r
  • 211
  • 2
  • 11