Comunidad de diseño web y desarrollo en internet online

playlist de video 3.0 con xml

Citar            
MensajeEscrito el 26 Jun 2008 04:59 pm
Hola buenas, me llamo víctor y estoy comenzando también en el infernal mundo del 3.0. Necesitaba para mi pagina web (www.davidearth.es por si alguien quiere ver como es el platlist en accion) un playlist con xml de video , y en la pagina de adobe hay una aplicacion que te puedes descargar con facilidad y que tiene el siguiente codigo...

Código :

package {
   import flash.display.MovieClip;
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.events.Event;
   import fl.controls.listClasses.CellRenderer;
   import fl.controls.ScrollBarDirection;


   public class VideoPlaylist extends MovieClip {
      private var xmlLoader:URLLoader;
      
      public function VideoPlaylist():void {
         // Load the playlist file, then initialize the media player.
         xmlLoader = new URLLoader();
         xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
         xmlLoader.load(new URLRequest("playlist.xml"));
         // Format the tileList, specify its cellRenderer class.
         tileList.setSize(100, 240);
         tileList.columnWidth = 180;
         tileList.rowHeight = 60;
         tileList.direction = ScrollBarDirection.VERTICAL;
         tileList.setStyle("cellRenderer", Thumb);
      }
      
      public function initMediaPlayer(event:Event):void {
         var myXML:XML = new XML(xmlLoader.data);
         var item:XML;
         for each(item in myXML.vid) { // populate playlist.
            // Get thumbnail value and assign to cellrenderer.
            var thumb:String;
            if(item.hasOwnProperty("@thumb")>0) thumb = item.@thumb;
            // Send data to tileList.
            tileList.addItem({label:item.attribute("desc").toXMLString(), 
            data:item.attribute("src").toXMLString(),
            source:thumb});;
         }
         // Select the first video.
         tileList.selectedIndex = 0;
         // Listen for item selection.
         tileList.addEventListener(Event.CHANGE, listListener);
         // And automatically load it into myVid.
         myVid.source = tileList.selectedItem.data;
         // Pause video until selected or played.
         myVid.pause();
      }

      
      // Detect when new video is selected, and play it
      function listListener(event:Event):void {
         myVid.play(event.target.selectedItem.data);
      }
      
      
   }
}




Luego sin embargo al intentar poner un boton de vuelta para volver a la otra parte de la web no me funciona guiandome del tutorial Actionscript 3.0 Parte 2: Botones, eventos, getURL y enlaces de esta grandiosa web. Es decir, el tutorial lo hago sin ningún problema, pero cuando incluyo mi codigo dentro del codigo de AS, no funciona y me dan varios errores.

El codigo al que me refiero es



Código :

function abrir (e:Event) : void{
         navigateToURL(new URLRequest("http://www.google.es/ig"));
      }
botoncito.addEventListener(MouseEvent.CLICK,abrir);





Si alguien pudiese ayudarme le daría el mundo y miles de gracias.

Muchas gracias
[/quote]

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 26 Jun 2008 05:11 pm
El código parece estar bien, ¿donde lo insertas y que tipo de errores te devuelve?

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 26 Jun 2008 06:23 pm
El código pues lo inserto así:

Código :

package {
   import flash.display.MovieClip;
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.events.Event;
   import fl.controls.listClasses.CellRenderer;
   import fl.controls.ScrollBarDirection;


   public class VideoPlaylist extends MovieClip {
      private var xmlLoader:URLLoader;
      
      public function VideoPlaylist():void {
         // Load the playlist file, then initialize the media player.
         xmlLoader = new URLLoader();
         xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
         xmlLoader.load(new URLRequest("playlist.xml"));
         // Format the tileList, specify its cellRenderer class.
         tileList.setSize(100, 240);
         tileList.columnWidth = 180;
         tileList.rowHeight = 60;
         tileList.direction = ScrollBarDirection.VERTICAL;
         tileList.setStyle("cellRenderer", Thumb);
      }
      
      function abrir (e:Event) : void{
         navigateToURL(new URLRequest("http://www.google.es/ig"));
      }
      botoncito.addEventListener(MouseEvent.CLICK,abrir);
      
      public function initMediaPlayer(event:Event):void {
         var myXML:XML = new XML(xmlLoader.data);
         var item:XML;
         for each(item in myXML.vid) { // populate playlist.
            // Get thumbnail value and assign to cellrenderer.
            var thumb:String;
            if(item.hasOwnProperty("@thumb")>0) thumb = item.@thumb;
            // Send data to tileList.
            tileList.addItem({label:item.attribute("desc").toXMLString(), 
            data:item.attribute("src").toXMLString(),
            source:thumb});;
         }
         // Select the first video.
         tileList.selectedIndex = 0;
         // Listen for item selection.
         tileList.addEventListener(Event.CHANGE, listListener);
         // And automatically load it into myVid.
         myVid.source = tileList.selectedItem.data;
         // Pause video until selected or played.
         myVid.pause();
      }

      
      // Detect when new video is selected, and play it
      function listListener(event:Event):void {
         myVid.play(event.target.selectedItem.data);
      }
      
      
   }
}


