PDA

View Full Version : path problems



garaiburu
July 25th, 2007, 02:39 AM
Hi

I'm new to actionscript 3 (as will become obvious!) and am a little confused. Here's why: I'm making a little gallery and it works fine if I put all the images in the same directory as the .swf file. If however I move them to a new folder (called 'images') in the same directory and change the path within the script accordingly flash can't find the images anymore. So I figure there must be something I'm doing wrong in defining the path. Here's what this bit of the script looks like

panel_mc.P1.addEventListener(MouseEvent.CLICK,imag e1);
function image1(event:MouseEvent):void {
var request:URLRequest = new URLRequest("\images\angry nell.jpg");
myloader.load(request);
addChild(myloader);
myloader.scaleX = .3;
myloader.scaleY = .3;
myloader.x=290;
myloader.y=35;
}

I've tried defining the full path to the images on my drive, but it doesn't make any difference.
As I say if I just put the images in the same directory so that the URLRequest bit reads,

var request:URLRequest = new URLRequest("angry nell.jpg");

it all works fine.

Any help on this would be great.

cheers

John

Roys
July 25th, 2007, 02:52 AM
Hi garaiburu,

I think you problem is with the path

Actually the path you specified contain "\" which is used as escape character.

Try replacing it with "/".

i.e., var request:URLRequest = new URLRequest("images/angry nell.jpg");

:}

garaiburu
July 25th, 2007, 04:22 AM
thanks Roy. I'll give it a go when I get home

cheers John

dthought
July 25th, 2007, 10:16 AM
Be careful with leading slashes too, as unless you are viewing it as run from a webserver, Flash will not be looking in the correct root location. You need to use relative paths when previewing locally as opposed to absolute ones.