Skip to main content
October 9, 2007
Question

Reading Querystring into FLASH variable

  • October 9, 2007
  • 14 replies
  • 793 views
I can't believe I can't make this work. I've even done this in the past, but everything I try, fails.

i want FLASH to read the querstring value from the address bar, apply that value to a variable, and be able to use it. I've read the articles all over the net about grabbing the QS value in the page that loads the SWF and sticking it into the embed and movie tags as well as the ones about using PARAM=FLASHVARS etc.

can't make it work.

I can grab the QS value in the .asp page that loads the SWF, but I can't for the life of me pass that value into FLASH. Can someone please give me two things:

1. whats the most effective/efficient way to pass the variable
2. the syntax for assigning the value to a variable in FLASH

Thanks tons all!
This topic has been closed for replies.

14 replies

Inspiring
October 9, 2007

there is no "standard" javascript replacement script - unless you consider the adobe one a standard. There are a number of different scripts that do the same thing, another one is called UFO. swfobject happens to be my favourite and also seems to be reasonably popular with others (including Adobe who have used it in their own sites)

It should work with the AC_FL_RunContent call as well (so long as you have the corresponding javascript file also on your server). But I tend to find swfobject easier.


October 9, 2007
i tried putting the variables in the AC.. block as well..no good. i did find a way to make it work.

downloaded a swfobject.js file and uploaded it to the server (is this a standard file?)

added to the head of the ASP page:
<script type="text/javascript" src="swfobject.js"></script>

then used this in the body of the page to load the SWF including the variables:

<div id="main" style="width:859px; height:1250px;"></div>

<script type="text/javascript">
var so=new SWFObject('randomItemGallery_v2.swf', 'randomItemGallery_v2_swf', '859', '1250', '9', '#000000');
so.addVariable('galpick2', '<%=strGallery%>')
so.write('main');
</script>

in the FLA, galpick2 is no a useable variable that returns the value that strGallery grabs.

works great...sure seems like I should have been able to do the same thing by adding some code in the AC_FL_RunContent call with all of the parameters there.

Thanks all for your help.
Inspiring
October 9, 2007
There is another thing there that is not so obvious (it would be easier to see if you had used the attachCode option)
The way it is at the moment only works with javascript switched off.
You need to put your server variable in the AC_FL_RunContent call as well for the galpick value.

And... make sure you have the javascript file for that (I think Dreamweaver would probably generate that automatically).

Inspiring
October 9, 2007
Your value should be accessible as simply _root.galpick or galpick on the main timeline.


October 9, 2007
I figured that in the latest attempt that I posted, that AS3 code only MIGHT work. No suprise it doesn't, but I'm drawing blanks here.

The file is AS2

Yes, when the ASp page loads, the strGallery variable in the ASP page grabs the value of "g" from the querystring (which will be 0, 1, 2, 3, etc).

Whats next? lol.

i really appreciate it guys!
kglad
Community Expert
Community Expert
October 9, 2007
i agree with gwd, your posts don't consistant.

is this as2 or as3?

do you already have the query string extracted from the url (using asp)?
Inspiring
October 9, 2007
Perhaps your problem is not to do with the flashvars side of things and more to do with flash. Your topic summary for this topic says "AS2.0". The code you have on frame 1 is AS3 (ish) looking. It won't work in as2 if that's what you're using.
October 9, 2007
kglad: can you point me to the write tutorial somewhere for the flash externalinterface class? I'm using ASP to grab the querystring value no problem:

The user clicks the link to load the gallery page and show subgallery #2, they are taken to gallery.asp?g=2

<% strGallery = Request.QueryString("g") %>

That's what I'm trying to grab...the #2 so that i can tell the FLASH file to evaluate that # and display the correct sub-gallery.

strGallery just generates 2
Inspiring
October 9, 2007
kglad: that's true about that particular utility method, I see what you mean... but you don't really need to use that if you want to pass the whole querystring. In the end its just simply a question of when you use javascript. You could use it to provide the whole querystring to a flashvar at the time the embedding script is executed.. or you could do it afterwards from flash. Either is fine.
Inspiring
October 9, 2007
I just took a look at your post again.
You don't need to use javascript if your server is generating the right value.
But if <%=strGallery%> is generating the text "g=2" which you want to assign to galPick then that is your problem
You need <%=strGallery%> to be urlencoded so it should look like:
g%3D2