Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variables into Flash not working

Status
Not open for further replies.

shedlord2

Technical User
May 20, 2006
36
0
0
GB
Hi,

We have a web page which loads a Flash flipbook. This flipbook grabs the content of an external XML file which lists the images to be used for each page. I need to be able to send a word or number into the flash file which is then picked up and used as the name of the XML file. This will allow us to use the same flipbook to display different content depending on different the variable we pass in, without having to have multiple versions of the flash.

So, having tried all the different places to add the querystring which I understand you use to pass the variable, I currently have this in the web page (note, "zone" is my variable and I'm trying to set it as 1 here)...

<script type="text/javascript">
AC_FL_RunContent( 'codebase',' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" width="697" height="550">
<param name="movie" value="newbook.swf?zone=1" />
<param name="quality" value="high" />
<embed src="newbook.swf?zone=1" quality="high" pluginspage=" type="application/x-shockwave-flash" width="697" height="550"></embed>
</object></noscript>

...and in the actionscript I have replaced...

FFlippingBookCache.prototype.loadExternalXML = function(src) {
if (src != "") {
this.extXML.load("newbook.xml");
} else {
this._baseObject._onXMLComplete(false);
}
};

...with...

FFlippingBookCache.prototype.loadExternalXML = function(src) {
var myQueryStrings=this.loaderInfo.parameters;
xmlfile = myQueryStrings.zone;
if (src != "") {
this.extXML.load(xmlfile + ".xml");
} else {
this._baseObject._onXMLComplete(false);
}
};


Have also tried...

var xmlfile = trace(root.loaderInfo.parameters.zone);
FFlippingBookCache.prototype.loadExternalXML = function(src) {
if (src != "") {
this.extXML.load(xmlfile + ".xml");
} else {
this._baseObject._onXMLComplete(false);
}
};

...with no joy. Both ways it just displays no images.

I really am not an expert in Actionscript! Am I doing something wrong here?

thanks
 
Hi oldnewbie,

Firstly, thanks for your offer to help.

I've tried to strip down the files as much as possible, to cut some of the confusing chaff out. Ignore the stuff going on in the linked Flash files, just included them . They are at (attached also, hopefully). Sorry about the size of this, obviously some stuff inside the fla files that we don't need!

You can see a working one where the XML file name is hard-coded at and a failing one with an attempted passing of the XML filename at
The actionscript I'm editing to try get this to work appears under actions: Frame 1 inside 'Premium Page Flip'. Around line 153 in the original is a line saying this.extXML.load("1.xml"). I'm just trying to bring the "1" part in through the querystring.

Hopefully this all makes sense.
 
Just to update my question, I've also tried passing the variable this way...

<param name="FlashVars" value="zone=1" />

with no luck ( ).

I'm doing something very basic wrongly somewhere, probably in how the variable is being pulled in and used in the actionscript (?)

FFlippingBookCache.prototype.loadExternalXML = function(src) {
var myQueryStrings=this.loaderInfo.parameters;
xmlfile = myQueryStrings.zone;
if (src != "") {
this.extXML.load(xmlfile + ".xml");
} else {
this._baseObject._onXMLComplete(false);
}
};
 
correction: In my original post I said I'd amended an actionscript function containing "newbook.xml". That should read "1.xml" - newbook.xml is not referred to in either the hardcoded working test files or the failing ones.

Sorry about that.
 
No luck so far. Tried setting up the Flashvars like this - - as suggested by another site but didn't work.

Neither did bringing the variable in like this...

FFlippingBookCache.prototype.loadExternalXML = function(src) {
if (src != "") {
trace(root.loaderInfo.parameters.zone)
this.extXML.load( root.loaderInfo.parameters.zone+ ".xml");
} else {
this._baseObject._onXMLComplete(false);
}
};
 
This is now working, using Flashvars brought into the actionscript this way...

FFlippingBookCache.prototype.loadExternalXML = function(src) {
var xmlfile = zone;
if (src != "") {
this.extXML.load(xmlfile + ".xml");
} else {
this._baseObject._onXMLComplete(false);
}
};

I've a follow-up question but that needs it's own thread. Thanks for the help offer oldnewbie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top