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.m ymoviesour ce
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.m
ASKER
I tried this, but now I get the error:
ReferenceError: Error #1065: Variable _root is not defined.
at mymovie_fla::Symbol1_1/mym ovie_fla:: frame1()
ReferenceError: Error #1065: Variable _root is not defined.
at mymovie_fla::Symbol1_1/mym
are you using Flash CS3?
I wonder if _level0 might work in place of _root...
I wonder if _level0 might work in place of _root...
ASKER
I am using Flash CS3.
I made the change to _level0 but got the same error.
I made the change to _level0 but got the same error.
in FLASH CS3
try following code:
mymovie.source=root.mymovi esource
only change is only "root" instead of "this.root"
try following code:
mymovie.source=root.mymovi
only change is only "root" instead of "this.root"
ASKER
That didn't work either.
I suggest if you can upload ur FLA for review
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.
You can download it at http://ourbeasley.com/media/kids/2007/mykids.zip
For simplicity, everything is located and referenced in the same directory.
ASKER
Has anybody been able to check out the zipped file I uploaded for any answers (see above)?
ASKER
Nobody has responded to this in almost a week, so I have resubmitted the question as a new question.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that did the trick!
mymovie.source=this.root.m
it should be like this:
mymovie.source=_root.mymov
-------------------
Aneesh Chopra
-------------------