Comunidad de diseño web y desarrollo en internet online

Cargar datos xml en flash as2

Citar            
MensajeEscrito el 19 Mar 2009 08:52 pm
nada no funciona

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Mar 2009 08:58 pm
Almenos te hace el trace?

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:20 pm
si eso si

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:29 pm
mmm, se me ocurre:

Código ActionScript :

pantalla_mc.onLoad = function()  
{  
   this.onEnterFrame = function()
   {
      trace("Centrando...") 
      this._width = Math.min( this._width, 200 );  
      this._height = Math.min( this._height, 200 );  
      this._x = (Stage.width - this._width) / 2;  
      this._y = (Stage.height - this._height) / 2;
      delete this.onEnterFrame;
   };
};


si eso no funciona, tendrias que usar MovieClipLoader

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:33 pm
Nada sigue sin funcionar.
Te explico recuerda que ese swf se habre dentro del principal. por eso lo de stage lo tiene el principal. Alomejor por eso no funciona correctamente.

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:49 pm
El Stage es un objeto accesible desde cualquier enfoque, pero bueno, si de lo restringe a 200x200 ?? osea el problea esta en que no lo centra en la pantalla? cuando estaba sin el onEnterFrame, ya te lo restringia de tamaño?

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:52 pm
Prueba con:

Código ActionScript :

pantalla_mc.onLoad = function()   
{   
   this.onEnterFrame = function() 
   { 
      trace("Centrando...")  
      this._width = Math.min( this._width, 200 );   
      this._height = Math.min( this._height, 200 );   
      var aux:Object = { x:((Stage.width - this._width) / 2), y:((Stage.height - this._height) / 2) }
      globalToLocal( aux );
      this._x = aux.x;
      this._y = aux.y
      delete this.onEnterFrame; 
   }; 
}; 

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:52 pm
No entiendo pero bueno da lo mismo te explico.
la imagen que carga del xml se carga y se ve pero no se ajusta al clip de pelicula o se queda en la parte de arriba a la izquierda o las grandes de pasan del tamaño que yo le he dado.

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:58 pm
nada seguimos igual ya no hace ni el trace

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 19 Mar 2009 11:59 pm
Bueno, postea tu codigo dentro de las etiquetas:

Código :

[as] [/as]

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 20 Mar 2009 12:01 am

Código ActionScript :

pantalla_mc.onLoad = function()    
{    
   this.onEnterFrame = function()  
   {  
      trace("Centrando...")   
      this._width = Math.min( this._width, 200 );    
      this._height = Math.min( this._height, 200 );    
      var aux:Object = { x:((Stage.width - this._width) / 2), y:((Stage.height - this._height) / 2) } 
      globalToLocal( aux ); 
      this._x = aux.x; 
      this._y = aux.y 
      delete this.onEnterFrame;  
   };  
}; 
var obj_xml:XML = new XML();
obj_xml.ignoreWhite = true;
but._x=-200;
but1._x=-200;
var num:Number=0;
obj_xml.onLoad = function(exito)
{
if (exito)
cargar(0);

}
obj_xml.load("OFERTAS-WEB.bus");
cargar =function(num:Number)
{
articulo.text = obj_xml.childNodes[0].childNodes[num].childNodes[0].childNodes[0].nodeValue;
descripcion.text = obj_xml.childNodes[0].childNodes[num].childNodes[1].childNodes[0].nodeValue;
precio.text = obj_xml.childNodes[0].childNodes[num].childNodes[2].childNodes[0].nodeValue;
imagen =obj_xml.childNodes[0].childNodes[num].childNodes[3].childNodes[0].nodeValue;
pantalla_mc.loadMovie(imagen);
if(obj_xml.childNodes[0].childNodes[num+1]==null)
but1._x=-200;
else
but1._x=762.95;
if(num==0)
but._x=-200;
else
but._x=611.8;
}

but.onRelease = function()
{
num--;
cargar(num);
}

but1.onRelease = function()
{
num++;
cargar(num);
}

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Mar 2009 12:03 am
Hay que tabular correctamente el codigo para que sea mas entendible, lo voy a convertir MovieClipLoader, pero explicame, ¿La imagen la quieres centrar en la patalla o en algun lugar especifico?

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 20 Mar 2009 12:08 am
alaa imagen quiero que se centre si es mas pequeña que las dimensiones dentro del clip de pelicula pantalla_mc y si es mas grande que se ajuste a las dimensiones del clip de pelicula por que la imagen se haber en el clip de pelicula pantalla_mc

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Mar 2009 12:19 am
Prueba con:

Código ActionScript :

stop();

//-- Cargador --//
var cargador_mcl:MovieClipLoader = new MovieClipLoader();
cargador_mcl.addListener( this );

function onLoadInit( target:MovieClip )
{     
   trace("Centrando..." + target);
   target._width = Math.min( target._width, 200 );     
   target._height = Math.min( target._height, 200 );     
   var aux:Object = { x:(Stage.width - target._width) / 2, y:(Stage.height - target._height) / 2 };
   globalToLocal( aux );  
   target._x = aux.x;  
   target._y = aux.y;
}

but._x = -200; 
but1._x = -200; 
var num:Number = 0; 

//-- XML --//
var obj_xml:XML = new XML(); 
obj_xml.ignoreWhite = true; 
obj_xml.onLoad = function( exito:Boolean ) 
{ 
   if (exito) cargar(0); 
};
obj_xml.load("OFERTAS-WEB.bus"); 

