PDA

View Full Version : [AS3] Buttons located under video layer object


Jynxis
05-28-2010, 12:45 AM
Hello, so I'm quite new to flash and for a website I'm designing i want to add in a custom video player. I've always wanted to learn flash and of course Actionscript.

I recently found a vidcast on a simple video player in AS3 and am having a few issues. I remembered this site and thought."Hey maybe these guys could help me cure my noobitity.


I have a flash canvas of 640x360 for the video component ; two buttons located on the bottom right and left corners (play|pause, fullscreen).
As the page loads you can see the two buttons, but as soon as the video plays, it is on top of the buttons. The buttons are still clickable, but do not show.

How do i fix that? I thought about putting the buttons below the video, but i want it to only show on hover. Also, if its not even working with two buttons now; what will happen when i put a bit "PLAY ME" button in the middle of the canvas?

Here is my code; if you need the fla, let me know.


var video:Video = new Video(640,360);
addChild(video);

var nc:NetConnection = new NetConnection();
nc.connect(null);


var ns:NetStream = new NetStream(nc);

ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
function onStatusEvent(stat:Object):void
{
trace(stat.info.code);
}

var meta:Object = new Object();
meta.onMetaData = function(meta:Object)
{
trace(meta.duration);
}


ns.client = meta;

video.attachNetStream(ns);
//Play video
//ns.setBufferTime(15);
ns.play("/media/videos/" + root.loaderInfo.parameters.videostream);

btn_play.addEventListener(MouseEvent.CLICK, handleBtn);
function handleBtn(evt:MouseEvent):void {
ns.pause();

}

sparX
05-28-2010, 02:30 AM
Objects u place on the stage at authoring time in flash get added to the display list first,before your dynamically added objects & hence end up on the bottom of the display list.

What u can do is slot your video in under the objects by selecting a position to place it on the display list. Instaed of addChild(video); , try

addChildAt(video,0);

will put it at very bottom of display list of container your adding it to(mainTimeline in your case),if u dont want it all the way down there then just adjust the parameter '0' to the position u like.

Jynxis
05-28-2010, 03:26 AM
It worked, thanks!!