Comunidad de diseño web y desarrollo en internet online

Ayuda urgente AS3

Citar            
MensajeEscrito el 11 Jul 2012 01:30 pm
Buenos días,

tengo los siguientes archivos en AS3 (2 archivos: main.as,customvideo.as) y quiero modificarlo para que los videos no se reproduzcan todos simultaneamente,sino cuando pasas el raton por encima de los videos o haces click en ellos, ambas 2 soluciones me sirven. Por favor necesito ayuda urgentisimamente.
package{

//zona de importación
import flash.display.Sprite;
import flash.events.*;
import media.CustomVideo;

//zona decl. clase
[SWF(width="1024", height="720", backgroundColor="#000000", frameRate="30")]
public class Main extends Sprite{


//vars
private var v1:CustomVideo;
private var v2:CustomVideo;
private var v3:CustomVideo;
private var v4:CustomVideo;
private var v5:CustomVideo;
private var v6:CustomVideo;
private var v7:CustomVideo;
private var v8:CustomVideo;


public function Main():void{

v1 = new CustomVideo(320,205,"flv/acustico.flv");
v1.x = 0;
v1.y = 50;
v1.alpha = .9;
//v1.rotation = 180;
addChild(v1);


v2 = new CustomVideo(320,205,"flv/believe.flv");
v2.x = 350;
v2.y = 50;
v2.alpha = .7;
//v2.rotation = 360;
addChild(v2);


v3 = new CustomVideo(320,205,"flv/hey.flv");
v3.x = 700;
v3.y = 50;
v3.alpha = .7;
//v3.rotation = 360;
addChild(v3);

v4 = new CustomVideo(320,205,"flv/calles.flv");
v4.x = 0;
v4.y = 270;
v4.alpha = .9;
//v1.rotation = 180;
addChild(v4);


v5 = new CustomVideo(320,205,"flv/empujenet.flv");
v5.x = 350;
v5.y = 270;
v5.alpha = .7;
//v2.rotation = 360;
addChild(v5);


v6 = new CustomVideo(320,205,"flv/f.flv");
v6.x = 700;
v6.y = 270;
v6.alpha = .7;
//v3.rotation = 360;
addChild(v6);

v7 = new CustomVideo(320,205,"flv/p.flv");
v7.x = 0;
v7.y = 490;
v7.alpha = .7;
//v2.rotation = 360;
addChild(v7);


v8 = new CustomVideo(320,205,"flv/t.flv");
v8.x = 700;
v8.y = 490;
v8.alpha = .7;
//v3.rotation = 360;
addChild(v8);
}//end constructor
}//end class main
}//end package


package media { //import flash.display.Stage;

import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
//import flash.display.Sprite;
import flash.events.*;


public class CustomVideo extends Video {
private var nc:NetConnection;
private var ns:NetStream;
public var file:String;
public var duration:Number;
private var infoCode:String;


public function CustomVideo(w_:int, h_:int, file_:String)
{
//stage.addEventListener(MouseEvent.MOUSE_OVER, mouse_);

file = file_;
this.width = w_;
this.height = h_;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
this.attachNetStream(ns);
ns.client = new Object();
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
ns.play(file);



}//end constructor


private function statusHandler(par:NetStatusEvent){
infoCode = par.info.code
if ( infoCode == 'NetStream.Play.Stop' ) { // seems to always fire when the flv is complete
par.currentTarget.play(file);
}//end if

}//end statusHandler Func

}//end class
}//end package

Por chuculuna

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 11 Jul 2012 01:32 pm
Buenos días,

tengo los siguientes archivos en AS3 (2 archivos: main.as,customvideo.as) y quiero modificarlo para que los videos no se reproduzcan todos simultaneamente,sino cuando pasas el raton por encima de los videos o haces click en ellos, ambas 2 soluciones me sirven. Por favor necesito ayuda urgentisimamente.
//Main.as
package{

//zona de importación
import flash.display.Sprite;
import flash.events.*;
import media.CustomVideo;

//zona decl. clase
[SWF(width="1024", height="720", backgroundColor="#000000", frameRate="30")]
public class Main extends Sprite{


//vars
private var v1:CustomVideo;
private var v2:CustomVideo;
private var v3:CustomVideo;
private var v4:CustomVideo;
private var v5:CustomVideo;
private var v6:CustomVideo;
private var v7:CustomVideo;
private var v8:CustomVideo;


public function Main():void{

v1 = new CustomVideo(320,205,"flv/acustico.flv");
v1.x = 0;
v1.y = 50;
v1.alpha = .9;
//v1.rotation = 180;
addChild(v1);


v2 = new CustomVideo(320,205,"flv/believe.flv");
v2.x = 350;
v2.y = 50;
v2.alpha = .7;
//v2.rotation = 360;
addChild(v2);


v3 = new CustomVideo(320,205,"flv/hey.flv");
v3.x = 700;
v3.y = 50;
v3.alpha = .7;
//v3.rotation = 360;
addChild(v3);

v4 = new CustomVideo(320,205,"flv/calles.flv");
v4.x = 0;
v4.y = 270;
v4.alpha = .9;
//v1.rotation = 180;
addChild(v4);


v5 = new CustomVideo(320,205,"flv/empujenet.flv");
v5.x = 350;
v5.y = 270;
v5.alpha = .7;
//v2.rotation = 360;
addChild(v5);


v6 = new CustomVideo(320,205,"flv/f.flv");
v6.x = 700;
v6.y = 270;
v6.alpha = .7;
//v3.rotation = 360;
addChild(v6);

v7 = new CustomVideo(320,205,"flv/p.flv");
v7.x = 0;
v7.y = 490;
v7.alpha = .7;
//v2.rotation = 360;
addChild(v7);


v8 = new CustomVideo(320,205,"flv/t.flv");
v8.x = 700;
v8.y = 490;
v8.alpha = .7;
//v3.rotation = 360;
addChild(v8);
}//end constructor
}//end class main
}//end package

//customvideo.as
package media { //import flash.display.Stage;

import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
//import flash.display.Sprite;
import flash.events.*;


public class CustomVideo extends Video {
private var nc:NetConnection;
private var ns:NetStream;
public var file:String;
public var duration:Number;
private var infoCode:String;


public function CustomVideo(w_:int, h_:int, file_:String)
{
//stage.addEventListener(MouseEvent.MOUSE_OVER, mouse_);

file = file_;
this.width = w_;
this.height = h_;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
this.attachNetStream(ns);
ns.client = new Object();
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
ns.play(file);



}//end constructor


private function statusHandler(par:NetStatusEvent){
infoCode = par.info.code
if ( infoCode == 'NetStream.Play.Stop' ) { // seems to always fire when the flv is complete
par.currentTarget.play(file);
}//end if

}//end statusHandler Func

}//end class
}//end package[/quote]

Por chuculuna

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 11 Jul 2012 02:16 pm
Tienes 8 instancias de videos (v1 a v8), en vez de darle play automáticamente al NetStream como estás haciendo, agrega un método publico start por ejemplo, y lo llamas en el MouseEvent.MOUSE_OVER para arrancar el video. Incluso si quieres que sea toggle (arranque y pare alternativamente) dentro del metodo start que agregas puedes chequear si el NetStream esta reproduciendo o no (para ello simplemente agregas un booleano que pasas de true a false)

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.