function cargar( num:Number ) 
{ 
   articulo.text = obj_xml.childNodes[0].childNodes[num].childNodes[0].childNodes[0].nodeValue; 
   descripcion.text = obj_xml.childNodes[0].childNodes[num].childNodes[1].childNodes[0].nodeValue; 
   precio.text = obj_xml.childNodes[0].childNodes[num].childNodes[2].childNodes[0].nodeValue; 
   imagen =obj_xml.childNodes[0].childNodes[num].childNodes[3].childNodes[0].nodeValue; 
   cargador_mcl.loadClip( imagen, pantalla_mc );
   but1._x = (obj_xml.childNodes[0].childNodes[num+1]==null) ? -200 : 762.95; 
   but._x = (num==0) ? -200 : 611.8; 
} 
 
but.onRelease = function() 
{ 
   num--; 
   cargar(num); 
};
 
but1.onRelease = function() 
{ 
   num++; 
   cargar(num); 
}

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 20 Mar 2009 12:28 am
Correcto eso era lo que queria pero no quiero que se ajuste a la pantalla solo que se ajuste al clip de pelicula

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Mar 2009 12:34 am
var aux:Object = { x:(Stage.width - target._width) / 2, y:(Stage.height - target._height) / 2 }; esta linea me lo centra no se por que, bueno de todas formas la he quitado y me lo hace como quiero solo falta un detalle que las imagenes que no sean mayores a las dimensiones del clip de pelicula que me las centre al clip de pelicula

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Mar 2009 01:22 am
Ok, entonces, la quieres centrada en un "marco imaginario" de 200 por 200 ?

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 20 Mar 2009 01:29 am
no vamos a ver cuando la he quitado ya ha quedado bien:

Código :

var cargador_mcl:MovieClipLoader = new MovieClipLoader(); 
cargador_mcl.addListener( this ); 
 
function onLoadInit( target:MovieClip ) 
{       
   target._width = Math.min( target._width, 334 );      
   target._height = Math.min( target._height, 260 );      
   globalToLocal( aux );   
   target._x = aux.x;   
   target._y = aux.y; 
} 
 


pero claro eso esta de lux para las imagenes mas grandes de 334 * 260 pero las pequeñas se quedan a la izquierda superior, entonces lo que me gustaria saber es como hacer para que la imagen que tenga menos resolucion que la indicada se centre en el clip de pelicula pantalla_mc

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Mar 2009 01:32 am
Si, a eso me refiero, centrar en un marco imaginario, tu prueba esto:

Código ActionScript :

function onLoadInit( target:MovieClip ) 
{       
   target._width = Math.min( target._width, 334 );      
   target._height = Math.min( target._height, 260 );      
   target._x = (200 - target._width) / 2;
   target._y = (200 - target._height) / 2;
} 

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 20 Mar 2009 01:50 am
nada lo del margen nada ahora se pone el la esquuina de abajo de la derecha si se pudiera centras al clip de pelicula estaria de lux

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Mar 2009 02:48 am
listo solucionado en mi caso el problema estaba en estas lineas:

Código :

target._x = (450 - target._width) / 2; 
   target._y = (380 - target._height) / 2;


he tenido que ir jugando con los numeros 450 y 380 para cuadrarlo con lo que queria.

al final se ha quedado asi:

Código :

var cargador_mcl:MovieClipLoader = new MovieClipLoader(); 
cargador_mcl.addListener( this ); 
 
function onLoadInit( target:MovieClip )  
{        
   target._width = Math.min( target._width, 334 );       
   target._height = Math.min( target._height, 260 );       
   target._x = (450 - target._width) / 2; 
   target._y = (380 - target._height) / 2;
} 
but._x = -200;  
but1._x = -200;  
var num:Number = 0;  
 
//-- XML --// 
var obj_xml:XML = new XML();  
obj_xml.ignoreWhite = true;  
obj_xml.onLoad = function( exito:Boolean )  
{  
   if (exito) cargar(0);  
}; 
obj_xml.load("OFERTAS-WEB.xml");  
 
function cargar( num:Number )  
{  
   articulo.text = obj_xml.childNodes[0].childNodes[num].childNodes[0].childNodes[0].nodeValue;  
   descripcion.text = obj_xml.childNodes[0].childNodes[num].childNodes[1].childNodes[0].nodeValue;  
   precio.text = obj_xml.childNodes[0].childNodes[num].childNodes[2].childNodes[0].nodeValue;  
   imagen =obj_xml.childNodes[0].childNodes[num].childNodes[3].childNodes[0].nodeValue;  
   cargador_mcl.loadClip( imagen, pantalla_mc ); 
   but1._x = (obj_xml.childNodes[0].childNodes[num+1]==null) ? -200 : 779.95;  
   but._x = (num==0) ? -200 : 628.8;  
}  
  
but.onRelease = function()  
{  
   num--;  
   cargar(num);  
}; 
  
but1.onRelease = function()  
{  
   num++;  
   cargar(num);  
} 


hay estan los botones la carga de los datos y la imagen en su lugar para el diseño.

Muchisimas gracias a todos.
Un saludo¡¡¡¡¡¡¡¡¡¡¡¡¡¡
SOLUCIONADO

Por rubensfh

38 de clabLevel



 

firefox
Citar            
MensajeEscrito el 20 Mar 2009 03:24 am
:D perfecto.

Por LongeVie

Claber

1741 de clabLevel

1 tutorial

Genero:Masculino  

En un lugar, re moto.

firefox
Citar            
MensajeEscrito el 20 Mar 2009 03:27 am
Muchas gracias a ti LongeVie y a yeestrada1 gracias a vosotros empiezo a entender y manejar el as2.
Os lo agradezco mucho.

Por rubensfh

38 de clabLevel



 

firefox

 

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