Comunidad de diseño web y desarrollo en internet online

carousel con carga de swf

Citar            
MensajeEscrito el 05 Oct 2010 04:50 pm
Hola de nuevo!!

A ver si en esto alguien me puede ayudar...

Quiero hacer esto http://tutorials.flashmymind.com/2009/05/vertical-3d-carousel-with-actionscript-3-and-xml/ pero con una diferencia, q al dar click a cada botón me cargue un swf diferente, en vez de ir a una web...Agradecería q alguien me dijera lo q tengo q cambiar del código as3 y del xml.

Muchas gracias!

Por natig

76 de clabLevel



 

chrome
Citar            
MensajeEscrito el 05 Oct 2010 08:52 pm
Bueno, ya q nadie contesta, voy a decir lo q he probado y el error que me da:

En el código he añadido en esta función:

Código ActionScript :

function createMenu():void {

//Get the number of menu items we will have
numberOfItems = xml.items.item.length();

//Calculate the angle difference between the menu items (in radians)
var angleDifference:Number = Math.PI * (360 / numberOfItems) / 180;

//We use a counter so we know how many menu items have been created
var count:uint = 0;

//Loop through all the <button></button> nodes in the XML
for each (var item:XML in xml.items.item) {

//Create a new menu item
var menuItem:MenuItem = new MenuItem();

//Calculate the starting angle for the menu item
var startingAngle:Number = angleDifference * count;

//Set a "currentAngle" attribute for the menu item
menuItem.currentAngle = startingAngle;

//Position the menu item
menuItem.xpos3D = 0;
menuItem.ypos3D = radius * Math.sin(startingAngle);
menuItem.zpos3D = radius * Math.cos(startingAngle);

//Calculate the scale ratio for the menu item (the further the item -> the smaller the scale ratio)
var scaleRatio = focalLength/(focalLength + menuItem.zpos3D);

//Scale the menu item according to the scale ratio
menuItem.scaleX = menuItem.scaleY = scaleRatio;

//Position the menu item to the stage (from 3D to 2D coordinates)
menuItem.x = vanishingPointX + menuItem.xpos3D * scaleRatio;
menuItem.y = vanishingPointY + menuItem.ypos3D * scaleRatio;

//Add a text to the menu item
menuItem.menuText.text = item.label;

//Add a "linkTo" variable for the URL
menuItem.linkTo = item.linkTo;

menuItem.movie = item.movie;

//We don't want the text field to catch mouse events
menuItem.mouseChildren = false;

//Assign MOUSE_OVER, MOUSE_OUT and CLICK listeners for the menu item
menuItem.addEventListener(MouseEvent.MOUSE_OVER, mouseOverItem);
menuItem.addEventListener(MouseEvent.MOUSE_OUT, mouseOutItem);
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);

//Add the menu item to the menu items array
menuItems.push(menuItem);

//Add the menu item to the stage
addChild(menuItem);

//Assign an initial alpha
menuItem.alpha = 0.3;

//Add some blur to the item
TweenMax.to(menuItem,0, {blurFilter:{blurX:1, blurY:1}});

//Update the count
count++;
}
}


la línea

Código ActionScript :

menuItem.movie = item.movie;


Y en esta:

Código ActionScript :

function itemClicked(e:Event):void {
   var loader:Loader = new Loader();
    var ureq:URLRequest = new URLRequest(e.target.movie);
    loader.addEventListener(Event.COMPLETE, swfHandler);
    loader.load(ureq);
   function swfHandler(e:Event):void {
        addChild(loader);
}
}


En el xml he añadido:

Código XML :

<movie>peli1.swf</movie>


Y me da este error:

Error #2044: IOErrorEvent no controlado: text=Error #2035: No se encuentra la dirección URL.

Gracias.

Por natig

76 de clabLevel



 

chrome
Citar            
MensajeEscrito el 05 Oct 2010 09:36 pm
mm de echo puedes usar el mismo tag linkTo solo sustituyes por la ruta..la clase MenuItem si esta linkeado desde la biblioteca y su base es en Mc y su clase asosiada es la que el mismo flash genera deberia dejarte crear propiedades, por la clase es abierta..de lo contrario debes escribir la clase y agregar la propiedad movie , ahora en la funcion itemClicked no anides funciones.. me molesta la vista cuando veo eso jeje..ademas de que el scope es jodido cuando haces eso prueba con :

Código ActionScript :

var loader:Loader = new Loader(); 
loader.addEventListener(Event.COMPLETE, swfHandler, false, 0, true);
 
function itemClicked(e:MouseEvent):void 
{ 
   var swf_url:String = (e.target.movie);
   if(swf_url) {
      loader.load(new URLRequest(swf_url)); 
   }
}

function swfHandler(e:Event):void 
{ 
   var swf_content:MovieClip = e.target.content as MovieClip;
    addChild(swf_content); 
} 


declaramos fuera el loader y en la funcion verificas que la propiedad movie exista, de ser asi que se llame el metodo load() del objeto Loader ..en el handler agregar su contenido.

Nota: tambien debe existir tus swfs en la carpeta de tu proyecto..si no nada serviara.

Jonathan

Por maneuver

243 de clabLevel



Genero:Masculino  

Mexico City

firefox
Citar            
MensajeEscrito el 06 Oct 2010 02:18 pm
Muchas gracias por tu respuesta, pero lo he probado y me da exactamente el mismo error...

Y tengo el swf q quiero cargar en el mismo sitio...

Por natig

76 de clabLevel



 

chrome
Citar            
MensajeEscrito el 06 Oct 2010 03:13 pm
really ? ..lo probe y anda baje el demo y agrege esto

Código ActionScript :

//Import TweenMax
import com.greensock.TweenMax;

var swf_loader:Loader = new Loader();
swf_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfHandler, false, 0, true);
//The path to the XML file (use your own here)
var xmlPath:String = "carousel-menu.xml";
//........
function swfHandler(e:Event):void
{
   var swf_content:MovieClip = e.target.content as MovieClip;
   addChild(swf_content)
}

function itemClicked(e:Event):void {

   //Navigate to the URL that's assigned to the menu item
   var urlRequest:URLRequest=new URLRequest(e.target.linkTo);
   swf_loader.load(urlRequest);
   //navigateToURL(urlRequest);

}


el xml solo los tags linkTo su valor cambialos por las rutas de los swf.

Código XML :

<menu>
    <items>
        <item>
            <label>Home</label>
            <linkTo>swfA.swf</linkTo>
        </item>
//...


Jonathan

Por maneuver

243 de clabLevel



Genero:Masculino  

Mexico City

firefox
Citar            
MensajeEscrito el 06 Oct 2010 03:24 pm
Pues mil gracias!!

Ya funciona, y la verdad esq no se q es lo que había hecho mal, ya tenía mil archivos con mil pruebas y en algo habré metido la pata...

Por natig

76 de clabLevel



 

chrome

 

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