How to get multiple Flashvars variables into Flash (not using swfobject)
I'm rebuilding this embedable player for a client of mine, the video file URL and a couple of other variables are in the HTML as Flashvars. I suspect something is wrong with the code that lo开发者_JAVA技巧oks for the flashvars.
The top part showing the green box is where the player didn't load because it was unable to obtain the Flashvars form the HTML. The player below has the Flashvars string hardcoded into the player so it works.
I believe the problem lies somewhere below Perhaps something wrong with the way I'm trying to pull in the Flashvars?
// LIVE Embedded
//vidURL = stage.loaderInfo.parameters.fvar;
vidURL = this.loaderInfo.parameters.fvar;
fvarText.text = "vidURL = this.loaderInfo.parameters.fvar"
vidSplit = vidURL.split(".flv")[0].split("/");
varVid = vidURL.toLowerCase().split("&vid=")[1].split("&")[0];
varChid = vidURL.toLowerCase().split("&chid=")[1].split("&")[0];
// Hardcode Testing
//(This creates the player that works at the bottom of the test page)
/*vidURL = "http://";
vidSplit = vidURL.split(".flv")[0].split("/");
varVid = vidURL.toLowerCase().split("&vid=")[1].split("&")[0];
varChid = vidURL.toLowerCase().split("&chid
I get this error when I export from Flash:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.Player::Embed/init()
at com.Player::Embed()
I expect this error however since obviously the Flash isn't embedded yet, but could this error shed any light on why my player isn't able to get the FlashVars link and then render itself?
The HTML embed code:
<object width="640" height="395" border="0">
<param name="flashvars" value="fvar=http://360.flv&VID=1273&CHID=4" />
<embed src="http://dev.site.com/flash.swf" width="640" height="395" flashvars="fvar=http://360.flv&VID=1273&CHID=4">
</embed>
</object>
You need to set the flashVars param in both the object as well as the embed tag. Check out this link http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html
<object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab' height='100%' width='100%'>
<param name='src' value='FlashVarTest.swf'/>
<param name='flashVars' value='firstName=Nick&lastName=Danger'/>
<embed name='mySwf' src='FlashVarTest.swf' pluginspage='http://www.adobe.com/go/getflashplayer' height='100%' width='100%' flashVars='firstName=Nick&lastName=Danger'/>
</object>
To get values inside Flash. Use this:
var firstName:String = stage.loaderInfo.parameters.firstName;
var lastName:String = stage.loaderInfo.parameters.lastName;
Like George said, you could try using flashvars for both the and tag. Also, I quote my attribute values and escape my ampersand (&). The following code should work:
<object width="640" height="395" border="0">
<param name="flashvars" value="file=http://how.llnwd.net/o18/UpDo_H_828-640x360.flv&VID=1273&CHID=4" />
<embed src="http://dev.site.com/flash.swf" width="640" height="395" flashvars="file=http://how.llnwd.net/o18/UpDo_H_828-640x360.flv&VID=1273&CHID=4">
</embed>
</object>
精彩评论