Hi, wondering if anyone here can help.
In brief, my question is, how can I pass a variable from a parent flash file to a child flash file which it calls?
- More detailed version:
We have a parent flash file which imports various child flash files based on instructions in an XML file. It's probably easier to see an example - - the text above each page, and the 'enlarge page' lightbox links are all in seperate flash files (one per double page) which are brought in, depending on the pages you are looking at, based on the instructions in an XML file which looks like this...
<page ani_swf="pages/text1.swf">pages/white.jpg</page>
<page ani_swf="pages/text1.swf">pages/0001.jpg</page>
<page ani_swf="pages/text2.swf">pages/0002.jpg</page>
<page ani_swf="pages/text2.swf">pages/0003.jpg</page>
etc, where the swf is the header flash file containing the text and one or two lightbox links, and the jpg files are the page images that appear.
We had to repeat the imported child flash file because of a glitch when you go backwards through the book otherwise.
This system has been fine for us up until now but recently we've had to look at making it a dynamic system, so the content of the book can be varied depending on a variable being passed into the parent file via FlashVars...
<param name="FlashVars" value="zone=1" />
<embed src="newbook3.swf" FlashVars="zone=1" ....etc
This makes the book load an xml file called "1"). This is fine, except we also need to vary the 'enlarge page' target images to match.
The 'enlarge page' links are currently hard coded into each child flash file, like this...
on (release){
getURL("javascript:SWFDelegate('imagename.jpg','Example');");
}
- What we've tried so far:
1. Trying to pass the variables in querystrings from the XML
eg.
<page ani_swf="pages/text2.swf?var1=image1&var2=image2">pages/0002.jpg</page>
<page ani_swf="pages/text2.swf?var1=image1&var2=image2">pages/0003.jpg</page>
with the child flash setting it's action like this...
on (release){
var image1 = var1 + ".jpg"
getURL("javascript:SWFDelegate(image1,'Example');");
}
I'm not sure if the syntax here is correct. We have to add the ".jpg" in here because, as far as I understand it, you can't pass "." in a querystring.
2. Passing the variables for the child into the parent
I read somewhere that variables passed to a parent are automatically available to a child. Not sure if this is true, but it didn't work for me when I tried it like...
<param name="FlashVars" value="zone=1?var1=image1&var2=image2" />
<embed src="newbook3.swf" FlashVars="zone=1?var1=image1&var2=image2" ....etc
Combined with...
on (release){
var image1 = var1 + ".jpg"
getURL("javascript:SWFDelegate(image1,'Example');");
}
...in the child button action.
Sorry if this is a bit confusing. It definitely confuses me!
Is there something really obvious we're missing here?
thanks
In brief, my question is, how can I pass a variable from a parent flash file to a child flash file which it calls?
- More detailed version:
We have a parent flash file which imports various child flash files based on instructions in an XML file. It's probably easier to see an example - - the text above each page, and the 'enlarge page' lightbox links are all in seperate flash files (one per double page) which are brought in, depending on the pages you are looking at, based on the instructions in an XML file which looks like this...
<page ani_swf="pages/text1.swf">pages/white.jpg</page>
<page ani_swf="pages/text1.swf">pages/0001.jpg</page>
<page ani_swf="pages/text2.swf">pages/0002.jpg</page>
<page ani_swf="pages/text2.swf">pages/0003.jpg</page>
etc, where the swf is the header flash file containing the text and one or two lightbox links, and the jpg files are the page images that appear.
We had to repeat the imported child flash file because of a glitch when you go backwards through the book otherwise.
This system has been fine for us up until now but recently we've had to look at making it a dynamic system, so the content of the book can be varied depending on a variable being passed into the parent file via FlashVars...
<param name="FlashVars" value="zone=1" />
<embed src="newbook3.swf" FlashVars="zone=1" ....etc
This makes the book load an xml file called "1"). This is fine, except we also need to vary the 'enlarge page' target images to match.
The 'enlarge page' links are currently hard coded into each child flash file, like this...
on (release){
getURL("javascript:SWFDelegate('imagename.jpg','Example');");
}
- What we've tried so far:
1. Trying to pass the variables in querystrings from the XML
eg.
<page ani_swf="pages/text2.swf?var1=image1&var2=image2">pages/0002.jpg</page>
<page ani_swf="pages/text2.swf?var1=image1&var2=image2">pages/0003.jpg</page>
with the child flash setting it's action like this...
on (release){
var image1 = var1 + ".jpg"
getURL("javascript:SWFDelegate(image1,'Example');");
}
I'm not sure if the syntax here is correct. We have to add the ".jpg" in here because, as far as I understand it, you can't pass "." in a querystring.
2. Passing the variables for the child into the parent
I read somewhere that variables passed to a parent are automatically available to a child. Not sure if this is true, but it didn't work for me when I tried it like...
<param name="FlashVars" value="zone=1?var1=image1&var2=image2" />
<embed src="newbook3.swf" FlashVars="zone=1?var1=image1&var2=image2" ....etc
Combined with...
on (release){
var image1 = var1 + ".jpg"
getURL("javascript:SWFDelegate(image1,'Example');");
}
...in the child button action.
Sorry if this is a bit confusing. It definitely confuses me!
Is there something really obvious we're missing here?
thanks