Comunidad de diseño web y desarrollo en internet online

Quien me ayuda con el preload ???

Citar            
MensajeEscrito el 27 Sep 2004 12:30 am
Yo no se q pasa ?? pero no va , buaaa!!!

Dejo el code para q me lo mireis :

Código :

import com.buho.dibujo.Dibujo; 
import com.buho.utilidades.ObjectLoader;

class com.buho.componentes.Preload extends com.buho.componentes.BuhoObject {
   
   // capas
   var $fondo: Dibujo ;
   var $barra: Dibujo ;
   var $barraLinea: Dibujo ;
   
   // medidas
   var $ancho: Number = 80 ;
   var $alto: Number = 10 ;
   var $anchoMarco: Number = 100 ;
   var $altoMarco: Number = 40 ;
   
   // texto
   var $CampoTexto: MovieClip ;
   var $texto : Array ;
   var $css:Object;
   
   // color componente
   private var $styleUndefined:Boolean =true;
   private var $style:Object = new Object();
   
   // transferencia
   var $objectoLoad ;
   private var classLoader:ObjectLoader ;
   
   // posicion de la barra
   private var $posx:Number ;
   private var $posy:Number ;

   //referencia donde aplicar el evento
   private var $listener:Object ;
   
   //default style
   static var $styleGlobal = {
      
      movimiento : {   
         ecuacion : com.robertpenner.easing.Quint.easeOut ,
         duracion : 15 , // duracion de el movimiento en frames/sg
         interval : 1 // tiempo en la q se comprueba como va la transeferencia , + tiempo = + bruto , en sg
      },
      barra : {
         ver:true,
         radio : 0,
         inf : {   
            color: {
               ver :{linea:false, fondo:"solido"} ,
               solido:{color:0x4B6B7C, alpha:100}
            }   
         },
         med : {   
            color: {
               ver :{linea:false, fondo:"degradado"} ,
               solido:{color:0x777777 , alpha:40},
               degradado:{type:"linear", color:[0xFFFFFF, 0x4B6B7C, 0x8EAEB9], ratio:[0, 100,255]}
            }
         },
         sup : {   
            color: {
               ver :{linea:true, fondo:false} ,
               linea:{grosor:2 , color:0x555555 , alpha:100} 
            }
         }
      },
      marco:{
         ver:true,
         radio : 10,
         color: {
            ver :{linea:false, fondo:"solido"} ,
            solido:{color:0xC2CFD5 , alpha:80}
         }
      }
   }
   
   //// CONSTRUCTOR
   
   function Preload () {
      //creamos la capas donde dibujaremos
      $fondo = Dibujo.addDibujo (this,0,0,1);
      $barra = Dibujo.addDibujo (this,0,0,2);
      $barraLinea = Dibujo.addDibujo (this,0,0,3); 
   }
   
   
   static function addPreload (clip , x:Number, y:Number , nivel:Number):Preload {
      
      if(x==undefined)x=0;
      if(y==undefined)y=0;
      
      if(nivel==undefined) nivel = clip.getNextHighestDepth();
      var tempPreload:Preload = Preload(clip.attachMovie("Preload", "preload" + nivel , nivel,{_x:x,_y:y}));
      return tempPreload ;
      
   }
   
   //// MEDIDAS DE EL PRELOAD
   function setSize (barra:Object,marco:Object) {
      
      // medidas
      if(barra != undefined){
         $ancho = barra.ancho ;
         $alto = barra.alto ;
      }
      
      if(marco != undefined){
         $anchoMarco = marco.ancho ;
         $altoMarco = marco.alto ;
      }
      
      // cargando style
      if ($styleUndefined){
         if(_global.buho.preload._style != undefined)$style = _global.buho.preload._style
         else $style = $styleGlobal;
      }
      
      // dibujando el tinglao
      drawText ();
      draw();
      
   }
   
   //// INICIO COMPONENTE
   function load (target,obj):Void{
      
      
      //objecto q se le aplicara el metodo "onLoadComplete"
      $listener = target ;
      
      // supervisando la descarga
      $objectoLoad = obj ;
      classLoader = new ObjectLoader(this,$objectoLoad,$style.movimiento.interval);
      
      move(0)
      mueveBarra($barra,0);
      
   }
   
   //// PROPIEDAD _style
   // cambia el estilo de el componente
   function set _style (obj:Object):Void {   
      $style = obj ;
      $styleUndefined = false
   }
   
   //// METODO setTexto
   // 
   
   function setTexto (texto:String,css:Object) {   
      $css = formateaText(css) ;
      $texto = texto.split("#");   
   }
   
