all groups > flash actionscript > may 2005 >
You're in the

flash actionscript

group:

Referencing External files


Re: Referencing External files Jammer
5/17/2005 12:00:00 AM
flash actionscript: Acually that is not correct. If you do not use a folder prefix at all, it
acually references the folder that the html file running the swf is in. For
instance if I do a load movie. And I am referencing a swf outside the folder as
the html file I am running, it will look for my loadmovie in the same folder as
the html file, not the swf.

I heard there was a way to reference the swf file. Any ideas? Anyone?
Referencing External files Jammer
5/17/2005 6:50:49 AM
Hey there,

Here is my questions. How do I reference files outside of flash, either
absolutely or relative.

I know the basic
../
goes to a parent folder
and
/
goes to the root, but I heard there is a way to refernce the folder that the
swf is in. Can you tell me how to do that?
Re: Referencing External files David Stiller
5/17/2005 8:58:55 AM
Jammer,

[quoted text, click to view]

It works in Flash exactly the way it works in HTML.

[quoted text, click to view]

To get to the folder the SWF is in, don't use a folder prefix at all;
simply reference the file.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Referencing External files David Stiller
5/17/2005 3:13:54 PM
[quoted text, click to view]

By bad! What you say is true, which is a bit puzzling until it becomes
second nature. I made the blunder of assuming your SWF was in the same
location as your HTML page. I'm chagrined. :-/

[quoted text, click to view]

Check out the MovieClip._url property, which you can use on the _root.
Trace that and see what it gives you.


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Referencing External files Jammer
5/18/2005 12:00:00 AM
Re: Referencing External files David Stiller
5/18/2005 10:01:27 AM
Jammer,

[quoted text, click to view]

There is. :)

Let's take a look. Start a brand new FLA. Enter frame 1 and type the
following:

trace(this._url);

Test your movie. I get this:

file:///C|/DOCUME%7E1/dstiller/LOCALS%7E1/Temp/Untitled%2D1.swf

Naturally, you'll get a different path, because your user name is
different, and you may have your installation set up another way. When the
_url property is run against a SWF on a website, the return value will be an
http:// address, which only makes sense, right? The return value is a
string, so you can perform String methods on it, such as
String.lastIndexOf(). (See the String class entry in the ActionScript
Language Reference for the full scoop.) By using, for example,
String.lastIndexOf() (and others), you can determine the string that
summarizes from http:// onward, up to the name of the SWF itself, and that's
your folder path.

Assuming this code is in the main timeline (where "this" would refer to
the _root) ...

loadMovie((this._url).substring(0, (this._url).lastIndexOf("/") + 1) + [name
of asset]);


David
stiller (at) quip (dot) net
"Luck is the residue of good design."

Re: Referencing External files Jammer
5/18/2005 5:50:20 PM
Sweet! Thanks! I will go ahead and try that. I'll let you know what I get.
Thanks for your help! And if you have any say in the development of Flash, feel
free to input that it would be nice that if a person put in
"././"
It would take them to the folder that the swf resides in. It is just a
suggestions. THanks again!!

AddThis Social Bookmark Button