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

flash actionscript

group:

FlashVars


FlashVars cutie369
11/15/2006 9:47:07 PM
flash actionscript:
Isn't there at least one big strong man who can help me with this.

I do have a question in regards to FlashVars and how you test for the
existance of a certain value inside a SWF movie?

This code right here works fine for me.
if (_level0.myURL == undefined) {

}
else {
pflipper.gotoPage(3);
gotoAndStop(1);
}

However, it is not what I need. I want to be able to setup an if statement
with multiple else if statements. I have tried almost every possible
combination except the correct one.

Here is what I would like to do. If _level0.myURL == 1 then gotoPage(1) &
gotoAndStop(1) else if _level0.myURL == 4 then gotoPage(2) & gotoAndStop(4)

Can you please tell me what is the correct syntact for doing this.
Re: FlashVars arunbe
11/16/2006 1:45:19 PM
I think, the way you are using now is the general.
Otherwise you can trace all the varialbles in the _root.
like this...
for ( i in _root)
{
trace(i);
}

But, in this case, you know the FlashVar name, so you can use like this....
No other easiest way , I think......
Re: FlashVars cutie369
11/16/2006 2:01:32 PM
Can anyone help me how to develop this for loop. I am not familiar with how to
construct it. Also, I am not able to run trace while the swift is in an HTML
page..

for ( i in _root)
{
trace(i);
}
Re: FlashVars arunbe
11/16/2006 2:11:34 PM
hi,
this for loop is just to detect the variables and objects used in the main
file.
So , you can use this just to idenfy the the variables and Objects.
But, the way you are using now, is the only way.....i think.
Anyhow, if anyone know better idea, i can also know that....
Re: FlashVars cutie369
11/16/2006 2:19:11 PM
Re: FlashVars arunbe
11/16/2006 3:14:47 PM
hey, you can receive the values.
But, you cant predict them with all the variables in the main movie.
Look, if am sending a FlashVars likse my_swf.swf?myFlashVar="myName".

Here we go,
I can receive the value of myFlashVar in the my_swf files. like this,

// In the main timeline frame
if(this.myFlashVars != undefined)
{
trace("The Flash Vars :"+ this.myFlashVars);
}
kool, this wil help, i think... :)
Re: FlashVars 2m
11/16/2006 3:21:03 PM
Well what you do is just right, as far as I understand.

I suppose you set myURL via flashvars, so the way to do it is:

if (_level0.myURL == "option1"){
do this;
do that;
}
else if (_level0.myURL == "option3") {
do this;
do that;
}
else if (_level0.myURL == "option4") {
do this;
do that;
}
else { // this servers for undefined
do something else;
}

I hopr hat helps, if not pleas post a url or a zip for us to see the problem.

Markus

Re: FlashVars cutie369
11/16/2006 3:25:05 PM
Can anyone help me develop this further. It seems clear to me that I can never
access level0.myURL directly to determine it's value. However it seems that I
need to loop over _level0 to determine the existance of the value of myURL
which got passed in through FlashVars to _level0. I need to loop over _level0
to determine what is there? This is where I need help. Here is some starting
code. Can someone help me complete it.

var myURL = _level0.myURL
for (var myURL in _level0) {
//substatements; // Statements typically use thisElem in some way
pflipper.gotoPage(3);
gotoAndStop(1);
}
What code do I need to test to see if myURL exists in the for loop?

Re: FlashVars 2m
11/16/2006 3:34:53 PM
Sorry to contradict, but it is perfectly legal (and it also works!) to access
the variables that come via flashvars, the way you (try to) do it.

(You can also use loops, but there is no need to do so)

If it is not working, there must be another reason. So I repeat, pleas post a
URL, so that we can see and reconstruct the problem.

Give us a chance to be your heroes ;-)
Re: FlashVars cutie369
11/16/2006 3:52:03 PM
2m, I need a hero. I have been racking my brain on this for 2 days. I have
put your code in with the multiple if else statements and it is still not
working. I am passing the URL variable through ColdFusion. Here is the URL
http://www.graphicartsworld.com/level3.cfm?T1ID=15&T2ID=25&T3ID=16&myURL=4

Also, here is a link to download my FLA
http://www.graphicartsworld.com/pflipper.fla
Re: FlashVars 2m
11/16/2006 4:08:17 PM
As it seems the problem is not inside Flash, but with your cold-fusion I'm more
of a PHP-guy, so I might not be of great help there, but I can try to point you:

</div>
<script type="text/javascript">
// <![CDATA[

var so = new SWFObject("pflipper.swf", "pflipper", "500", "600", "8.0.23",
"#636363", true);
so.addVariable("myURL", [h]getQueryParamValue("4")[/h]);
so.write("comm");

// ]]>
</script>

the highlighted part should be something the is already evaluated to a value
by cf, I'd say, and it should also be inside quotation marks, for swf object to
work correctly.

Hope that helps.

Markus

Re: FlashVars cutie369
11/16/2006 4:17:03 PM
Markus, I don't think that is it because when I run this code. It works just
fine.

if (_level0.myURL == undefined) {

}
else {
pflipper.gotoPage(3);
gotoAndStop(1);
}

This is my ColdFusion code.

<cfif NOT ISDefined('URL.myURL')>
<cfset URL.myURL = 1>
</cfif>
<script src="js/swfobject.js" type="text/javascript"></script>
<div id="comm" style="margin:0px; padding:0px; text-align:left; width:500px;
height:350px; background-color:#636363;">
[B]You need to upgrade your Flash Player[/B]
<code>noscript</code>
</div>
<script type="text/javascript">
// <![CDATA[

var so = new SWFObject("pflipper.swf", "pflipper", "500", "600", "8.0.23",
"#636363", true);
so.addVariable("myURL",
getQueryParamValue("<cfoutput>#URL.myURL#</cfoutput>"));
so.write("comm");

// ]]>
</script>
AddThis Social Bookmark Button