Copy link to clipboard
Copied
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");
}
use:
// to stop your video
ns.pause();
// to unpause your video
ns.resume();
Copy link to clipboard
Copied
use:
// to stop your video
ns.pause();
// to unpause your video
ns.resume();
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
sure.
use addChild for your buttons AFTER your addChild(myVideo)
p.s. please mark helpful/correct responses
Copy link to clipboard
Copied
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?"
Copy link to clipboard
Copied
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"));
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now