Have you ever tried in ActionScript 3 this:

this.addEventListener(Event.ENTER_FRAME, cpF1);
this.addEventListener(Event.ENTER_FRAME, cpF2);
 
function cpF1(e:Event):void{
trace("cpF1")
}
function cpF2(e:Event):void{
trace("cpF2")
}

Don’t expect to have traces like “cpF2″ only. You’ll have “cpF1 cpF2″ traced on every frame. This is a very hard to find mistake, if you expect an object to have only one onEnterFrame listener but you add another.

  • Share/Bookmark
2 Responses to “[AS3] Event.ENTER_FRAME strange behaviour”
  1. vitaLee says:

    that’s one of the advantages you get with AS3.
    there’s nothing wrong with it, actually you should expect the same behaviour from all your event listeners (listening to custom and built in events).

  2. SikoTiko says:

    @vitaLee – You are right. Actually I wanted to tell people to be careful with this advantage, because if you forget about it then it can produce unexpected results, when you think you have one listener.

  3.  
Leave a Reply


TxEff - The Flash Text Effects