all groups > flash actionscript > may 2006 >
You're in the

flash actionscript

group:

Pass filename as a variable to a swf file


Re: Pass filename as a variable to a swf file mostlyliquid
5/17/2006 9:36:04 PM
flash actionscript:
One way to do that is to use FlashVars as a parameter, and give that
parameter a value by requesting the querystring using php or asp. Then
that variable will be accessible within flash. So first make the page
with the swf a .asp or .php page. Then add the FlashVars parameter to
the list of parmeters in the object and embed tags on your page. So, it
will look something like this:

<object classid= blah blah .....
<param name=FlashVars
value="variablename=<%=request.querystring("variablename")%>>
NOTE: this sets the flash variable 'variablename' equal to the
querystring value,
in this case 'filename_to_use'

Also do this in the embed tag, a bit different tho:
<embed src="myFile.swf" quality="high" bgcolor="#1c2b2f" width="760"
height="50" name="myFile" align="top" allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
FlashVars="variablename=<%=request.querystring("variablename")%>"
pluginspage="http://www.macromedia.com/go/getflashplayer" />

Now, the querystring value is accessible at _root.variablename. So if
memory serves, for that component it will be
myMedia.setMedia(_root.variablename) - double check that. I suggest you
set up a simple flash file and little playground to test this - just
put a textbox on the stage and pass the variable value to it, then run
it on a server with the querystring to make sure its all working. Im
pretty sure my asp syntax is good but double check, and again you can
do this with php instead - im just more familar with asp. HTH!

-J
Pass filename as a variable to a swf file MYSCREENNAMEISUNAVAILABLE
5/17/2006 11:45:45 PM
I want to pass a variable which will represent a filename to a swf file from a
hypertext link in an HTML document.

When the user clicks on the link which has ?variablename=filename_to_use
appended to a "normal" link to a page,

this variablename will be passed to the swf file.

I've already created this target swf file to have an actionscript with a
FLVPlayComponent with the filename hard-coded in the actionscript. I want the
actionscript to use the variable representing the filename_to_use that was
passed to from the URL line.

The following is the actionscript that plays the flv file taken from the Flash
Help: Creating an Application with an FLVComponent
ORIGINAL VERSION:
import mx.video.*;
this.attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:320, height:240,
x:100, y:100});
my_FLVPlybk.skin = "file:///install_drive|/Program Files/Macromedia/Flash
8/en/Configuration/Skins/ClearOverPlaySeekMute.swf"
my_FLVPlybk.contentPath = "<a target=_blank class=ftalternatingbarlinklarge
href="http://www.helpexamples.com/flash/video/water.flv";


VERSION">http://www.helpexamples.com/flash/video/water.flv";


VERSION</a> USING THE FILENAME FROM THE PASSED VARIABLE INSTEAD OF WATER.FLV
import mx.video.*;
this.attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:320, height:240,
x:100, y:100});
my_FLVPlybk.skin = "file:///install_drive|/Program Files/Macromedia/Flash
8/en/Configuration/Skins/ClearOverPlaySeekMute.swf"
my_FLVPlybk.contentPath = "<a target=_blank class=ftalternatingbarlinklarge
href="http://www.helpexamples.com/flash/video/variable";

I">http://www.helpexamples.com/flash/video/variable";

I</a> currently can play videos with this actionscript at my school website
but must make a separate swf for each video.
I want to be able to have one swf file that will play which video was passed
from the link in the HTML page.
I am using HTML page to lower the bandwidth so that users won't have to load a
swf file to see curricular material and then perhaps choose a video on the
topic.

<a target=_blank class=ftalternatingbarlinklarge
href="http://www.wearekennedy.com/kent/whatsup.htm
click">http://www.wearekennedy.com/kent/whatsup.htm
click</a> the link to the Spring curriculum map with resources and then click
on e.g. The_Food_Web video

Thank you,
Kevin Kent
Educator, John F. Kennedy H.S., Bronx, NY
AddThis Social Bookmark Button