|
-
anyone else hear that?
AS3 pass URL parameter
I must be missing something obvious. I'm trying to pass a parameter from a URL into a text field in flash, but it doesn't seem to work...
I've got a dynamic text field (display as html is checked), with an instance name txt_txt. Here's the only line of code in the file:
Code:
txt_txt.htmlText="test "+this.loaderInfo.parameters.nameVar;
And, when I upload it and use the following, I get "test undefined" as my return!?
http://www.brianwpiper.com/fk/tstURL...ameVar=testing
Can anyone help out on this??? What obvious thing am I overlooking??
TIA!!!
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
-
The parameters available from loaderInfo are the flashvars (if any) set in the embed/object for the swf. URL parameters for the page are not automatically available. To get them in the flashvars, you'll need to set the flashvars parameter with or whatever javascript you're using to generate the embed/object tag. If you're using a server side script to generate the page, you could put the parameters on the swf url there instead.
-
anyone else hear that?
Hmm....thanks...so, there's no way to directly get the info from the URL parameters??
The flash file is being launched in a modal window put together by the client so I'll have to work with them to make sure the parameters get read and passed to the flashvars correctly and the right javascript is in there...
Thanks!
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
-
Not directly, no. But if you can have script access, you could use ExternalInterface to run some javascript to get the page url, then parse it yourself.
Something like this:
Code:
function getPageParams():Object{
var params:Object = {};
if (ExternalInterface.available){
var pageurl:String = ExternalInterface.call("function getPageURL(){return document.location.href}");
var paramStr:String = pageurl.substr(pageurl.indexof("?")); //get the part after ?
var paramPairs:Array = paramStr.split('&'); //split into name/value pairs
for (var i:int = 0; i < paramPairs.length; i++){
var nameVal:Array = paramPairs[i].split("=");
params[nameVal[0]] = nameVal[1];
}
}
return params;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|