0

I have a url like this

www.website.com?fname=Peter

and I have a Dynamic Text field as fnameurl in my Flash movie and want to show Peter in the Dynamic Text field once its opened on a browser. How can I grab the url Parameters and display it on the browser?

Thanks

1 Answer 1

1

The most straight forward way would be to use the FlashVars parameter. It is defined via an HTML param tag like this:

<param name='flashvars' value='name=value&amp;name2=value2' />

The value must be formatted as a URL query string. The indiviual key/value pairs will be made available in the root of the SWF movie. In AS2 you can simply access them using _root:

_root.name
_root.name2

In AS3 these values are available via LoaderInfo.parameters:

root.loaderInfo.parameters.name
root.loaderInfo.parameters.name2

Long story short, you could do it like this in PHP:

<param name='flashvars' value='fname=<?php echo urlencode($_GET['fname']); ?>' />

and then in AS:

fnameurl.text = _root.fname;

// or

fnameurl.text = root.loaderInfo.parameters.fname;
Sign up to request clarification or add additional context in comments.

5 Comments

Thanks @ndm. I tried this, but it outputs "Denied". What could be the reason?
Only the word "Denied"? Maybe your textfield is very small and that's just the last word of a longer error message? Check that, and also have a look the HTML source generated by your PHP file if there are any errors.
No. There are no errors. I cant see the fname value in my HTML source code, but not sure why it isnt passing to the swf file. I have fnameurl.text = _root.fname; in a movie clip, does that matter? And the fnameurl text field is in the same movieclip
And there are no other assignemts to fnameurl.text in your code? Might sound like a stupid question, but could it be that it actually says undefined? Becasue root.fname will neither work in AS2 nor in AS3. I assume you are using AS2 since you're not trying to access loaderInfo? In that case you are missing an underscore, it should be _root.fname In case that's not the problem it would be good if you would show your actual HTML output and AS code.
The difference is that without _root it will try to access a variable in the current scope, ie in your movieclip where your code is located, where as with _root it would access a variable in the top most timeline of the SWF movie, ie in the root, where the FlashVars variables would be located. So, not using _root will only work in case the code in question is defined in the root timeline too. What exactly goes wrong in your movie is pretty hard to say without knowing the exact movie structure, the HTML and AS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.