Quantcast
Channel: Adobe Community: Message List - Foro en español
Viewing all articles
Browse latest Browse all 26997

Loadmovie en actionscript 3

$
0
0

Hola a tod@s!

 

Estoy intentando crear un boton para cargar un archivo swf , desde un AS3. He intentado varias cosas pero no he podido.

 

Ver Video: http://screencast.com/t/09PpB8cCm

 

AS3: http://www.mediafire.com/?15f4mbeq9ra4jtv

 

package  {

   

    import flash.display.MovieClip;

    import flash.net.URLLoader;

    import flash.net.URLRequest;

    import flash.events.Event;

    import flash.events.ProgressEvent;

    import flash.events.MouseEvent;

   

    import Jorge.Utiles.*;

    import gs.TweenLite;

    import gs.easing.*;

    import Jorge.JuegoPuzzle.Fase;

    import fl.motion.MotionEvent;

    import flash.display.Loader;

   

   

    public class Puzzle extends MovieClip {

        private var loader:URLLoader;

        private var urlDatos:String = "xml/puzzle.xml";

        private var datos:XML;

        private var fases:XMLList;

        private var indice:uint = 0;

        private var textoHelp:MovieClip;

       

       

        public var fase:Fase = null;

       

        public function Puzzle() {

            onInicio();

        }

       

        private function onInicio():void{

            stop();

           

            Globales.__root = this;

           

            loader = new URLLoader();

            loader.addEventListener(Event.COMPLETE, onDatosCargados);

            loader.addEventListener(ProgressEvent.PROGRESS, onProgress);

            loader.load(new URLRequest(urlDatos));

           

        }

       

        private function onProgress(evento:ProgressEvent):void{

            trace(evento.bytesLoaded + " de " + evento.bytesTotal);

        }

       

        private function onDatosCargados(evento:Event):void{

            datos = new XML(loader.data);

            fases = datos..fase;

            Globales.literales = datos..literal;

           

            gotoAndStop("intro");

        }

       

       

       

        /**********************  programación de la intro  ****************/

        public function cargaIntro():void{

           

            onDibujaIntro();

        }

        private function onDibujaIntro():void{

            enunciado.htmlText = Globales.literales.(id = "texto_enunciado")[0].toString();

            onListenersIntro();

        }

       

        private function onListenersIntro():void{

            b_play.funcion = lanzaPlay;

        }

       

        private function lanzaPlay(evento:MouseEvent):void{

            gotoAndStop("play");

        }

        /******************************************************************/

       

       

        /**********************  programación del juego  ****************/

        public function cargaPlay():void{

            indice = 0;

           

            onDibujaPlay();

        }

        private function onDibujaPlay():void{

            lanzaSiguiente(new MouseEvent("forzado"));

           

            onListenersPlay();

        }

       

        private function onListenersPlay():void{

            b_siguiente.funcion = lanzaSiguiente;

            b_help.funcion = _creaHelp;

            b_salir.funcion = salir;

           

        }

       

        private function lanzaSiguiente(evento:MouseEvent):void{

            if(fase != null){

                removeChild(fase);

            }

               

            if(indice < fases.length()){

                b_siguiente.visible = false;

                creaPuzzle();

                indice ++;

            }else{

                fase = null;

                lanzaGameOver();

            }

        }

       

        private function creaPuzzle():void{

            fase = new Fase(fases[indice]);

            addChild(fase);

        }

       

        private function lanzaGameOver():void{

            gotoAndStop("gameOver");

        }

        /******************************************************************/

       

       

        /**********************  programación del gameOver  ****************/

        public function cargaGameOver():void{

            onDibujaGameOver();

        }

        private function onDibujaGameOver():void{

            onListenersGameOver();

        }

       

        private function onListenersGameOver():void{

            b_volver.funcion = lanzaPlay;

        }

        /******************************************************************/

       

       

        /**********************  programación de la pantalla de error  ****************/

        public function cargaError():void{

            onDibujaError();

        }

        private function onDibujaError():void{

            onListenersError();

        }

       

        private function onListenersError():void{

           

        }

        /******************************************************************/

       

       

        /**********************  programación de la ayuda  ****************/

        private function _creaHelp(evento:MouseEvent):void{

            textoHelp = new TextoHelp();

            textoHelp.addEventListener(MouseEvent.CLICK, _borraHelp);

            textoHelp.texto.htmlText = Globales.literales.(id = "texto_descripcion")[0].toString();

            addChild(textoHelp);

        }

       

        private function _borraHelp(evento:MouseEvent):void{

            textoHelp.removeEventListener(MouseEvent.CLICK, _borraHelp);

            removeChild(textoHelp);

        }

       

        /******************************************************************/

       

        /**********************  programación de salir  ****************/

       

        private function salir(evento:MouseEvent):void{

            b_salir.addEventListener(MouseEvent.CLICK, _abreSwf)

        }

       

        private function _abreSwf(evento:MouseEvent):void{

            //loader.load(new URLRequest ("sonidos.swf"));

           

        }

        /******************************************************************/

       

    }

   

}


Viewing all articles
Browse latest Browse all 26997

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>