# Add/remove eventlistener, re-add?

**URL:** https://forum.kirupa.com/t/add-remove-eventlistener-re-add/310737
**Category:** Uncategorized
**Created:** [June 17, 2010, 7:05pm UTC](https://forum.kirupa.com/t/add-remove-eventlistener-re-add/310737 "2010-06-17T19:05:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jspark11](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jspark11](https://forum.kirupa.com/u/jspark11)
#### Post date: [June 17, 2010, 7:05pm UTC](https://forum.kirupa.com/t/add-remove-eventlistener-re-add/310737/1 "2010-06-17T19:05:16Z")

</div>

Hi everyone,

I have a rotating 3d cube on frame 1. I have it rotating on a loop through addlistener and if we go to another frame I remove the listener. However, the problem is when I return to frame 1 the cube is not rotating anymore. How can I “re-add” a listener (if that makes any sense). Why is it not launching?

Here is the code I have for the cube:

import com.theflashblog.fp10.SimpleZSorter;  
import com.theflashblog.fp10.SimpleZSortVO;  
import flash.display.DisplayObject;  
import flash.geom.Point

con.getChildAt(0).rotationY = 90;  
con.getChildAt(0).x = -140;

con.getChildAt(1).rotationY = 90;  
con.getChildAt(1).x = 140;

con.getChildAt(2).z = 140;

con.getChildAt(3).rotationX = 90;  
con.getChildAt(3).y = 140;

con.getChildAt(4).rotationX = 90;  
con.getChildAt(4).y = -140;

con.getChildAt(5).z = -140;

addEventListener(Event.ENTER\_FRAME, loop);

function loop(e:Event):void {  
if(this.currentFrame ==1)  
{  
SimpleZSorter.sortClips(con);  
con.rotationY -= (mouseX - stage.stageWidth / 2) \* 0.003;  
con.rotationX += (mouseY - stage.stageHeight / 2) \* 0.003;  
e.currentTarget.removeEventListener(Event.ENTER\_FR AME, loop);  
}  
}
