PDA

View Full Version : Help me to load external jpg files please.



ecptavares
July 7th, 2008, 09:26 AM
Hi!

I am trying to load an external JPG file but I am having some weird problems. I was looking at a tutorial of how to load external files and I've done everything correctly but it is not working.

Here is my code:



var loadBanner : Loader = new Loader();
var url1 : URLRequest = new URLRequest("banner.jpg");

loadBanner.load(url1);
bg.addChild(loadBanner);

loadBanner.contentLoaderInfo.addEventListener(Even t.OPEN,onOpenLoader);
loadBanner.contentLoaderInfo.addEventListener(Even t.COMPLETE,onCompLoader);

function onOpenLoader(event:Event):void
{
loading_txt.visible = true;
}

function onCompLoader(event:Event):void
{
loading_txt.visible = false;
}

stop();

bg is a MC that I want to load the jpg into.

and here is the error message I am getting.



1120: Access of undefined property bg.
What am I doing wrong please!

sekasi
July 7th, 2008, 10:18 AM
Error messages are more intuitive than you might think. That message means that wherever you're trying to access 'bg' does not have access to that movieclip/sprite.

Are you doing this in the timeline? Where is the bg object? Stage? Library?

ecptavares
July 7th, 2008, 12:17 PM
Hi!

bg is a movie clip that is a square animating from its alpha 0 to 100 and scaling up. At the end of this scale and alpha animation I have a keyframe(in the actions layer) that has that code I´ve posted before.
The bg movie clip is at the stage.

snickelfritz
July 7th, 2008, 03:16 PM
Make sure you give the bg movieclip an instance name of "bg".
BTW, I highly recommend using TweenLite or TweenMax, instead of the timeline for simple tweens like this.

ecptavares
July 7th, 2008, 05:54 PM
Hi!
I did give it an instance name of bg.
Where do I find tutorials about this tweeners?