views:

36

answers:

1

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

+2  A: 

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;
        }
PatrickS
Hey thanks for the answer. Now I have this problem, when I mouse over item1, how do I stop all items from moving? Do I need to removeEventListener off all items, and addEventListener to them again while I mouse out? Is this a OO concept?
flashing
all items should stop moving since they should all listen to the speed variable. this is a simple version of the code, practically you could have the first part of the code in a loop in order to add your 8 items to the stage.
PatrickS
Thanks, best answer!! I think my problem should be solved now =)
flashing