   function onLoadProgress(obj){
      $CampoTexto.htmlText = parseaTexto ($texto,obj);
      mueveBarra($barra,obj.porcentaje);
   }
      
   function onLoadComplete(obj){
      move(100);
      $CampoTexto.htmlText = parseaTexto (["Cargado"],obj);
      $listener.onLoadComplete($objectoLoad,obj.bytesTotal);
   }
   
   function onLoadError(str:String){
      $listener.onLoadError($objectoLoad,str);
   }
   
   private function move(scale){
      
      delete $barra.onEnterFrame ;
      // inicio de variables para $barra
      $barra.duracion = $style.movimiento.duracion ; // frames/sg 
      $barra.antes=0
      $barra._xscale=scale;
      
   }
   
   private function parseaTexto (array:Array,obj:Object):String {
      
      var result = "<titulo>";
      
      for ( var i = 0 ; i<=array.length-1; i++ ){
         if (array[i].substr(0,1)=="$")result += obj[array[i].substr(1)];
         else result += array[i];
      }
      
      return result += "</titulo>";
      
   }
   
   private function draw(){
      
      // cuando hay marco
      if($style.marco.ver){
         
         // marco
         $fondo._style = $style.marco.color;
         $fondo.rRectangulo($anchoMarco,$altoMarco,0,0,$style.marco.radio);
         
         if ($style.barra.ver){
            
            // barra inf
            $fondo._style = $style.barra.inf.color;
            $fondo.rRectangulo($ancho,$alto,$posx,$posy,$style.barra.radio);
            
            // barra med
            $barra._x = $posx ;
            $barra._y = $posy ;
            $barra._style = $style.barra.med.color;
            if($style.barra.med.color.matrix==undefined){
               $barra._style = { matrix:{x:$ancho/2, y:$alto/2, w:$alto, h:$ancho, r:90}};
            }
            $barra.rRectangulo($ancho,$alto,0,0,$style.barra.radio);
            $barra._xscale = 0 ;
            
            // barra sup
            $barraLinea._x = $posx ;
            $barraLinea._y = $posy ;
            $barraLinea._style = $style.barra.sup.color;
            $barraLinea.rRectangulo($ancho,$alto,0,0,$style.barra.radio);
            
         }
      
      // cuando no hay marco
      } else if ($style.barra.ver){
         
         // barra inf
         $fondo._style = $style.barra.inf.color;
         $fondo.rRectangulo($ancho,$alto,$posx,$posy,$style.barra.radio);
         // barra med
         $barra._style = $style.barra.med.color;
         $barra._style = { matrix:{x:$ancho/2, y:$alto/2, w:$alto, h:$ancho, r:90}}
         $barra.rRectangulo($ancho,$alto,$posx,$posy,$style.barra.radio);
         $barra._xscale = 0 ;
         // barra sup
         $barraLinea._style = $style.barra.sup.color;
         $barraLinea.rRectangulo($ancho ,$alto , $posx ,$posy , $style.barra.radio);
         
      }
   }
   
   //// TEXTO

   private function formateaText(css:Object){
      
      if(css == undefined) {
         
         //si no existe en _global
         if(_global.buho.preload.css == undefined){            
            
            return {
               ver:true,
               color: '#000000',
               fontFamily: '_sans',
               fontSize: '9',
               fontWeight: 'bold',
               textAlign : 'center' ,// left // right // center
               posy : 'inf' // sup // inf // med
            };
            
          //si existe en _global
         }else return _global.buho.preload.css ;
         
      }else return css ;
      
   }
   
