Comunidad de diseño web y desarrollo en internet online

cargar URL variable

Citar            
MensajeEscrito el 26 Nov 2007 02:41 am
Hola, tengo un problemilla. Estoy haciendo un tutorial que he encontrado por ahi de hacer carrusels (imagino que más de uno sabrá a cual me refiero).

El problema es que en el tutorial se manejan datos como imágenes y textos pero no URL's.

Os expongo los códigos y luego las dudas.

Código :

El XML
<icons>
   <icon image="hogar.swf" tooltip="Hogar" url="http://www.tuweb.com/1.pdf" />
   <icon image="personal.swf" tooltip="Cuidado personal" url="http://www.tuweb.com/2.pdf" />
   <icon image="bolsos.swf" tooltip="Bolsos y viaje" url="http://www.tuweb.com/3.pdf" />
   <icon image="escritura.swf" tooltip="Escritura y oficina" url="http://www.tuweb.com/4.pdf" />
   <icon image="relojes.swf" tooltip="Relojes y Electrónica" url="http://www.tuweb.com/5.pdf" />
   <icon image="mecheros.swf" tooltip="Encendedores" url="http://www.tuweb.com/6.pdf" />
   <icon image="herramientas.swf" tooltip="Herramientas" url="http://www.tuweb.com/7.pdf" />
   <icon image="juegos.swf" tooltip="Juegos" url="http://www.tuweb.com/8.pdf" />
   <icon image="paraguas.swf" tooltip="Paraguas" url="http://www.tuweb.com/9.pdf" />
   <icon image="textil.swf" tooltip="Textil" url="http://www.tuweb.com/10.pdf" />
   <icon image="playa.swf" tooltip="Camping y playa" url="http://www.tuweb.com/11.pdf" />
</icons>


Código :

El Action Script
import mx.utils.Delegate;

var numOfItems:Number;
var radiusX:Number = 300;
var radiusY:Number = 75;
var centerX:Number = Stage.width / 2;
var centerY:Number = Stage.height / 2;
var speed:Number = 0.05;
var perspective:Number = 130;
var home:MovieClip = this;

var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
tooltip._alpha = 0;

var xml:XML = new XML();
xml.ignoreWhite = true;

xml.onLoad = function()
{
   var nodes = this.firstChild.childNodes;
   numOfItems = nodes.length;
   for(var i=0;i<numOfItems;i++)
   {
      var t = home.attachMovie("item","item"+i,i+1);
      t.angle = i * ((Math.PI*2)/numOfItems);
      t.onEnterFrame = mover;
      t.toolText = nodes[i].attributes.tooltip;
      t.content = nodes[i].attributes.content;
      t.icon.inner.loadMovie(nodes[i].attributes.image);
      t.r.inner.loadMovie(nodes[i].attributes.image);
      t.icon.onRollOver = over;
      t.icon.onRollOut = out;
      t.icon.onRelease = released;
   }
}

function over()
{
   var sou:Sound = new Sound();
   sou.attachSound("sover");
   sou.start();   
   home.tooltip.tipText.text = this._parent.toolText;
   home.tooltip._x = this._parent._x;
   home.tooltip._y = this._parent._y - this._parent._height/2.6;
   home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
   home.tooltip._alpha = 100;
   
}

function out()
{
   delete home.tooltip.onEnterFrame;
   home.tooltip._alpha = 0;
}

function released()
{   
   var sou:Sound = new Sound();
   sou.attachSound("sdown");
   sou.start();
}




function moveTip()
{
   home.tooltip._x = this._parent._x;
   home.tooltip._y = this._parent._y - this._parent._height/2.6;
}

xml.load("icons.xml");

function mover()
{
   this._x = Math.cos(this.angle) * radiusX + centerX;
   this._y = Math.sin(this.angle) * radiusY + centerY;
   var s = (this._y - perspective) /(centerY+radiusY-perspective);
   this._xscale = this._yscale = s*100;
   this.angle += this._parent.speed;
   this.swapDepths(Math.round(this._xscale) + 100);
}

this.onMouseMove = function()
{
   speed = (this._xmouse-centerX)/1800;
}


La pregunta es sencilla, no se si la explicación lo es tanto. ¿Cómo hago para cargar la variable url del xml y que en la función released de as la obtenga?

Cada icono debería obtener su url que al ser un pdf se iniciaría una descarga.

Muchas gracias.

Por Abducted

Claber

489 de clabLevel

3 tutoriales

Genero:Masculino  

Mentalidad Renovada

firefox
Citar            
MensajeEscrito el 27 Nov 2007 03:30 pm
despues de:
t.toolText = nodes[i].attributes.tooltip;

pones:
t.Url = nodes[i].attributes.url;

y en la función "released" obtienes el valor de la Url:
var UrlPdf = this._parent.Url;


y la manipulas como quieras.

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7
Citar            
MensajeEscrito el 27 Nov 2007 03:31 pm
y este post deberia ir en el apartado de actionscript, por eso nadie te lo responde.

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7
Citar            
MensajeEscrito el 28 Nov 2007 05:26 pm
Muchas gracias por la respuesta, al final conseguí hacerlo de otra manera, pero que lo volveré a hacer con la solución que me has dado.

Con respecto a lo del foro, puse esto aqui, por que debajo del título del foro pone "conexiones a datos remotos, XML..." por eso creí que era su lugar. No obstante al día siguiente y al ver que casi nadie lo leía puse en el foro de AS un post refiriéndose a este. Pero no conseguí mucho mas con ello.

De nuevo Muchíiiisimas gracias.

Saludos,
Abducted.

Por Abducted

Claber

489 de clabLevel

3 tutoriales

Genero:Masculino  

Mentalidad Renovada

firefox

 

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