Please I really need help with this video problem.
TavaresEd Jan 11, 2014 9:22 AMHi!
Please I need help with this app I am trying to make for an Android cellphone and I've been struggling with this for a couple of months.
I have a main flash file (video player.fla) that will load external swf files. This is the main screen.When I click the Sets Anteriores button I want to open another swf file called sets.swf.The app is freezing when I click Sets Anteriores button
Here is the code for this fla file.
import flash.events.MouseEvent;
preloaderBar.visible = false;
var loader:Loader = new Loader();
btHome.enabled = false;
var filme : String = "";
carregaFilme("home.swf");
function carregaFilme(filme : String ) :void
{
var reqMovie:URLRequest = new URLRequest(filme);
loader.load(reqMovie);
loader.contentLoaderInfo.addEventListener(Event.OPEN,comeco);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,progresso);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completo);
palco.addChild(loader);
}
function comeco(event:Event):void
{
preloaderBar.visible = true;
preloaderBar.barra.scaleX = 0;
}
function progresso(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
preloaderBar.percent.text = Math.ceil(perc*100).toString();
preloaderBar.barra.scaleX = perc;
}
function completo(e:Event):void
{
preloaderBar.percent.text = '';
preloaderBar.visible = false;
}
btHome.addEventListener(MouseEvent.MOUSE_DOWN,onHomeDown);
btHome.addEventListener(MouseEvent.MOUSE_UP,onHomeUp);
btSets.addEventListener(MouseEvent.MOUSE_DOWN,onSetsDown);
btSets.addEventListener(MouseEvent.MOUSE_UP,onSetsUp);
btVivo.addEventListener(MouseEvent.MOUSE_DOWN,onVivoDown);
btVivo.addEventListener(MouseEvent.MOUSE_UP,onVivoUp);
btHome.addEventListener(MouseEvent.CLICK,onHomeClick);
btSets.addEventListener(MouseEvent.CLICK,onSetsClick);
function onSetsClick(Event : MouseEvent) : void
{
if (filme != "sets.swf")
{
filme = "sets.swf";
carregaFilme("sets.swf");
}
}
function onHomeClick(Event : MouseEvent) : void
{
if (filme != "home.swf")
{
filme = "home.swf";
carregaFilme("home.swf");
}
}
function onHomeDown(Event : MouseEvent) : void
{
btHome.y += 1;
}
function onHomeUp(Event : MouseEvent) : void
{
btHome.y -= 1;
}
function onSetsDown(Event : MouseEvent) : void
{
btSets.y += 1;
}
function onSetsUp(Event : MouseEvent) : void
{
btSets.y -= 1;
}
function onVivoDown(Event : MouseEvent) : void
{
btVivo.y += 1;
}
function onVivoUp(Event : MouseEvent) : void
{
btVivo.y -= 1;
}
Now this is the sets.fla file:
Here is the code for sets.fla
import flash.utils.Timer;
import flash.events.TimerEvent;
var video:Video;
var nc:NetConnection;
var ns:NetStream;
var t : Timer = new Timer(1000,0);
var meta:Object = new Object();
this.addEventListener(Event.ADDED_TO_STAGE,init);
function init(e:Event):void{
video= new Video(320, 240);
addChild(video);
video.x = 80;
video.y = 100;
nc= new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
ns.bufferTime = 1;
ns.client = meta;
video.attachNetStream(ns);
ns.play("http://www.djchambinho.com/videos/segundaquinta.flv");
ns.pause();
t.addEventListener(TimerEvent.TIMER,timeHandler);
t.start();
}
function onStatusEvent(stat:Object):void
{
trace(stat.info.code);
}
meta.onMetaData = function(meta:Object)
{
trace(meta.duration);
}
function timeHandler(event : TimerEvent) : void
{
if (ns.bytesLoaded>0&&ns.bytesLoaded == ns.bytesTotal )
{
ns.resume();
t.removeEventListener(TimerEvent.TIMER,timeHandler);
t.stop();
}
}
The problem is when I test it on my computer it works but when I upload it to my phone it freezes when I click Sets Anteriores button.
Please help me with this problem I dont know what else to do.
thank you





