Comunidad de diseño web y desarrollo en internet online

remover video al finalizar as3 removeChild??

Citar            
MensajeEscrito el 08 Feb 2017 12:49 pm
Hola soy nuevo en as3 así que necesitaría de su sabiduría :D
estoy llamando a un video externo con el NetStream y agregándolo mediante addChild en el swf principal, este se reproduce bien, pero quiero que al terminar de mostrar ese video, poder removerlo para que muestre la información que esta detrás de este. y hasta ahora no enontrado un foro claro que me ayude con esto. El video queda en el frame final y ya.

mi código de llamado del video en as3 es:

Código ActionScript :

package com.introvideo{
    import flash.display.Sprite;
    import flash.events.*;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;

    public class loadvideo extends Sprite {
        private var videoURL:String = "https://www.youtube.com/watch?v=ht9KUu6eSm8";
        private var connection:NetConnection;
        private var stream:NetStream;

        public function loadvideo() {
            connection = new NetConnection();
            connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            connection.connect(null);
         
        }

        private function netStatusHandler(event:NetStatusEvent):void {
            switch (event.info.code) {
                case "NetConnection.Connect.Success":
                    connectStream();
                    break;
                case "NetStream.Play.StreamNotFound":
                    trace("Unable to locate video: " + videoURL);
                    break;
            }
        }

        private function connectStream():void {
            stream = new NetStream(connection);
            stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
         
         
         
            var video:Video = new Video();
            video.attachNetStream(stream);
            stream.play(videoURL);
         video.width = 1472;
         video.height = 512;
         
            addChild(video);
         
        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }
        
        private function asyncErrorHandler(event:AsyncErrorEvent):void {
         
         
            // ignore AsyncErrorEvent events.
        }
    }
 }


y mi código de llamado al swf principal es:

Código ActionScript :

package {
   import com.plastikaweb.view.TempWeatherView;
   import flash.display.Sprite;
   import com.plastikaweb.controller.WeatherController;
   import com.plastikaweb.model.WeatherModel;
   import com.plastikaweb.view.DataWeatherView;
   import com.plastikaweb.view.IconWeatherView;
   import com.plastikaweb.view.TimeWeatherView;
   import com.plastikaweb.introvideo;
   
   import flash.utils.Timer;
   import flash.events.TimerEvent;
   import com.plastikaweb.introvideo.loadvideo;


   public class Weather extends Sprite{
      
      public function Weather() {

         var model:WeatherModel = new WeatherModel();

         var controller:WeatherController = new WeatherController(model);

         var tempview:TempWeatherView = new TempWeatherView(model);

         var dataview:DataWeatherView = new DataWeatherView(model);

         var iconview:IconWeatherView = new IconWeatherView(model);

         var timeview:TimeWeatherView = new TimeWeatherView(model);

         var introvideo:loadvideo = new loadvideo;

         
         
         addChild(iconview);
         addChild(tempview);
         addChild(dataview);
         addChild(timeview);
         addChild(introvideo);
         
   
         controller.update(null);
      
         var timer:Timer = new Timer(1000);
         timer.addEventListener(TimerEvent.TIMER, controller.update);
         timer.start();
      }
      
   }
   
}

Por jaico

1 de clabLevel



 

safari
Citar            
MensajeEscrito el 09 Feb 2017 05:00 pm

Código ActionScript :


package com.plastikaweb.introvideo {
   import flash.display.Sprite;
    import flash.events.*;
    import flash.media.Video;
    import flash.net.NetConnection;
    import flash.net.NetStream;
   
   public class loadvideo extends Sprite{

      public function loadvideo() {
         var nc:NetConnection = new NetConnection();
         nc.connect(null);

         var video:Video = new Video();
         video.width = 1472;
         video.height = 512;
         
         addChild(video);

         var ns:NetStream = new NetStream(nc);
         video.attachNetStream(ns);
         ns.play("http://signatures.vafepublicidad.com/tiempo/INTRO2.mp4");


         ns.addEventListener(NetStatusEvent.NET_STATUS, estadoVideo);
         //ns.client = {onMetaData:ns_onMetaData, NetStatusEvent:estadoVideo};

         // Evitar error
         var cliente:Object = new Object()
         ns.client = cliente
          function estadoVideo(event:NetStatusEvent):void {
         if(event.info.code == "NetStream.Play.Stop"){
         removeChild(video);}
         }

         //le digo que cuando el video haya terminado lo quite del escenario
      
}
      }

   }

Por jaico

1 de clabLevel



 

safari
Citar            
MensajeEscrito el 12 Feb 2017 02:54 pm
Fijate que en el primer código que posteaste tenes un handler para los NetStatusEvent llamado netStatusHandler
Agregá allí uno para NetStream.Play.Stop (o algo parecido, cinsultá la documentación) y luego hace simplemente un removeChild(video) Para que funcione declará video como propiedad de la clase

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.