FORUMS: list search recent posts

Basic AS2 scrubbing within flv file

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sean Jahnig
Basic AS2 scrubbing within flv file
on Nov 18, 2015 at 3:12:09 pm

Hi,

I am preparing a basic presentation in Flash AS2. I have done this many times in the past and it works well. I want to take it a step further now.

What i would like to do is load up an flv video and play it until lets say, 50 frames in (ie. 2 seconds in @ 25fps) then pause. Then upon the click of a button, the video plays another, say 100 frames then pauses. And so on and so on...

I already have working code that loads up an flv via myNetStream.play and a button that progressed the timeline. I just need to somehow know how to A. control the flv file via stop(); type code and B. program the button to control the timeline of the video

Any ideas would be appreciated :-)

Thanks


Return to posts index

Sam Mattern
Re: Basic AS2 scrubbing within flv file
on Nov 19, 2015 at 7:03:54 pm

You need to check the "time" property of the NetStream object using an interval. If you wanted to check it 10 times a second, and you wanted it to pause at 10 seconds and 20 seconds, you would do:
//setInterval takes name of function to call, and how many milliseconds between calls
//replace nsVideo with the name of your netstream
setInterval(checkTime,100);
function checkTime():Void{
//Math.floor rounds the time in seconds down to the nearest whole number
if(Math.floor(nsVideo.time) == 10){
nsVideo.pause;
showButton1();
}
if(Math.floor(nsVideo.time) == 20){
nsVideo.pause;
showButton2();
}
}


Then you could have your button execute the same nsVideo.pause which will toggle the pause off. Or you can specify nsVideo.pause(true) and nsVideo.pause(false).

-Sam


Return to posts index

Sean Jahnig
Re: Basic AS2 scrubbing within flv file
on Nov 21, 2015 at 6:17:39 pm

Hey Sam,

Thanks for much for the reply - really appreciate it!

This is the code i've used and it doesn't seem to work - can you see what i'm doing wrong? When the swf plays the video loads and runs and pauses for a moment but gets going again. ie. Doesn't stay paused

What i'd ideally like to happen is have the myNetStream play until second number 5, then pause until i click a button. Then it should play until second number 10 and pause. And so on... Incase you're wondering what i'm trying to do, i have created a fancy slideshow of say 10 pictures in after effects but i'm using a basic flash program to display it slide by slide. It needs to pause on each photo so that the presenter can talk for an uncertain amount of time before proceeding to the next picture.

var nc:NetConnection = new NetConnection();
nc.connect(null);
myNetStream = new NetStream(nc);
videoPlayer1.attachVideo(myNetStream);
myNetStream.play("_assets/slideshow1.flv");
//setInterval takes name of function to call, and how many milliseconds between calls
//replace nsVideo with the name of your netstream
setInterval(checkTime,1000);
function checkTime():Void{
//Math.floor rounds the time in seconds down to the nearest whole number
if(Math.floor(myNetStream.time) == 2){
myNetStream.pause("_assets/slideshow1.flv");
showButton1();
}
}


FYI, the button is on a different layer and has the following code which works for a regular netstream video that i'm playing without any timer like above.
on (release) {
myNetStream.pause("_assets/slideshow1.flv")
}


Return to posts index


Sean Jahnig
Re: Basic AS2 scrubbing within flv file
on Nov 22, 2015 at 8:04:51 am
Last Edited By Sean Jahnig on Nov 22, 2015 at 8:07:47 am

Hi Sam,

Sorry to keep bugging you with this but i'm really hoping to get it working.

Take a look at this video you'll see that the code is not stopping the video at 2 seconds (ie. when the cinnabon picture shows and the button appears). But the button does work if pressed manually as i show towards the end of the video.

Can you see where i'm going wrong from the code below?

var nc:NetConnection = new NetConnection();
nc.connect(null);
myNetStream = new NetStream(nc);
videoPlayer1.attachVideo(myNetStream);
myNetStream.play("_assets/slideshow1.flv");
//setInterval takes name of function to call, and how many milliseconds between calls
//replace nsVideo with the name of your netstream
setInterval(checkTime,100);
function checkTime():Void{
//Math.floor rounds the time in seconds down to the nearest whole number
if(Math.floor(myNetStream.time) == 2){
myNetStream.pause("_assets/slideshow1.flv");
btn_play._alpha = 50;
}
}


Return to posts index

Sean Jahnig
Re: Basic AS2 scrubbing within flv file
on Nov 25, 2015 at 6:53:51 am

Hey Sam,

Any chance you could take a quick look for me? Really appreciate your help!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]