PDA

View Full Version : Flashvars problem


mrgee
10-15-2008, 06:42 AM
I am having trouble with flashvars and passing variables to flash
here is my html
-----------------
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '550',
'height', '400',
'src', 'test',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'test',
'bgcolor', '#ffffff',
'name', 'test',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'test',
'salign', ''
); //end AC code
}
</script>
<noscript>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase=""http://macromedia.com/cabs/swflash.cab#version=9,0,0,0""
WIDTH="250" HEIGHT="250" id="test" ALIGN="CENTER">
<PARAM NAME=movie VALUE="test.swf">
<PARAM NAME=FlashVars VALUE="id=sport.mp4">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<embed src="test.swf" FlashVars="id=sport.mp4"
quality="high" bgcolor="#FFFFFF"
FlashVars="id=sport.mp4"
WIDTH="250" HEIGHT="250"
NAME="test" ALIGN TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</OBJECT>
</noscript>
------------

and here is the actionscript
--------------
function loaderComplete(myEvent:Event)
{
var flashVars=this.loaderInfo.parameters;
my_text.text=flashVars.id;


}

this.loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);


--------------
Why is the my_text text box empty??
Any help thanks..

The Brow
10-15-2008, 07:11 AM
my_text.text = this.parameters.id;

mrgee
10-15-2008, 07:18 AM
my_text.text = this.parameters.id;

Thanks..
I tried that and my_text textfield is still empty..
The variable is not being passed for some reason..?

The Brow
10-15-2008, 07:22 AM
From my code:
var fnCFG:String = this.parameters.cfg;

I tried your version with this.loaderInfo.parameters.cfg and it didn't work.

I took out loaderInfo and it worked again.

That's all I've got for now.

The Brow
10-15-2008, 07:25 AM
Also try removing the <noscript> tags.

The Brow
10-15-2008, 07:30 AM
It seems odd to me that you joined this forum over four years ago and are still struggling with FlashVars.

mrgee
10-15-2008, 07:35 AM
It seems odd to me that you joined this forum over four years ago and are still struggling with FlashVars.

Im a slow learner

The Brow
10-15-2008, 07:39 AM
You also have two occurrrences of FlashVars in the embed tag and there is no closing embed tag.

mrgee
10-15-2008, 07:50 AM
You also have two occurrrences of FlashVars in the embed tag and there is no closing embed tag.

Thanks..
I fixed these errors .. but still nothing in the text box

The Brow
10-15-2008, 07:57 AM
your param tags need to end with a forward slash:

<param name="quality" value="high" />

mrgee
10-15-2008, 08:11 AM
your param tags need to end with a forward slash:

<param name="quality" value="high" />

Thsnkas..
I have check the param tags.. all are correct..
When I debug the fla I receive this error
-------
Attemping to launch and connect to Player using URL D:\reel\test.swf
[SWF] D:\reel\test.swf - 114611 bytes after decompression
TypeError: Error #1010: A term is undefined and has no properties.
at test_fla::MainTimeline/frame1()[test_fla.MainTimeline::frame1:2]
--------
Again here is the script
----------
var myVar:String =this.parameters.id;

my_text.text = myVar;

The Brow
10-15-2008, 08:25 AM
Sorry I couldn't help - I'll leave it at this. Your original code had noscript tags around the object embed. But there was nothing in the script section to run your page. In the html you showed, the noscript tags shouldn't be there, and your page won't run that way.

The Brow
10-15-2008, 08:32 AM
You need a flashvars in the AC_FL_RunContent call. I guess that is the Javascript to load your page but none of the parameters match what's in the noscript section. Also as a I said you need to pass FlashVars in there as well. Or just remove it. Right now its calling AC_FL_Runcontent. (At first glance I thought that was loading the Flash Installer.)

mrgee
10-15-2008, 09:26 AM
You need a flashvars in the AC_FL_RunContent call. I guess that is the Javascript to load your page but none of the parameters match what's in the noscript section. Also as a I said you need to pass FlashVars in there as well. Or just remove it. Right now its calling AC_FL_Runcontent. (At first glance I thought that was loading the Flash Installer.)

OK
Here is my html
-----------
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test</title>

</head>
<body bgcolor="#ffffff">

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="test" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name=FlashVars value="id=sport.mp4"/>
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="test.swf quality="high" bgcolor="#ffffff" FlashVars="id=sport.mp4"
width="550" height="400" name="test" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

</body>
</html>

and here the as
---------------
var myVar:String =this.parameters.id;

my_text.text = myVar;
-
the text box is still empty.

JLM
10-15-2008, 01:14 PM
public function processLoadVar():void
{

_timer = new Timer( 40, 0 );
_timer.addEventListener( TimerEvent.TIMER, isReady );
_timer.start();
}


private function isReady( e: TimerEvent )
{

_allFlashVars = LoaderInfo( (root as MovieClip).loaderInfo ).parameters;


var notEmpty: Boolean = false;

for( var all in _allFlashVars )
{
notEmpty = true;
break;
}

if( notEmpty )
{
_timer.stop();
loadvarReady();
}

}


flash vars are not always ready imediately especially if there are lots.

The Brow
10-15-2008, 04:04 PM
OK
Here is my html
-----------
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>test</title>

</head>
<body bgcolor="#ffffff">

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" id="test" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name=FlashVars value="id=sport.mp4"/>
<param name="movie" value="test.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="test.swf quality="high" bgcolor="#ffffff" FlashVars="id=sport.mp4"
width="550" height="400" name="test" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

</body>
</html>

and here the as
---------------
var myVar:String =this.parameters.id;

my_text.text = myVar;
-
the text box is still empty.


All those problems I originally mentioned in the html object embed section aren't the issue. I tried running my own page from Firefox with multiple flashvar sections in the embed tag and with no closing embed tag and surprisingly it ran anyway. (The embed tag is only relevant to Netscape browsers I think). Also, HTML doesn't care about the closing "/" either.

As I mentioned in my last post, Your AC_FL_RunContent call in the javascript section is what's running your page and it has nothing in it to set Flashvars. You need something like the following:

AC_FL_RunContent(
"src", "Rad38",
"width", "100%",
"height", "100%",
"align", "middle",
"id", "zzzzzzz4",
"quality", "high",
"bgcolor", "#869ca7",
"name", "zzzzzzz4",
"flashvars",'cfg=zzzzzzz4.xml',
//"flashvars",'historyUrl=history.htm&lconid=' + lc_id + '',
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer",
"wmode", "transparent"
);


Since you enclosed the object-embed section in noscript tags it will only be executed if Javascript is not enabled. You could remove the noscript tags tags and the AC_FL_RunContent call and it would run, or you can fix the AC_FL_RunContent call. Your choice.

JLM
10-15-2008, 06:20 PM
did you try the swfobject in the head