# 'Infinite Menu' with AS3?

**URL:** <https://forum.kirupa.com/t/infinite-menu-with-as3/262332>\
**Category:** flash\
**Created:** [June 5, 2008, 4:53am UTC](https://forum.kirupa.com/t/infinite-menu-with-as3/262332 "2008-06-05T04:53:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![larnar](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@larnar](https://forum.kirupa.com/u/larnar)\
**Post date:** [June 5, 2008, 4:53am UTC](https://forum.kirupa.com/t/infinite-menu-with-as3/262332/1 "2008-06-05T04:53:02Z")

</div>

Hey everyone- long time reader, first time poster 🙂

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](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

---

<div class="post-metadata">

**Author:** ![sudhansurana](https://avatars.discourse-cdn.com/v4/letter/s/50afbb/32.png) [@sudhansurana](https://forum.kirupa.com/u/sudhansurana)\
**Post date:** [June 5, 2008, 10:33am UTC](https://forum.kirupa.com/t/infinite-menu-with-as3/262332/2 "2008-06-05T10:33:24Z")

</div>

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+=(distance_speed);//or clip.x+=(distance_speed);  
}

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

---

<div class="post-metadata">

**Author:** ![larnar](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@larnar](https://forum.kirupa.com/u/larnar)\
**Post date:** [June 5, 2008, 12:24pm UTC](https://forum.kirupa.com/t/infinite-menu-with-as3/262332/3 "2008-06-05T12:24:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)\
**Post date:** [June 5, 2008, 12:51pm UTC](https://forum.kirupa.com/t/infinite-menu-with-as3/262332/4 "2008-06-05T12:51:05Z")

</div>

[http://murmadillo.tut.su/fla/goto-first-frame.swf](http://murmadillo.tut.su/fla/goto-first-frame.swf)  
[http://murmadillo.tut.su/fla/goto-first-frame.zip](http://murmadillo.tut.su/fla/goto-first-frame.zip)

```auto

//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";
}

```

---

<div class="post-metadata">

**Author:** ![larnar](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@larnar](https://forum.kirupa.com/u/larnar)\
**Post date:** [June 6, 2008, 1:38am UTC](https://forum.kirupa.com/t/infinite-menu-with-as3/262332/5 "2008-06-06T01:38:02Z")

</div>

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

-thanks anyways
