Actionscript Button click to Flv video Help
I'm new at actionscript and not sure how to do this.
I have a button named btnPlay and an flv video named valerie.flv I would like it when the button is pressed, the flv video plays in the same flash file through the standard flv player.
I tried everything I could and I just have no idea. I would really appreciate the 开发者_运维问答help.
AS3 solution:
This all takes place on one frame in the timeline.
Components Panel > Video > FLV Playback <-- drag this component on to the stage
In Component Inspector panel, with flv playback instance selected, set:
- source: valerie.flv (this is a relative html path that will only work if flv in same folder as your html and swfs)
- autoplay: false
Then, with flv playback instance selected, in Properties panel, set:
- myVideo as the instance name
Components Panel > User Interface > Button <-- drag on to stage
With button instance selected, in Properties panel, set:
- myButton as the instance name
In Component Inspector panel, with button instance selected, set:
- Label: Play Video
With the frame selected that both these components are on, open Actionscript window and enter this:
import fl.controls.Button; import fl.video.FLVPlayback;
var playBtn:Button = myButton; var flvVideo:FLVPlayback = myVideo;
playBtn.addEventListener(MouseEvent.CLICK, buttonClick);
function buttonClick(e:MouseEvent) { var button:Button = Button(e.target); button.enabled = false; button.label = "Playing..."; flvVideo.play(); }
Upload your valerie.flv file to the same folder where your html and swf will go.
Publish the Flash movie and copy the html and 2 swfs to that folder.
精彩评论