flashing
flashing

Reputation: 3

Flash, using Event.ENTER_FRAME or movieclip?

I want to create an endless loop, 8 items moving in a circular shape. When you roll over of each item, it will stop the moving, and you should be able to click it.

I dont know what should I use, should I use Event.ENTER_FRAME or the circular shape should be in movie clip, so that when there is a mouse over event, it will stop moving? I am new to action script, please advise.

EDIT:

Oh ya, I code everything in AS3, including the movement, objects etc. Something like a new class

Upvotes: 0

Views: 19659

Answers (1)

PatrickS
PatrickS

Reputation: 9572

Yes, you can use the Event.ENTER_FRAME to trigger a function that would animate your items. You could define a "speed" variable to determine the motion speed. On mouse over set the speed variable value to 0 , then back to its original value on mouse out

        var speed:Number = 10;

        var item:MovieClip = new MovieClip();
        item.addEventListener(Event.ENTER_FRAME , animateItem );
        item.addEventListener(MouseEvent.MOUSE_OVER , mouseOverHandler );
        item.addEventListener(MouseEvent.MOUSE_OUT , mouseOutHandler );

        addChild( item );

        private function animateItem(event:Event):void
        {
            motion( event.currentTarget );
        }

        private function motion(mc:MovieClip):void
        {
            //your motion code here using the speed variable
            mc.rotation += speed // for instance;
        }

        private function mouseOverHandler(event:MouseEvent):void
        {
             speed = 0;
        }

        private function mouseOutHandler(event:MouseEvent):void
        {
            speed = 10;
        }

Upvotes: 2

Related Questions