cregox
cregox

Reputation: 18408

Flash debugger behaving differently from the player with AS3 and Events

Why this works on flash professional's debugger, but brings null on the compiled SWF?

var firstParameter:SomeObject = new SomeObject();
someLoader = new Loader();
someLoader.contentLoaderInfo.addEventListener(
    Event.COMPLETE
  , function(evt) {
      onLoaded(evt, firstParameter);
    }
  , false
);

function onLoaded (evt:Event, param:SomeObject):void {
    mcOnSceneForTracing.text = param; // this is used for SWF debugging
}

For the record:

Upvotes: 0

Views: 160

Answers (1)

weltraumpirat
weltraumpirat

Reputation: 22604

My guess would be: When loading your resource from the debugger player, the operation finishes instantly, and thus firstParameter is available when your anonymous listener function is called, but when running the swf elsewhere, the load operation takes longer, and then the reference to firstParameter is lost, since it is a local variable.

Upvotes: 1

Related Questions