Passing variables into Flash not working

Discussion in 'Software' started by shedlord, May 10, 2010.

  1. shedlord

    shedlord Private E-2

    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','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width','697','height','550','src','newbook?z one=1','flashvars','zone=1','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','newbook?zone=1' ); //end AC code </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" 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="http://www.macromedia.com/go/getflashplayer" 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
     
  2. shedlord

    shedlord Private E-2

    If it helps, I've uploaded test files showing what is happening (or not happening rather). 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, the lightbox stuff won't work on these because those parts aren't included in the test files and I don't think that has any bearing on the issue. They are at http://www.opg2.co.uk/flash/flipper.zip (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 http://www.opg2.co.uk/flash/works.html and a failing one with an attempted passing of the XML filename at http://www.opg2.co.uk/flash/fails.html

    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.

    The files can be downloaded from http://www.opg2.co.uk/flash/flipper.zip
     
  3. shedlord

    shedlord Private E-2

  4. PC-XT

    PC-XT Master Sergeant

    I have no idea, really, as I don't do flash yet, but since noone else has answered yet, I'll attempt it...

    http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html says "You assign the values of these properties after the application's creationComplete event is dispatched. Otherwise, the run-time properties might not be available when you try to assign their values to local variables." This is for MXML, but someone said you can also access it from stage.loaderInfo.parameters, so the same condition probably applies.

    Then, some say it is better to pass it the old way, with the url, as in "test.swf?myvar=testing&user=me" and use trace(_root.myvar) or trace(_root.user), respectively, or maybe parameters.myvar and parameters.user, which was replaced because it requires the code to be executed before it can start loading the data, or something like that.

    Other possibly relevant links:
    http://kb2.adobe.com/cps/164/tn_16417.html
    http://kb2.adobe.com/cps/142/tn_14253.html

    I wish I could be of more help.
     
  5. shedlord

    shedlord Private E-2

    Have got this working now, using Flashvars brought into the actionscript like this...

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

    Thanks for trying anyway, appreciated.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds