Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variables Syntax Question

Status
Not open for further replies.

GeeBee2

Technical User
Aug 29, 2005
12
US
Is there a way to pass the name of a file to my movie, right now I have it hard coded with the name, how do I pass it the name of a file via a variable instead. I am somewhat familar with ASP and Javascript

Thanks in advance

var quizItems=new Array();
var myData=new XML();
myData.ignoreWhite=true;
myData.onLoad=onQuizData;
myData.load("stop();
 
You can add it to your object/embed source code.

Code:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL unfurl="true"]http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"[/URL] width="550" height="400" id="default" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="default.swf[highlight]?variableName=whatever[/highlight]" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="default.swf[highlight]?variableName=whatever[/highlight]" quality="high" bgcolor="#ffffff" width="550" height="400" name="default" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] />
</object>

You would access that variable at _root.variableName.

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
Thanks Pixl8r,

for putting that together for me, What would the correct syntax be in my falsh document.

so instead of this
myData.load("
is this the correct syntax? do I put it in quotes?
myData.load("myvariable name here");


Thanks
 
The other way to pass variables from an HTML to a SWF is to use [tt]FlashVars[/tt] parameter.

Object tag:
[tt]<PARAM NAME=FlashVars VALUE="xmlPath=[/tt]

Embed tag:
[tt]<EMBED SRC="yourMovie.swf" FlashVars="xmlPath=[/tt]

Once set, [tt]FlashVars[/tt] are accessible as[tt] _root[/tt] variables.
[tt]//
myData.load(_root.xmlPath)
//[/tt]

For more info go to: <
Kenneth Kawamoto
 
Thanks Kenneth, you da man!

That worked perfectly, I am confused about one thing though
below is the code that I am using to play the movie. I want to pass the variable newquiz to the movie. I have tried

<PARAM NAME=FlashVars VALUE="xmlPath=newquiz">

That doesn't work - I know it is probably a syntax issue, any thoughts?

<%
newquiz ="'testing to see if I can write the varible out
response.write(newquiz)
%>

<body>
<PARAM NAME=FlashVars VALUE="xmlPath=<embed src="quiz_movie.swf" flashvars="xmlPath= height="400" ></embed>
</body>
 
Thanks again Kenneth, you put me in the right direction, this is what I ended up doing.
<%
newQuiz = " & thisMovie & "?embed"
%>

I could probably take the ?embed out, but it works and use the syntax below for the FLASH object


<PARAM NAME=FlashVars VALUE="xmlPath=<%=newQuiz%>">
<embed src="quiz_movie.swf" flashvars="xmlPath=<%=newQuiz%>" width="550" height="400" ></embed>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top