Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Loading external swf and setting its relative path

Posted on 2008-06-10
3
Medium Priority
?
3,744 Views
Last Modified: 2010-01-25
I am trying to create a flash viewer, which will load various other flash movies. The viewer will be in the root directory, but the flash movies it will load are a few directories deep. Those movies access various sound clips that are in an audio directory relative to each swf I want to load.

/flashViewer.swf
/myContent/someProgram/program.swf
/myContent/someProgram/audio/sound1.wav

It seems that when I load one of these movies into my viewer, the loaded movie is looking for the sounds in an audio folder in the root directory, and not relative to the swf I loaded. Is there a way to set this? I would rather not have to make the changes in each of my other movies to use the absolute path
var request:URLRequest = new URLRequest(movieSrc);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
loader.load(request);
stage.addChild(loader);

Open in new window

0
Comment
Question by:newstandard
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 21753957
I think it's safer to just move the files.

When you load any *.swf into another *.swf, it's URL changed to that one of the parent, in this case, the root directory. The easiest thing to do in this kind of scenarios is to move them, so you end up with something like this:

/flashViewer.swf
/audio/sound1.wav
/myContent/someProgram/program.swf

-V
0
 

Author Comment

by:newstandard
ID: 21754943
That would work, except the audio files have the same name for each swf. I would move the swf's that Iam trying to load, but the point of me creating the viewer is to try and make them hidden, as we are trying to secure them as much as we can.
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 1000 total points
ID: 21764319
Mhh... I'm afraid that's just not possible. Once you load a *.swf into another, it's url is the same as the main *.swf who loaded the child.

You have two options, either modify each "loadable" swf with a path coming from the loader (/myContent/someProgram/audio/sound1.wav instead of just audio/sound1.wav), or the one I mentioned earlier... with the issue of the repeating file names.

-V
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question