Author Topic: How do i change the "relative to swf" issue?  (Read 1611 times)

Antibody

  • Newbie
  • *
  • Posts: 2
How do i change the "relative to swf" issue?
« on: March 17, 2010, 01:00:39 am »
I would rather not have any of the assets, xml or images, load relative to the megazine.swf. Can someone please tell me how to change that? I rather like loading things relative to the html page, not an asset in that page.

Thank you.


Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: How do i change the "relative to swf" issue?
« Reply #1 on: March 18, 2010, 06:36:50 pm »
If you want/can, use the current trunk, otherwise wait for the next release:
I've added a possibility to tell the engine to not resolve paths relative to the
swf, but the html instead, by passing the value ":html:" via the basePath FlashVAR.
I.e. you'd put basePath : ":html:" to the list of passed variables (same block
where the xmlPath goes).

// Edit: realized this is the 1.x section. Are you using 1.x? In that case, you'll have to
do some change to the sources rebuild the engine yourself. Look for the getAbsPath
function in the MegaZine class, and change it to always return the given url parameter.
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

Antibody

  • Newbie
  • *
  • Posts: 2
Re: How do i change the "relative to swf" issue?
« Reply #2 on: March 18, 2010, 11:42:19 pm »
Great! Thanks for that. I ended up just hardcoding the image links in the xml instead and used xmlFile to point to the xml file. That sorted out the reason for the question.

CainVampyr

  • Jr. Member
  • **
  • Posts: 31
Re: How do i change the "relative to swf" issue?
« Reply #3 on: May 31, 2010, 07:01:20 pm »
If you want/can, use the current trunk, otherwise wait for the next release:
I've added a possibility to tell the engine to not resolve paths relative to the
swf, but the html instead, by passing the value ":html:" via the basePath FlashVAR.
I.e. you'd put basePath : ":html:" to the list of passed variables (same block
where the xmlPath goes).

// Edit: realized this is the 1.x section. Are you using 1.x? In that case, you'll have to
do some change to the sources rebuild the engine yourself. Look for the getAbsPath
function in the MegaZine class, and change it to always return the given url parameter.

Hi, we just tripped on this same problem our selfs, the diff is we're going to be running the MegaZine3 in standalone mode, probably embedded in Zink... and the thing is we cant actually pass any url encoded values while loading swf's, like query values, and we're not using any html to lunch the app so no flashvars either...

We can obviously hack the core engine and tune it to our needs... however I wonder if it wouldn't be a good idea to have some sort of singleton value where we can define the loading prefix that would then be applied to the basePath value...

something like: MegaZine.loadPrefix = "some/folder/path/"
this of course would probably lead to make basePath a static property as well that would be updated whenever "MegaZine.loadPrefix" setter was invoked....

CainVampyr

  • Jr. Member
  • **
  • Posts: 31
Re: How do i change the "relative to swf" issue?
« Reply #4 on: June 01, 2010, 11:24:01 am »
Hum, after further testing we realized that the actual problem is with how basePath is being constructed at the moment... is there a special reason why you use loaderInfo.loaderURL intead of loaderInfo.url to construct it?

Since the loaderURL points to the swf owner of the swf loaded where this displayObject is found it tends to produce odd basePaths that don't adapt well to dynamic uses of the megazine engine.

For instance if we run the megazine on standalone by calling the preloader directly the loaderURL will point to the same path as the main.swf since they're both on the same folder.

However if for some reason you call the preloader from inside another SWF that is somewhere else other then the same folder as the preloader.swf and main.swf then the loaderURL will point to that other folder
Which will inevitably generates an invalid basepath.
This happens because we changed the preloader to add the main.swf to itself and not the stage, from my point of view it's a bad practice to assume we have access to the application root specially if we have no actual need to do it...

PS: Just realized the original issue was with an older version of MZ3, evil search function! he he he, guess I'll make a new post on the right forum regarding this issue...
« Last Edit: June 01, 2010, 02:59:47 pm by CainVampyr »