'Infinite Menu' with AS3?

Hey everyone- long time reader, first time poster :slight_smile:

so my questions is this:
How do I translate the AS2 code for the Infinite loop menu into AS3??
http://www.kirupa.com/developer/mx/infinite.htm

in AS2, for the example on kirupa the code is:

[COLOR=black] onClipEvent (load)
{
xcenter=150;
speed=1/10;
}
onClipEvent (enterFrame)
{
var distance=_root._xmouse-xcenter;
_x+=(distance*speed);
}
[/COLOR]

but I’m really lost as to how to turn this into an eventlisterner or class or whatever AS3 I need…(can you tell Ive only JUSt started learning AS3 ;))
anyone got an idea?

many thanks!
-L

it is same but instead of onClip Event
you have to eventListeners

suppose your movieClip instance name is clip then

import flash.events.Event;
var xcenter:Number=150;
var speed:Number=1/10;
clip.addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(event:Event):void
{
var distance:Number=mouseX-xcenter;
event.target.x+=(distancespeed);//or clip.x+=(distancespeed);
}

Write the code in the timeline as as3 doesn’t support it on the movieClip

sudhansurana,
thanks for the reply!- when i try that i am am getting an error:

Warning: 1090: Migration issue: The onEnterFrame is not triggered automatically by Flash Player at run time in ActionScript 3.0. You must first register this handler for the event using addEventListener ( ‘enterFrame’, callback_handler).

this might seem like an obvious answer- but Im lost…any suggestions?

http://murmadillo.tut.su/fla/goto-first-frame.swf
http://murmadillo.tut.su/fla/goto-first-frame.zip


//first frame code
addEventListener(Event.ENTER_FRAME, eventHandler)
function eventHandler(event:Event):void {
my_text.text="currentFrame"+currentFrame;	
if (currentFrame==totalFrames) my_text.text="Stop one second";
}

thanks Alex, but your file has timeline animation- I am hoping to use all actionscript for the movement

-thanks anyways