   private function drawText ():Void {
      
      //texto
      if($css.ver)this.createTextField("$CampoTexto", 4, 0, 0 ,0,0);
      var css = new TextField.StyleSheet();
      css.setStyle("titulo", $css)
      $CampoTexto.autoSize = $css.textAlign;
      $CampoTexto.selectable = false;
      $CampoTexto.html = true ;
      $CampoTexto.styleSheet = css ;
      //$CampoTexto.border = true;
      
      $CampoTexto.htmlText = parseaTexto ($texto,{porcentaje:0,bytesTotal:"??",bytesLoaded:0});

      //// RECOLOCANDO BARRA Y EL CAMPO DE TEXTO
      // recoloca todo segun la css
      
      // cuando hay marco 
      if ($style.marco.ver){
            
         $posx = ($anchoMarco - $ancho )/2;
         
         //moviendo x
         switch ($css.textAlign) {
            case "left":
               $CampoTexto._x = $posx
               break;
            case "center":
               $CampoTexto._x = Math.round( $posx+(($ancho - $CampoTexto._width)/2 ));
               break;
            case "right":
               $CampoTexto._x = Math.round( $posx+($ancho - $CampoTexto._width )) ;
               break;
         }
         
         //moviendo y
         switch ($css.posy) {
            
            case "inf":
               var posy = ($altoMarco - $alto - $CampoTexto._height)/3;
               if (posy>$style.marco.radio){
                  $posy = posy ;
                  $CampoTexto._y = Math.round( $posy*2 + $alto ) ;
               }else{
                  $posy = $style.marco.radio;
                  var centro = ($altoMarco - $alto - $CampoTexto._height-$posy)/2
                  $CampoTexto._y = Math.round( $posy + $alto + centro);
               }
               break;
               
            case "med":
               $posy =(($altoMarco - $alto )/2)
               $CampoTexto._y = Math.round( ($altoMarco  - $CampoTexto._height)/2 ) ;
               break;
               
            case "sup":
               var posy = ($altoMarco - $alto - $CampoTexto._height)/3;
               if (posy>$style.marco.radio){
                  $posy = $altoMarco - posy - $alto;
                  $CampoTexto._y = Math.round( posy ) ;
               }else{   
                  $posy = $altoMarco - $style.marco.radio - $alto;
                  var centro = ($posy-$CampoTexto._height)/2 ;
                  $CampoTexto._y = Math.round( centro) ;
               }
               break;
         }
      
      // cuando no hay marco   
      }else{
         
         $posy = $posx = 0; 
         
         //moviendo x
         switch ($css.textAlign) {
            
            case "left":
               break;
            case "center":
               $CampoTexto._x = Math.round( ($ancho - $CampoTexto._width)/2 ) ;
               break;
            case "right":
               $CampoTexto._x = Math.round( $ancho - $CampoTexto._width ) ;
               break;
               
         }
         
         //moviendo y
         switch ($css.posy) {
            
            case "inf":
               $CampoTexto._y = Math.round( $alto) ;
               break;
            case "med":
               var centrar = ($alto - $CampoTexto._height )/2 ;
               $CampoTexto._y = Math.round( $CampoTexto._y + centrar ) ;
               break;
            case "sup":
               $CampoTexto._y = Math.round( -$CampoTexto._height ) ;
               break;
               
         }
         
      }
   }
   
   function mueveBarra (mc:Dibujo,porcen:Number):Void{
      
      delete mc.onEnterFrame ;
      mc.posini = mc._xscale =  mc.antes; 
      mc.distancia = porcen - mc.posini ;
      mc.tiempo = 0 ;//contador
      
      mc.onEnterFrame = function() {
         
         with (this) {   
            _xscale = _parent.$style.movimiento.ecuacion(tiempo++, posini , distancia, duracion);
            if (tiempo>duracion) delete onEnterFrame;
         }
         
      };
      
      mc.antes = porcen ;
      
   }
      
   function toString ():String {return "Preload" ;}
   
}


XD XD XD XD XD XD XD XD XD

Unos ejemplos de mi preload 8) 8) 8) 8)

los ejemplo funciona , solo teneis q pulsar sobre ellos ...













Bueno paso 2 cumplido !! -->mirar de q ostia hablo

Abra paso 3 ?

no he jugado demasiado con los colores (degradados) ni con la fuente pero esto da mucho mas !!!

Se me olvidaba ... , mirar en la cache XD XD XD

salu2

Por buho29

510 de clabLevel

1 tutorial

7 ejemplos

 

unknown
Citar            
MensajeEscrito el 27 Sep 2004 01:38 am
w00t
Esta increible ... (Asi que cumplo con el punto !3)

Solamente que cualquier newbie se asusta de solo ver como se minimiza la barra de desplazamiento (Y eso que no ha visto las otras clases); pero es buenisimo

Lo dicho, para que sea 100% util, solo le falta documentación ;)

Saludos

Por Freddie

BOFH

53 tutoriales
597 articulos
43 ejemplos

Genero:Masculino   Admin

Conserje de Cristalab

unknown
Citar            
MensajeEscrito el 27 Sep 2004 06:31 am
Buho, por que no subes las clases esas tuyas pa aca, ya tengo el componente de dibujo y pincha mostro, que tal si te unes eso tambien.

Seria un componente muy fuerte y mas si le pones una documentacion como se la pusiste al componete de dibujo.

Por Alucard

54 de clabLevel



Genero:Masculino  

Universidad

unknown
Citar            
MensajeEscrito el 27 Sep 2004 06:39 am
Lo dicho !!!! (Y me avisas :$ ) xD

Por Freddie

BOFH

53 tutoriales
597 articulos
43 ejemplos

Genero:Masculino   Admin

Conserje de Cristalab

unknown

 

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