PDA

View Full Version : AS3 image loading PROBLEM



Lankyman
March 3rd, 2010, 08:55 AM
Hi guys I wonder if any of you would be kind enough to help me!?

I'm trying to create a flash movie with external images that load on set keyframes so I can add mask effects to images. I did the tutorial about loading external images. (below is the code) which worked fine for loading in one image on the first keyframe but when i tried the same code on a new keyframe but replacing the image file name the code/file failed.

I can do this using AS2 but not too clued up on AS3 so could anyone point me in the right direction for a tutorial to learn how to do what i'm looking for or even better tell me how to achieve my goals.

var imageLoader:Loader;

function loadImage(url:String):void {

// Set properties on my Loader object
imageLoader = new Loader();
imageLoader.load(new URLRequest(url));
imageLoader.contentLoaderInfo.addEventListener(Pro gressEvent.PROGRESS, imageLoading);
imageLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, imageLoaded);

}
loadImage("support.jpg");

function imageLoaded(e:Event):void {

// Load Image
imageArea.addChild(imageLoader);

}

function imageLoading(e:ProgressEvent):void {

// Use it to get current download progress
// Hint: You could tie the values to a preloader :)

}

Thanks alot

e.s.x.s
March 3rd, 2010, 09:54 AM
is there any error messages in the output window?

Lankyman
March 4th, 2010, 04:08 AM
Yeah I get the 4 below.


1151: A conflict exists with definition imageLoader in namespace internal. var imageLoader:Loader;
1021: Duplicate function definition. function loadImage(url:String):void {
1021: Duplicate function definition. function imageLoaded(e:Event):void {
1021: Duplicate function definition. function imageLoading(e:ProgressEvent):void {
Warning: 3596: Duplicate variable definition. var imageLoader:Loader;

bennybosox
March 4th, 2010, 11:39 AM
I see a space in between "e" and "n" of "Eve nt.COMPLETE, imageLoaded"...could mess things up.