passing flv url from html


Im quite new to flash/actionscript. Id be very grateful if you could help me.

Im using the FLVPlayback component and trying to pass the url for the flv through html.   The idea is to make the page dynamic so that the user can decide what movie to play.  SWFObject or FlashVars seems to be the way to go. However i havent been able to get it working.  it seems to be a simple thing to implement, but it just does not work for me.

FYI im using ActionScript 3.

my html and AS3 code are below


HTML Code:
<script type="text/javascript" src="swfobject.js"></script>
	<div id="flashcontent">
	<script type="text/javascript">
		// <![CDATA[
		var so = new SWFObject("movie1.swf", "MyFBulletin", "512", "325", "8", "#FFFFFF");
		so.addVariable("movieurl", "");
		// ]]>
ActionScript3  code
var movieurl:String;
movieurl = root.loaderInfo.parameters['movieurl'];

Open in new window

Who is Participating?
Aneesh ChopraConnect With a Mentor Commented:
here is a working sample version I have done for your review:

I also want to update you on the fact that FLV path must be of the same server where SWF is hosted,
in case you want to load the FLV from different server then you need to implement the crossdomain.xml
You can get the variables by

movieurl = Request.QueryString("movieurl");

if your url is like
Aneesh ChopraCommented:
YOUR CODE seems perfect,

make sure:
1) FLV path is correct
2) FLVPlayback instance property "autoPlay" has been set to 'true';
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

espadanaAuthor Commented:
Thanks for the reply, the issue is that I get the following error:

1119: Access of possibly undefined property loader through a reference with static type flash.display:DisplayObject.

there is something wrong with this line
movieurl = root.loaderInfo.parameters['movieurl'];

Ive tried subtituting "root" with "this" and "super".  I dont get the error anymore, but nothing plays.  Ive also set "autoPlay" to true.

Would i need to import a specific library?
Aneesh ChopraCommented:
try adding following import line on top:

import flash.display.LoaderInfo;
espadanaAuthor Commented:
Thanks; tried that but still the same issue.

I was just wondering if its possible for you to try this code with the flvplayback component, and if it works for you after testing it, to email me the fla file?  Ive tried everything, and dont know what else to do about it.

Im using flash CS3 with AS3

my email is pars AT

Many thanks
Hellow all,

In your html code you use

so.addVariable("movieurl", "");

This means that in the _root of the .fla a variable is set with the value, like
_root.movieurl = "";

In your actionscript you define a new variable with the same name

var movieurl:String;

Maybe this variable overwrites the one that you have set by using flashVars, so the value is NULL or UNDEFINED.

Try changing your as code to:

var movieurlFlash:String;
movieurlFlash = root.loaderInfo.parameters['movieurl'];

Maybe this works.


Aneesh ChopraCommented:
Hi wal_toor,

same variable name will not be any problem in this case, because in AS3 FlashVars variables does not get set on root,
it comes under "root.loaderInfo.parameters"
Hellow aneeshchopra,

Ahaa, i did'nt know that. Thanks.
espadanaAuthor Commented:
Thanks aneeshchopra! your solution worked!

Im not sure why my original one didnt work, as it looks exactly the same as yours!  Maybe there is some sort of settings in the project thats causing this?

Thanks again!!
espadanaAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.