Groups | Blog | Home
all groups > flash (macromedia) > may 2004 >

flash (macromedia) : Dynamically Load FLV on Button Click


AdamMB
5/21/2004 8:43:59 PM
I would like to load different videos (located on a remote web server)
depending on which video the user clicks. The video URLs will not be specified
until the Flash Application is running (so I can't use the UI tools to set the
video source inside of Flash's designer). Can anyone give me an example of how
to do this using the Media components of Flash MX Pro 2004? I don't have a
problem getting the video to load if I use the Component Inspector on a Media
Playback component and specify the URL there, but if I try to use action script
to set the video at runtime, it doesn't play (or even begin to load the video).
So assuming I know I want to load a video located at
"http://someserver/myVideo1.flv" and I have a media playback component called
"mpcMainVideo", how would I load the video from the location into the component
and start it playing? Thanks in advance for any help anyone here can provide!

- Adam
mlangner-MMTS
5/21/2004 9:10:37 PM
I recommend reading the Flash MX documentation, specifically the "setMedia" attribute of the Media Components.

AdamMB
5/21/2004 9:13:40 PM
Thanks Mike for the suggestion, but I already tried that. I did:

myComponent.setMedia("http://myserver/myvideo.flv","FLV");

and that had no effect on the player whatsoever (and it did get called because
I watched the debugger). I also tried adding a:

myComponent.play(0);

Just to make sure it knew to play, but still no luck.

- Adam
AdamMB
5/21/2004 9:19:11 PM
Nevermind, I got it now. I am not used to programming action script yet and
didn't realize the way I was doing things meant that I needed to add _root. to
the name of the media control. That made it play just fine. (Why doesn't
calling a method on something that doesn't exist cause an error at
runtime?...Sorry, I'm from a C++/Java/C# background.) Anyway, thanks for the
help Mike.

- Adam
mlangner-MMTS
5/22/2004 12:02:16 AM
No problem, I only pointed you at the docs, you figured out the code you need. :)

AddThis Social Bookmark Button