muchas gracias por todo

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 26 Jun 2008 06:28 pm
perdón que no he puesto los errores...

Access of unndefined property botoncito
Access of unndefined property MouseEvent
Access of unndefined property abrir
Call to a possibly undefined method navigateToURL

muchas gracias

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 27 Jun 2008 08:11 am
Access of unndefined property botoncito:
no tienes declarado a botoncito dentro de la clase, debes enviarlo de alguna manera como variable de una función o acceder a el desde la document class.

Access of unndefined property MouseEvent:
en la clase importas dentro de eventos a Events, pero no importas otros eventos

Código :

import flash.events.MouseEvent;


Call to a possibly undefined method navigateToURL:
en la clase no importas navigateToURL

Código :

import flash.net.navigateToURL;



Access of unndefined property abrir:
No estoy seguro de por qué ocurre pero cuando arregles estos otros errores, prueba a ver, de todas maneras estás llamando a la función mediante un MouseEvent y el parámetro evt es un Event, debería ser así

Código :

function abrir (e:MouseEvent) : void{

     navigateToURL(new URLRequest("http://www.google.es/ig"));

}

botoncito.addEventListener(MouseEvent.CLICK,abrir);

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 27 Jun 2008 08:33 am
Muchas gracias, ya he resuelto los problemas de Access of unndefined property MouseEvent y Call to a possibly undefined method navigateToURL, gracias a lo que me has dicho, sin embargo debido a mi escaso conocimiento no comprendo a lo que te refieres con:


Access of unndefined property botoncito:
no tienes declarado a botoncito dentro de la clase, debes enviarlo de alguna manera como variable de una función o acceder a el desde la document class.



el error de abrir me sigue saliendo pero supongo que será porque todavia no he arreglado lo de botoncito.

Muchas gracias por todo.

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 27 Jun 2008 10:33 am
Mira en AS3 a diferencia de AS1 y AS2 no puedes poner

Código :

boton = 3;


Porque botón no se ha definido (Te saldrá el mismo error que te sale en este momento);
De la misma manera no puedes decir:

Código :

botoncito.addEventListener(MouseEvent.CLICK,abrir);


Sin antes haber definido a botoncito, debes decirle a la clase quién es botoncito o escribir en la document class o lo que es lo mismo escribir en la línea de tiempo donde se encuentra botoncito.

Lo correcto es declarar la variable, después que la declares puedes acceder a sus propiedades o añadirle eventos:

Código :

var botoncito:Sprite = new Sprite();
botoncito.buttonMode = true;

botoncito.addEventListener(MouseEvent.CLICK,abrir);

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 27 Jun 2008 04:54 pm
Pues poniendo el codigo tal que así...

Código :

package {
   import flash.display.MovieClip;
   import flash.events.MouseEvent;
   import flash.net.navigateToURL;
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.events.Event;
   import fl.controls.listClasses.CellRenderer;
   import fl.controls.ScrollBarDirection;


   public class VideoPlaylist extends MovieClip {
      private var xmlLoader:URLLoader;

      public function VideoPlaylist():void {
         // Load the playlist file, then initialize the media player.
         xmlLoader=new URLLoader  ;
         xmlLoader.addEventListener(Event.COMPLETE,initMediaPlayer);
         xmlLoader.load(new URLRequest("playlist.xml"));
         // Format the tileList, specify its cellRenderer class.
         tileList.setSize(100,240);
         tileList.columnWidth=180;
         tileList.rowHeight=60;
         tileList.direction=ScrollBarDirection.VERTICAL;
         tileList.setStyle("cellRenderer",Thumb);
      }
      function abrir(e:MouseEvent):void {

         navigateToURL(new URLRequest("http://www.google.es/ig"));

      }
      var botoncito:Sprite = new Sprite();
      botoncito.buttonMode = true;
      botoncito.addEventListener(MouseEvent.CLICK,abrir);

      public function initMediaPlayer(event:Event):void {
         var myXML:XML=new XML(xmlLoader.data);
         var item:XML;
         for each (item in myXML.vid) {// populate playlist.
            // Get thumbnail value and assign to cellrenderer.
            var thumb:String;
            if (item.hasOwnProperty("@thumb") > 0) {
               thumb=item.@thumb;
            }// Send data to tileList.
            tileList.addItem({label:item.attribute("desc").toXMLString(),data:item.attribute("src").toXMLString(),source:thumb});

         }
         // Select the first video.
         tileList.selectedIndex=0;
         // Listen for item selection.
         tileList.addEventListener(Event.CHANGE,listListener);
         // And automatically load it into myVid.
         myVid.source=tileList.selectedItem.data;
         // Pause video until selected or played.
         myVid.pause();
      }
      // Detect when new video is selected, and play it
      function listListener(event:Event):void {
         myVid.play(event.target.selectedItem.data);
      }
   }
}



Me sale un error: A conlfict exists with defintion botoncito in namespace internal.

Cuando dices:
Sin antes haber definido a botoncito, debes decirle a la clase quién es botoncito o escribir en la document class o lo que es lo mismo escribir en la línea de tiempo donde se encuentra botoncito.
No comprendo a lo que te refieres. Lo siento y perdona mi incompetencia.

