0

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 looks 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&amp;VID=1273&amp;CHID=4" />
<embed src="http://dev.site.com/flash.swf" width="640" height="395" flashvars="fvar=http://360.flv&amp;VID=1273&amp;CHID=4">
</embed>
</object>
2
  • 1
    try setting the flashvars in both embed and object tags. I think some browsers use object tag, while other use the embed. Do you get any variables at all in any browser ? Commented Jun 22, 2010 at 16:12
  • hmm I'll add it now into the object, I've only tested in Safari on Mac so far, thanks for the feedback! Commented Jun 22, 2010 at 16:17

2 Answers 2

1

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;
Sign up to request clarification or add additional context in comments.

3 Comments

I tried that just now, using both your code and dana's... I think the problem still has something to do with the actionscript that tries to pick up the Flashvar :/ using Flash not Flex btw
Updated the answer with the AS3 code that works for me. See if it solves the issue.
Thanks Abinav! The way I was trying to get the other 2 variables was the problem :) but yeah your way works!
1

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&amp;VID=1273&amp;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&amp;VID=1273&amp;CHID=4">
    </embed>
</object>

3 Comments

Thanks, but still the player doesn't render, does my Flash code look correct?
OK, a couple of things here. First, your flash code shouldn't have to split the flashvars string. Depending on which version of flash you use, you can get at the flashvars object in a different way. in AS3 for example, you would do something like this: var x:String = LoaderInfo(this.root.loaderInfo).x; var y:String = LoaderInfo(this.root.loaderInfo).y; var z:String = LoaderInfo(this.root.loaderInfo).z; Also, try replacing the forward slashes (/) with %2f. For instance: http:%2f%2fhowtoevery... Not sure if that will help but it might?
I wish I could check both you and Abinav, but heres a vote up at least :D thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.