PDA

View Full Version : Problem with FlashVars


liquidgraph
06-18-2007, 01:24 AM
I'm using FlashVars to pass along two simple variables (previouspage & currentpage) to my .swf. Problem is, inside the .swf, these variables aren't recognized (it's telling me that the variables are undefined).

How exactly would I call the variables in Flash? And where would this call be made? I've tried what seems like every possiblity, but the variables are still "undefined."

My HTML Code:
<?php
session_start();
if(isset($_SESSION['previoustemp']))
{

}
else
{
$_SESSION['previoustemp'] = 123;
}
$_SESSION['current'] = 0;
$_SESSION['previous'] = $_SESSION['previoustemp'];
$_SESSION['previoustemp'] = $_SESSION['current'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="../../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<body>
<?php
echo "current: ". $_SESSION['current'] . "<br>";
echo "previous: ". $_SESSION['previous'] . "<br>";
echo "previoustemp: ". $_SESSION['previoustemp'];
?>
<a href="resume01.php">resume</a>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','508','height','25','title','test','src','../../flash/leogura_banner_02','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','../../flash/leogura_banner_02' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="508" height="25" title="test">
<param name="movie" value="../../flash/leogura_banner_02.swf" />
<param name="flashvars" value="previouspage=1&currentpage=0" />
<param name="quality" value="high" />
<embed src="../../flash/leogura_banner_02.swf" flashvars="previouspage=1&currentpage=0" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="508" height="25" ></embed>
</object>
</noscript></body>
</html>

My Flash Code:

switch(_root.previouspage){
case "0":
arrow01._x = 29;
break;
case "1":
arrow01._x = 101;
break;
case "portfolio":
arrow01._x = 181;
break;
case "education":
arrow01._x = 268;
break;
case "epistemology":
arrow01._x = 368;
break;
case "contact":
arrow01._x = 464;
break;
default:
arrow01._x = 300;
}

_root.texttext = _root.previouspage;
_root.currenttext = _root.currentpage;

_Aerospace_Eng_
06-18-2007, 01:38 AM
Because they are. It seems that you haven't been paying attention to what Dreamweaver has been doing to your code. Notice the code you tried to edit is in noscript tags? This means that code will only run if you have javascript disabled. You need to be editing this line
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','508','height','25','title','test','src','../../flash/leogura_banner_02','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','../../flash/leogura_banner_02' ); //end AC code
Change it to this
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','508','height','25','title','test','src','../../flash/leogura_banner_02','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','../../flash/leogura_banner_02' ,'flashvars','previouspage=1&amp;currentpage=0'); //end AC code

liquidgraph
06-18-2007, 05:26 AM
Thanks, that did the trick! I still don't quite understand why it works the way you say, because every other example of FlashVars implementation that I looked at was closer to the way I implemented originally than the way you gave me now.

_Aerospace_Eng_
06-19-2007, 09:38 PM
And they were the correct way however Adobe converts flash objects to their javascript counterpart to get around the EOLAS for Internet Explorer. All params need to go in the javascript function call. You should do what you've been doing as not everyone has javascript enabled though you may want to put in some text saying something like "If you are seeing this it means you have javascript disabled".