Autoplay FLV / FLVPlayback

  • Impel GD
  • Professor
  • Professor
  • No Avatar
  • Joined: Oct 26, 2004
  • Posts: 834
  • Loc: Cologne, Germany
  • Status: Offline

Post May 5th, 2009, 4:10 am

Flash version: CS4
AS version: 2 (slide presentation)
Skill level in Flash: please treat me like a noob

On the second slide of my presentation, I have an imported FLV video. If I apply a skin to it, the play controls work fine. However, I need to have the video play automatically once slide 2 is navigated to when playing the presentation.

I can't set the instance of FLVPlayback to autoPlay because that means that the video plays before slide 2 is navigated to.

I've tried putting the following ActionScript on frame 1 of slide 2:

Code: [ Select ]
instancename.play();


But it doesn't work.

Many thanks for any help you can give.
Web and print design
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post May 5th, 2009, 4:10 am

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post May 5th, 2009, 5:51 am

Put your FLVPlayback component into a separate movie(swf). To function properly it needs to be on the first frame of the timeline and this accomplishes that.

Then in frame two of your main movie load the swf that contains the FLV. If you need to move beyond frame two after the FLV plays you'll need to set up a listener for the end of the FLV. Easiest way to do that is embed cuepoints in the FLV (you can set up action script cuepoints as an alternative but it's a lot easier to add the cuepoints when you encode the FLV).

I have several posts in this Flash forum that address this if you want to check into those. Just search my handle in this forum for FLVPlayback
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Impel GD
  • Professor
  • Professor
  • No Avatar
  • Joined: Oct 26, 2004
  • Posts: 834
  • Loc: Cologne, Germany
  • Status: Offline

Post May 5th, 2009, 9:53 am

I've now switched to using frames in the timeline alone, and it's turning out to be much easier than using slides.

I've made the temporary "cover" screen frame 1, and applied the following ActionScript to it (found it by Googling):

Code: [ Select ]
stop();
stage.addEventListener (KeyboardEvent.KEY_DOWN, detectText);
function detectText (myevent:KeyboardEvent):void {
    this.nextFrame();
}
  1. stop();
  2. stage.addEventListener (KeyboardEvent.KEY_DOWN, detectText);
  3. function detectText (myevent:KeyboardEvent):void {
  4.     this.nextFrame();
  5. }


My imported FLV is on frame 2, and I can leave it on autoplay in the component inspector.

Many thanks to ATNO/TW who tried to help me with the slides.
Web and print design
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post May 5th, 2009, 10:16 am

I actually figured this out for working it with the slides. Just had to understand the screens class a little bit which I had never looked at before. You won't believe how easy. (the mx.screens.Slide class is actually automatically included in the properties of each slide).

On slide1 open your actions panel and add this code
Code: [ Select ]
//prevent FLV from playing when your presentation starts
on (focusIn) {
    import mx.video.*;
    obama.autoPlay = false;
}
  1. //prevent FLV from playing when your presentation starts
  2. on (focusIn) {
  3.     import mx.video.*;
  4.     obama.autoPlay = false;
  5. }


On slide2 open your actions panel and add this code.

Code: [ Select ]
//start the video when this slide gains focus
on (focusIn) {
    import mx.video.*;
    obama.play();
}
//stop the video when this slide loses focus
on (focusOut) {
    import mx.video.*;
    obama.stop();
}
  1. //start the video when this slide gains focus
  2. on (focusIn) {
  3.     import mx.video.*;
  4.     obama.play();
  5. }
  6. //stop the video when this slide loses focus
  7. on (focusOut) {
  8.     import mx.video.*;
  9.     obama.stop();
  10. }


Set up like that, when you use your right or left arrows to navigate between slides, it acts as a toggle switch to turn the video on and off instantly.


Sorry I couldn't figure it out faster for you. Been a busy day. But I learned something new, so it wasn't wasted time at all! Cheers!

//update - actually if you have the autoplay parameter in your FLVPlayback component set to false you don't even need the code in slide1 at all.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Impel GD
  • Professor
  • Professor
  • No Avatar
  • Joined: Oct 26, 2004
  • Posts: 834
  • Loc: Cologne, Germany
  • Status: Offline

Post May 5th, 2009, 10:22 am

Ah, that's good to know, and may well come in handy for more of these things in the future. Thanks very much.
Web and print design
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post May 5th, 2009, 10:28 am

Yeah. That's something I can actually use very effectively to make a whole presentation with FLV's. I added a small update to my prior post.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Impel GD
  • Professor
  • Professor
  • No Avatar
  • Joined: Oct 26, 2004
  • Posts: 834
  • Loc: Cologne, Germany
  • Status: Offline

Post May 5th, 2009, 10:31 am

I'm just trying it now, and the compiling errors are telling me that:

Mouse events are permitted only for button instances

It doesn't like the on (focusIn)

Any ideas? Don't worry, though - I've got it working in the timeline now.

Edit: my mistake. I'd applied the AS to the first frame and not the slide itself. :)
Web and print design
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23407
  • Loc: Woodbridge VA
  • Status: Offline

Post May 5th, 2009, 10:41 am

If you are trying it on your new version it probably won't work. It does work in the original slides presentation version you sent me. It needs the mx.screens.slides class for the focusIn and focusOut to work.

Here's the working FLA. just drop it in the same folder as your FLV
http://www.alaron-nuclear.com/ozzu/Amer ... ro_CS3.fla
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Impel GD
  • Professor
  • Professor
  • No Avatar
  • Joined: Oct 26, 2004
  • Posts: 834
  • Loc: Cologne, Germany
  • Status: Offline

Post May 5th, 2009, 10:43 am

Got it working now - I edited my previous post to say that I was applying the AS to the wrong place.

Thanks again.
Web and print design

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 61 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.