Link to home
Start Free TrialLog in
Avatar of pdben
pdben

asked on

Pass variable from JavaScript to ActionScript to load FLV clip

How can I pass a variable from JavaScript to ActionScript so that I can load different FLV clips with the same SWF file?

Currently, I use FlashVars within the HTML Flash Object tag to pass the variable, and in the SWF file I set up a variable to pass to the SWF Parameters for the video clip source. The source field is left blank in the SWF videoclip, but I have used ActionScript to set the source, and I call the video object "mymovie".

I have tested the ActionScript with manually setting the mymovie source to the appropriate file, and it works perfectly. But when I try to pass a variable to it from JavaScript, it is not found.

In the HTML file, I use FlashVars in the OBJECT tag, as follows:
<param name="FlashVars" value="mymoviesource=http://mysite.com/mymovie.flv">

In the SWF file, I use:
mymovie.source=this.root.mymoviesource
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Problem is in following code, where u trying to access passed variable:

mymovie.source=this.root.mymoviesource

it should be like this:

mymovie.source=_root.mymoviesource


-------------------
Aneesh Chopra
-------------------
Avatar of pdben
pdben

ASKER

I tried this, but now I get the error:

ReferenceError: Error #1065: Variable _root is not defined.
      at mymovie_fla::Symbol1_1/mymovie_fla::frame1()
are you using Flash CS3?

I wonder if _level0 might work in place of _root...
Avatar of pdben

ASKER

I am using Flash CS3.

I made the change to _level0 but got the same error.
in FLASH CS3

try following code:

mymovie.source=root.mymoviesource


only change is only "root" instead of "this.root"
Avatar of pdben

ASKER

That didn't work either.
I suggest if you can upload ur FLA for review
Avatar of pdben

ASKER

OK, here is everything zipped and uploaded.

You can download it at http://ourbeasley.com/media/kids/2007/mykids.zip

For simplicity, everything is located and referenced in the same directory.
Avatar of pdben

ASKER

Has anybody been able to check out the zipped file I uploaded for any answers (see above)?
Avatar of pdben

ASKER

Nobody has responded to this in almost a week, so I have resubmitted the question as a new question.
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdben

ASKER

Thanks, that did the trick!