-
CS3: Loading a PNG with AS3 - sometimes loads, sometimes does not
I am seriously considering throwing my pc out the window!!!
Okay I am trying to load a simple png. Sometimes it works sometimes it doesn't, WHY!!! Either work all the time or do not work all the time!!! Anyway here is my code. It worked last night but this morning it does not load anything.
import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
var container:Sprite = new Sprite();
container.x = 0;
container.y = 250;
addChild(container);
var pictLdr:Loader = new Loader();
var pictURL:String = "flyfire.png"
var pictURLReq:URLRequest = new URLRequest(pictURL);
pictLdr.load(pictURLReq);
pictLdr.contentLoaderInfo.addEventListener(Event.C OMPLETE, imgLoaded);
function imgLoaded(event:Event):void
{
container.addChild(pictLdr.content);
}
-
Actionscript 3, postproduction
Why you want to add listener to .contentLoaderInfo? 'a LoaderInfo object corresponding to the object being loaded.' It possibly add your listener to a null object before your image being loaded.
pictLdr.contentLoaderInfo.addEventListener(Event.C OMPLETE, imgLoaded);
-
Actionscript 3, postproduction
Try this.
pictLdr.addEventListener(Event.COMPLETE, imgLoaded,false,0,true);
function imgLoaded(event:Event):void
{
container.addChild(pictLdr.content);
pictLdr.removeEventListener(Event.COMPLETE, imgLoaded);
}
-
I still can't get it to work.
-
btw the squirell bubble game needs a warning about addiction possibilities -
thats how I just spent my past 2 hours
-
Actionscript 3, postproduction
Sorry for your hours. hehe.
Well I'm too busy these days I forget myself used the same .contentLoaderInfo to add listener. I have a class I wrote 6 months before you could use to load images. It works fine.
http://www.neatfilm.com/flash/download/ImageLoader.as
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
|