PDA

View Full Version : Loaders and Paths



owl
November 18th, 2008, 12:37 AM
Hi,
I am new to this forum, I joined because I was having a hard time with an assignment I'm doing.

Basically I have to use loaders to bring in 5 separate jpeg images, which I have no problem doing as long as the .swf file and the images are together. Ideally I would like to be able to have the .swf file in one folder and the images in their own folder. Is there a way to do this?

This is my code now:


var myLoader:Loader = new Loader;

myLoader.x = 5
myLoader.y = 18

tibet1.addEventListener(MouseEvent.CLICK, loadJPG);
tibet2.addEventListener(MouseEvent.CLICK, loadJPG);
tibet3.addEventListener(MouseEvent.CLICK, loadJPG);
tibet4.addEventListener(MouseEvent.CLICK, loadJPG);
tibet5.addEventListener(MouseEvent.CLICK, loadJPG);

function loadJPG(event:MouseEvent):void {

var thingToLoad:URLRequest = new URLRequest(event.target.name + ".jpg");
myLoader.load(thingToLoad);
addChild(myLoader);

}

If this helps my path from the fla file is images/tibet_

shubs6
November 18th, 2008, 11:44 PM
I'm assuming that main.swf (Project's main file) is in src folder and there is another folder "images" in the project.
I mean I'm assuming yr project structure to be somewhat this - MyProj is project folder name

MyProj-->images-->tibet_-->tibet1.jpg and
MyProj-->src-->main.swf



var thingToLoad:URLRequest = new URLRequest("../images/tibet_" + event.target.name + ".jpg");
new URLRequest("../assets/ReceiveIM.mp3")

owl
November 19th, 2008, 01:18 AM
Thanks so much! Now that I know what it's supposed to look like, it makes perfect sense and I don't know why I didn't see it before.

Thanks again!

shubs6
November 19th, 2008, 01:20 AM
U r welcome my friend :-)