Skip to main content
Inspiring
June 11, 2009
Question

query string variable from "loaderInfo.parameters" always "undefined"

  • June 11, 2009
  • 1 reply
  • 742 views

I've searched the internet and these forums and found plenty of information on accessing query strings using loaderInfo.parameters but they're all written for ActionScript in the Timeline and none of them work for me.

This is my HTML:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="800" height="500" id="eamchartmaster04" align="middle">
     <param name="allowScriptAccess" value="sameDomain" />
     <param name="allowFullScreen" value="false" />
     <param name="movie" value="eamchartmaster04.swf?swfid=3" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />

        <embed src="eamchartmaster04.swf?swfid=3" quality="high" bgcolor="#ffffff" width="800" height="500" name="eamchartmaster04" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
     </object>

...which is a modification of the HTML that Flash generates, which I'm eventually not going to be using but this is for quick testing purposes. I have read that Flash's "AC_RunActiveContent.js" has to be modified to use the flashVars parameter, but does it have any affect on query strings appended to a URL?

The variable I want is swfid (=3).

eamchartmaster04.fla has a Document class, EAMChartMaster.as. Within that I have the following ActionScript:

// class constructor

public function EAMChartMaster() {
               // set this as the parent object
               myParent = this;
               myParent.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
          }

private function loaderComplete(myEvent:Event):void {

               myLoaderInfo=myParent.loaderInfo.parameters;
               testTxt.text = String(myParent.loaderInfo.parameters.swfid);
               
          }

testTxt is ALWAYS "undefined".

I've also tried creating an Object (eg. myQueryStrings), loading loaderInfo.parameters into that object and then accessing it as a property of the object (eg. myQueryStrings.swfid) to no avail.

Note the "myParent" object is created for scoping to other classes, but I used it here in desperation because "this" and "this.root" did nothing, but they should all be the same thing.

Thanks for any help!

This topic has been closed for replies.

1 reply

maijakgAuthor
Inspiring
June 11, 2009

Wow, "preview" would be nice so that I could see that my "raw HTML" wasn't going to show up. Instead I've attached the HTML file, but all I've done is appended a query string "?swfid=3" to the param value and embed src.

This is the script again, since it also got bungled by the "raw HTML" feature:

// class constructor

public function EAMChartMaster() {   

            // set this as the parent object              

          myParent = this;               

          myParent.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);         

}

private function loaderComplete(myEvent:Event):void { 

              myLoaderInfo=myParent.loaderInfo.parameters; 

              testTxt.text = String(myParent.loaderInfo.parameters.swfid);                         

}

EDIT: interesting that reply posts have an "edit" option but initial posts do not.

maijakgAuthor
Inspiring
June 11, 2009

I looked into my own question about AC_RunActiveContent.js, and why yes, it does need to be addressed, no matter how you want to pass your variables. So in addition to appending the query on the filenames in the HTML object section, it also goes in the javascript in the HTML like so:

<script language="javascript">
    if (AC_FL_RunContent == 0) {
        alert("This page requires AC_RunActiveContent.js.");
    } else {
        AC_FL_RunContent(
            'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
            'width', '800',
            'height', '500',
            'src', 'eamchartmaster04',
            'quality', 'high',
            'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
            'align', 'middle',
            'play', 'true',
            'loop', 'true',
            'scale', 'showall',
            'wmode', 'window',
            'devicefont', 'false',
            'id', 'eamchartmaster04',
            'bgcolor', '#ffffff',
            'name', 'eamchartmaster04',
            'menu', 'true',
            'allowFullScreen', 'false',
            'allowScriptAccess','sameDomain',
            'movie', 'eamchartmaster04?swfid=3',
            'salign', ''
            ); //end AC code
    }
</script>

Similar things would have to be done with SWFObject, I assume.

At least I know my actionscript-fu is not weak.

June 21, 2009

Thanks for this, I don't know if I missed this piece of information in all other tutorials but I could not see why my code was not working until I found this!