[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Flash AS3 Pause currently playing video with pause button

Posted on 2012-08-29
9
Medium Priority
?
710 Views
Last Modified: 2012-09-01
Flash CS5, AS3

I have 3 .f4v videos loaded into my project using FLVPlayback.

I have them in a single layer on the timeline, each taking 20 frames, one after another (total project = 60 frames).

I have a pause button on the timeline that goes the entire 60 frames.

Each video is paused until the currently playing video finishes, then moves to the frame with the next video sits, at which point that video starts playing.

I want that single pause button to stop whichever video is currently playing (like it "detects" what video is playing and pauses it).

Thanks.
0
Comment
Question by:tlengnick
  • 5
  • 4
9 Comments
 
LVL 11

Expert Comment

by:mcnute
ID: 38350136
stop your video component, not your videos directly. So you would have a video component on your timeline with a dstinct name:

yournameofVideocomponent.pause();

Open in new window


Add this to a button you've created on a layer which goes all over your 60 frames and add an EventListener to it:

yourbtn_btn.addEventListener(MouseEvent.CLICK, yourfunction);

function yourfunction(event:MouseEvent): void 
{
yournameofVideocomponent.pause();
}

Open in new window


Place this code on a layer above all other layers and it will be active for all three videos. If your videos are timeline videos then pause your timeline.

just do this: this.stop();
0
 

Author Comment

by:tlengnick
ID: 38356066
when I am home I will upload my project so you can see how I've done this. Maybe I'm not efficiently setting up these videos.

For each video I import, it puts a different FLVPlayback on the stage, so I just move them off the stage (to the side) and set them to invisible in AS3. so, each one has a unique name...is there a way to import 3 videos but have only 1 name for FLVPlayback?
0
 
LVL 11

Accepted Solution

by:
mcnute earned 2000 total points
ID: 38356950
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:tlengnick
ID: 38357261
mcnute, that link had the answer!

I'm including the below for anyone else wanting to do this.

By putting 1 FLVPlayback only on the stage, you can set through AS3 to play any video you want.

In frame 1 of the AS3 layer, put this (you must have the following on the stage:
1) FLVPlayback component
2) A button with instance name of "switch_btn_i"
3) A button with the instance name of "pause_i"

=====================================================
//This line pulls in all the functions available in the video class
import fl.video.*;

// Set Variables
var display = display;
var flvSource = "introduction.f4v";

// Add listeners and load the video
display.source = flvSource;

//When you click this button, switch the video source to something else
switch_btn_i.addEventListener(MouseEvent.CLICK, fx_NextVid);
function fx_NextVid(e:MouseEvent):void
{
      display.stop();
      display.source = "texture.f4v";
      display.play();
}

// Add toggle code
pause_i.addEventListener(MouseEvent.CLICK, toggleHandler);
function toggleHandler(event:MouseEvent):void
{
   if( display.playing ){
      display.pause();
   }else{
      display.play();
   }
}

stop();
0
 

Author Closing Comment

by:tlengnick
ID: 38357262
That is a very helpful link for controlling video in Flash!
0
 
LVL 11

Expert Comment

by:mcnute
ID: 38357266
Yeah i know it had the answer, that's why I posted it. Glad it helped you. If you would accept it as answer I would be very thankful.
0
 

Author Comment

by:tlengnick
ID: 38357568
I did. It says "Accepted Answer" above it and "500 Excellent" to the right.

You don't see that?
0
 

Author Comment

by:tlengnick
ID: 38357569
"Accepted Solution", rather.
0
 
LVL 11

Expert Comment

by:mcnute
ID: 38357633
Thank you, i missed it. I wish you the best with your project!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question