Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-15-2006, 02:31 PM   #1
CthulhuChild
Easily Confused
 
CthulhuChild's Avatar
 
Join Date: May 2006
Location: Toronto
Posts: 15
Default Relative Directory Paths in flash

More insanity.

Ok, so I'm opening a file with loadvars, menuInfo.txt (tells this little flash banner what contents to have in the menu and what each item links too).

The banner file is simply embedded in every page on the site. The menuinfo.txt file is in the root\(some random crap\Site directory, along with an index.htm file. The rest of the pages are all in root\(some random crap\Site\Pages directory. The flash banner is in root\(some random crap\Site\Flash\banner.swf. That "random crap" section is subject to continual change as we move stuff around, so everything has to be relative to the \site directory.

The problem: banner.swf may be in the same place relative to all the other files, except that flash bases all relative paths on the page in which swf is embedded. Which is to say, the link "/pages/information.html" would be valid when you click on it in the index, but the link is broken for all instances of the banner apearing in the /pages directory (htm files with banner.swf embedded in them interpret the link as /pages/pages/information.html)

You see the problem?

It's even more frusterating because the menuInfo.txt file, from which the links all come from in the first place, suffers this problem: flash often can't even find it, because it's in the wrong directory.

Basically, I want to specify that all pathing is done relative to where the SWF file is located, NOT where the current page is located. If I can't do this, I'm going to have to move the index.html file into /pages and create a dummy index that just forwards instantly. And while that might work, it's a hack, and my boss won't like it.

Any thoughts?
CthulhuChild is offline   Reply With Quote
Old 06-15-2006, 02:38 PM   #2
senocular
six eyes
 
senocular's Avatar
 
Join Date: Jan 2003
Location: San Francisco, CA (USA)
Posts: 7,875
Send a message via ICQ to senocular Send a message via AIM to senocular Send a message via MSN to senocular Send a message via Yahoo to senocular
Default

use the _url property of the SWF to get its location on the drive and prefix all relative file references with that location
__________________
(6)
senocular is offline   Reply With Quote
Old 06-15-2006, 07:44 PM   #3
CthulhuChild
Easily Confused
 
CthulhuChild's Avatar
 
Join Date: May 2006
Location: Toronto
Posts: 15
Default

_url will return the location of the SWF then?

That would be... useful, to say the least.
CthulhuChild is offline   Reply With Quote
Old 07-10-2006, 04:30 PM   #4
CthulhuChild
Easily Confused
 
CthulhuChild's Avatar
 
Join Date: May 2006
Location: Toronto
Posts: 15
Default

Bah. Sorry to necropost.

Anyway, _url gives the absolute path, including the swf file. So it might be http://www.somesite.com/flash/myflash.swf.

Now, if myflash.swf was embeded in www.somesite.com/main/user666/default.asp, any url's specified in lang.load would be based on that path: that is to say, lang.load("../menuInfo.txt") would load www.somesite.com/main/menuinfo.txt

Let's say menuinfo.txt is located on the actual root (http://www.somesite.com/menuinfo.txt), and the flash that accesses it shows up all over the damned place (at varying levels, relative to the root).

What I want is to specify "one level above the swf's location", which (since the flash is at www.somesite.com/flash/ would point to the root). I could do this I suppose by taking the _url constant and cutting off /flash/myflash.swf, but this strikes me as fairly brute force. What if I renamed the directory, for example? Alot of pages may have similar structure, but different names, and I want my code to be reusable with the minimum changes. Is there an elegent way to use _url to perform relative pathign from the swf's location (rather than from the page displaying the swf's location), without resorting to just outright parsing it?
CthulhuChild is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimizing Flash Web Sites for Search Engines rockcoastmedia General Chat 19 03-29-2009 09:31 PM
[Q] Do we need those forums??? CyanBlue General Chat 59 07-27-2004 11:13 AM
Relative Paths with getURL Action JeffHobbs ActionScript 1.0 (and below) 1 06-26-2003 01:41 PM
Php, Javascript, and Flash 5 browser detect and more! Redline01 Server-Side Scripting 2 08-11-2001 01:09 AM


All times are GMT. The time now is 08:04 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.