Espero que puedas ayudarme.

Muchas gracias

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 27 Jun 2008 05:52 pm
Mira lo que te puse fue un ejemplo, no puedes crear a botoncito dinamicamente porque me parece que ya lo tienes creado, lo que te quería decir con ese comentario, es que si tienes a botoncito en la escena, añadas el código en la línea de tiempo, no te compliques con la document class, en el mismo frame donde está botoncito pones:

Código :

botoncito.addEventListener(MouseEvent.CLICK,abrir);

function abrir(e:MouseEvent):void {

         navigateToURL(new URLRequest("http://www.google.es/ig"));

}

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 27 Jun 2008 05:57 pm
Ahh y el error que te está dando es porque tienes la variable botoncito duplicada, yo no la veo otra vez dentro de la clase, así que en otro lado la debes tener declarada y está dando problemas, pero de todas formas intenta primero lo que te dije anteriormente.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 27 Jun 2008 07:36 pm
Finalmente el archivo VideoPlaylist.as ( que donde está todo el código) lo he dejado así...


Código :

package {
   import flash.display.MovieClip;
   import flash.events.MouseEvent;
   import flash.net.navigateToURL;
   import flash.net.URLLoader;
   import flash.net.URLRequest;
   import flash.events.Event;
   import fl.controls.listClasses.CellRenderer;
   import fl.controls.ScrollBarDirection;


   public class VideoPlaylist extends MovieClip {
      private var xmlLoader:URLLoader;

      public function VideoPlaylist():void {
         // Load the playlist file, then initialize the media player.
         xmlLoader=new URLLoader  ;
         xmlLoader.addEventListener(Event.COMPLETE,initMediaPlayer);
         xmlLoader.load(new URLRequest("playlist.xml"));
         // Format the tileList, specify its cellRenderer class.
         tileList.setSize(100,240);
         tileList.columnWidth=180;
         tileList.rowHeight=60;
         tileList.direction=ScrollBarDirection.VERTICAL;
         tileList.setStyle("cellRenderer",Thumb);
      }
      
      var botoncito:Sprite = new Sprite();
      botoncito.buttonMode = true;
      

      public function initMediaPlayer(event:Event):void {
         var myXML:XML=new XML(xmlLoader.data);
         var item:XML;
         for each (item in myXML.vid) {// populate playlist.
            // Get thumbnail value and assign to cellrenderer.
            var thumb:String;
            if (item.hasOwnProperty("@thumb") > 0) {
               thumb=item.@thumb;
            }// Send data to tileList.
            tileList.addItem({label:item.attribute("desc").toXMLString(),data:item.attribute("src").toXMLString(),source:thumb});

         }
         // Select the first video.
         tileList.selectedIndex=0;
         // Listen for item selection.
         tileList.addEventListener(Event.CHANGE,listListener);
         // And automatically load it into myVid.
         myVid.source=tileList.selectedItem.data;
         // Pause video until selected or played.
         myVid.pause();
      }
      // Detect when new video is selected, and play it
      function listListener(event:Event):void {
         myVid.play(event.target.selectedItem.data);
      }
   }
}


y he puesto en el frame 2 en la misma capa donde he puesto a botoncito y donde he colocado a botoncito el codigo que me ha dicho...


Código :


botoncito.addEventListener(MouseEvent.CLICK,abrir);

function abrir(e:MouseEvent):void {

   navigateToURL(new URLRequest("http://www.google.es/ig"));

}



Y no encuentro nada referente a que la variable esté duplicada. Las otras lineas de codigo son un stop() en el frame 45.

Luego he modificado la visibilidad en dos frames para el playlist.

El codigo en elframe 1 para esto sería :

Código :

myVid.alpha = 0;
tileList.alpha = 0;



y el codigo en el frame 42


Código :

myVid.alpha = 1;
tileList.alpha = 1


Referente a codigo no hay nada más.

Alguna idea que pueda solucionar esto pesadilla?

Muchas gracias.

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 28 Jun 2008 01:08 pm
Si ya pusiste el código que me dices en la línea de tiempo en el mismo frame de botoncito, entonces elimina de la clase estas dos líneas:

Código :

var botoncito:Sprite = new Sprite();
botoncito.buttonMode = true;

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 29 Jun 2008 08:38 am
Genial, y ahora ese error se ha ido, sin embargo surge otro error cuando le doy, y dice que el error se encuentra en la linea 4 del actionscript.as , y el error te lo describe como el 1046: type was not found or was not a complie-time constant:SimpleButton y luego te dice en el source que es import flash.net.navigateToURL;

Muchas gracias.

Por capi cibera

20 de clabLevel



Genero:Masculino  

safari
Citar            
MensajeEscrito el 30 Jun 2008 10:11 am
Esa línea no es el error, estoy seguro de que todo gira a través de botoncito, hagamos una cosa, mándame tus archivos a [email protected], trataré de ver donde está el problema y postearé cuando lo encuentre.

Saludos

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox

 

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