function playvideo(path:String, wid:Number=1280, heigt:Number=720):void
{
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = this;
ns.addEventListener(NetStatusEvent.NET_STATUS, statusChanged);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
SoundMixer.stopAll();
var vid:Video = new Video();
ns.play(path);
vid.width = wid;
vid.height = heigt;
vid.attachNetStream(ns);
mc_bg.removeChildAt(0);
mc_bg.addChild(vid);
}
Greetings, here's my "playvideo" function. whenever I try to move variables outside of function to control the video from elsewhere(for example "vid"), specific movieclips and buttons dissapear(are not shown on the stage). Is that some kind of a bug or am I doing something wrong? Thanks!
do this:
var vid:Video = new Video();
function playvideo(path:String, wid:Number=1280, heigt:Number=720):void
{
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = this;
ns.addEventListener(NetStatusEvent.NET_STATUS, statusChanged);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
SoundMixer.stopAll();
ns.play(path);
vid.width = wid;
vid.height = heigt;
vid.attachNetStream(ns);
mc_bg.removeChildAt(0);
mc_bg.addChild(vid);
}
And same for any var, declare outside function