Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need a stop and replay button for video web banner

Community Beginner ,
Jun 23, 2014 Jun 23, 2014

I'm creating my first web banners using full motion video (flv). Needs to be under 40kb per the site's requirements.

I was finally able to get my file size down by avoiding the FLVplayer and using ActionScript (not at all my area of expertise).

I've managed to get the basic video working and playing but I need to add a stop button and a replay button (or return to the initial static image with the play button) at the end of the video.

Here's the code I've managed to piece together thanks to Google.

inv_btn.addEventListener(MouseEvent.CLICK,onReleaseMyButton);

function onReleaseMyButton(event:MouseEvent=null):void {

var myVideo:Video = new Video(300, 170); // note size for video

addChild(myVideo);

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream = new NetStream(nc);

ns.client = new Object();

myVideo.attachNetStream(ns);

ns.play("http://www.dcccd.edu/images/DCCCDlogos/flash/welding.flv");

}

TOPICS
ActionScript
663
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 24, 2014 Jun 24, 2014

use:

// to stop your video

ns.pause();

// to unpause your video

ns.resume();

Translate
Community Expert ,
Jun 24, 2014 Jun 24, 2014

use:

// to stop your video

ns.pause();

// to unpause your video

ns.resume();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 24, 2014 Jun 24, 2014

Thanks. That gets me started in the right direction.

Now the question is how do I get the buttons to appear above the video? Or is that even an option?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2014 Jun 24, 2014

sure.

use addChild for your buttons AFTER your addChild(myVideo)

p.s. please mark helpful/correct responses

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 24, 2014 Jun 24, 2014

I'll have to do some more research to figure out how that works.

As for now I squeezed the buttons into my footer and everything appears to be working right.

play_btn.addEventListener(MouseEvent.CLICK,onReleaseMyButton);

function onReleaseMyButton(event:MouseEvent=null):void {

var myVideo:Video = new Video(300, 170); // note size for video

addChild(myVideo);

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream = new NetStream(nc);

ns.client = new Object();

myVideo.attachNetStream(ns);

ns.play("http://www.dcccd.edu/images/DCCCDlogos/flash/welding.flv");

stop_btn.addEventListener(MouseEvent.CLICK,onReleaseMyStopButton);

function onReleaseMyStopButton(event:MouseEvent=null):void {

  ns.pause();

}

}

learn_btn.addEventListener(MouseEvent.CLICK,DCCCDweb);

function DCCCDweb(event:MouseEvent):void {

  navigateToURL(new URLRequest ("http://www.dcccd.edu/cd/dcc/constr/weld/Pages/default.aspx?source=observer"));

}

I'm assuming since it's working as expected I've got the ActionScript as should be. Is there anything else I should be including as a best practice or "must have?"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2014 Jun 24, 2014

here's how to fix those button depths and some code issues:

var myVideo:Video = new Video(300, 170); // note size for video

addChild(myVideo);

play_btn.addEventListener(MouseEvent.CLICK,onReleaseMyButton);

addChild(play_btn);

function onReleaseMyButton(event:MouseEvent=null):void {

var nc:NetConnection = new NetConnection();

nc.connect(null);

var ns:NetStream = new NetStream(nc);

ns.client = new Object();

myVideo.attachNetStream(ns);

ns.play("http://www.dcccd.edu/images/DCCCDlogos/flash/welding.flv");

}



stop_btn.addEventListener(MouseEvent.CLICK,onReleaseMyStopButton);

addChild(stop_btn);

function onReleaseMyStopButton(event:MouseEvent=null):void {

  ns.pause();

}

learn_btn.addEventListener(MouseEvent.CLICK,DCCCDweb);

addChild(learn_btn);

function DCCCDweb(event:MouseEvent):void {

  navigateToURL(new URLRequest ("http://www.dcccd.edu/cd/dcc/constr/weld/Pages/default.aspx?source=observer"));

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 24, 2014 Jun 24, 2014

Thanks! That gives me a better idea on what to do.

I did get an error though with the closing bracket after

ns.play("http://www.dcccd.edu/images/DCCCDlogos/flash/welding.flv");

I moved it to the last line of the script and it seemed to fix it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2014 Jun 24, 2014
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines