-
Help needed about removeeventlistener
Code:
function Main() {
...
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, imgLoadErrorMethod);
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
this.stage.scaleMode=StageScaleMode.NO_SCALE;
this.stage.align=StageAlign.TOP_LEFT;
if (fileCount <= 4) {
fileCount++;
} else {
fileCount = 1;
}
}
function imgLoadErrorMethod(event:IOErrorEvent):void {
loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, imgLoadErrorMethod);
num = 0;
}
function completeHandler(event:Event):void {
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
this.container.addChild(event.target.content);
...
after testing this script I'm getting following errors:
Scene 1, Layer 'Actions', Frame 1, Line 63 1120: Access of undefined property loader.
Scene 1, Layer 'Actions', Frame 1, Line 68 1120: Access of undefined property loader.
can anyone help me?
-
Senior Member
You need to declare the the loader variable outside of any function once:
var loader:Loader;
then inside Main you write:
loader = new Loader();
The problem in your present script is that you have a local variable. However, alternatively you can also delete the listener this way without changing anything else:
event.currentTarget.removeEventListener(IOErrorEve nt.IO_ERROR, imgLoadErrorMethod);
- The right of the People to create Flash movies shall not be infringed. -
-
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|