Comunidad de diseño web y desarrollo en internet online

cargar swf externos por medio de xml

Citar            
MensajeEscrito el 05 Oct 2009 09:52 pm
señores k tal buenas tardes a todos y noches en dodne ya es noche bueno sin tanto bla bla bla el motivo k expongo esk tengo un flash me funcionan a la perfeccion los menus k cargo por xml todo perfecto no hay ningun problema el detalle esk kiero k al darle click ejemplo al boton contacto me cargue ese swf dentro de mi pelicula principal estos son los codigos k estoy utilizando
AS2

Código ActionScript :

import mx.transitions.Tween;
import mx.transitions.easing.*;

new Tween(forte, "_alpha", Strong.easeInOut, 0, 100, 3, true);

function addButtons() {
   pushOverX = 0;
   for (i=0; i<obj.buttons.length; i++) {
      btn = menu.attachMovie("button", "btn"+i, -i, {_x:pushOverX, id:i});
      btn.t.autoSize = "left";
      btn.t.text = obj.buttons[i].attributes.title;
      btn.t.textColor = 0xffffff;
      btn.back._width = btn.t._width;
      pushOverX += Math.round(btn._width+bS);
      setBtnEvents(btn);
   }
   selectFirstBtn();
   var cl:Color = new Color(menu.bar);
   cl.setRGB(0xCCFF00);
}

function setBtnEvents(btn:MovieClip) {
   btn.onRollOver = function() {
      btn = this;
      st = obj.buttons[btn.id].attributes.title;
      btn.t.textColor = 0xCCFF00;
      typeText(btn.t,st,0,5);
      menu.bar.tweenX.stop();
      menu.bar.tweenWidth.stop();
      menu.bar.tweenX = new Tween(menu.bar, "_x", Strong.easeOut, menu.bar._x, btn._x, .6, true);
      menu.bar.tweenWidth = new Tween(menu.bar, "_width", Strong.easeOut, menu.bar._width, btn.back._width, .6, true);
      pressedBtn.t.textColor = 0xffffff;
      typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,1);
      s.start();
   };
   btn.onRollOut = function() {
      btn = this;
      st = obj.buttons[btn.id].attributes.title;
      btn.t.textColor = 0xffffff;
      typeText(btn.t,st,0,1);
      menu.bar.tweenX.stop();
      menu.bar.tweenWidth.stop();
      menu.bar.tweenX = new Tween(menu.bar, "_x", Strong.easeOut, menu.bar._x, pressedBtn._x, .6, true);
      menu.bar.tweenWidth = new Tween(menu.bar, "_width", Strong.easeOut, menu.bar._width, pressedBtn.back._width, .6, true);
      pressedBtn.t.textColor = 0xCCFF00;
      typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,5);
   };
   btn.onPress = function() {
      pressedBtn.enabled = true;
      pressedBtn = this;
      this.enabled = false;
      //ADD HERE CUSTOM FUNCTION
      st  = obj.buttons[pressedBtn.id].attributes + ""; 
      demoFunction(st);
   };
}


function selectFirstBtn(){
   pressedBtn = menu.btn0;
   pressedBtn.enabled = false;
   menu.bar.tweenX = new Tween(menu.bar, "_x", Strong.easeOut, menu.bar._x, pressedBtn._x, .6, true);
   menu.bar.tweenWidth = new Tween(menu.bar, "_width", Strong.easeOut, menu.bar._width, pressedBtn.back._width, .6, true);
   pressedBtn.t.textColor = 0xCCFF00;
   typeText(pressedBtn.t,obj.buttons[pressedBtn.id].attributes.title,0,5);
}

function typeText(t:TextField, finalString:String, initRandomStringLength:Number, speed:Number) {
   var currentLength:Number = 0;
   var counter:Number = 0;
   t._parent.onEnterFrame = function() {
      if (currentLength<finalString.length) {
         counter++;
         var currentString:String = "";
         var randString:String = "";
         for (i=currentLength; i<initRandomStringLength; i++) {
            randString += String.fromCharCode(random(50)+20);
         }
         for (i=0; i<=currentLength; i++) {
            currentString += finalString.charAt(i);
         }
         if (counter>=speed || randString.charAt(stL) == finalString.charAt(stL)) {
            currentLength++;
            counter = 0;
         }
         
         if (initRandomStringLength<finalString.length-1) {
            initRandomStringLength++;
         }
         t.text = currentString+randString;
      } else {
         delete t._parent.onEnterFrame;
      }
   };
}

var tC:Number = new Number();//text color
var tROC:Number = new Number();//rollover text color
var bS:Number = new Number();//buttons spacing

var pressedBtn:MovieClip = new MovieClip();

var obj:Object = new Object();

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



xml.onLoad = function(succes) {
   if (succes) {
      tC = Number(this.firstChild.attributes.textColor);
      tROC = Number(this.firstChild.attributes.rolloverColor);
      bS = Number(this.firstChild.attributes.spacing);
      obj.buttons = this.firstChild.childNodes;

      addButtons();
   } else {
      trace("xml could not load");
   }
};

xml.load("menu.xml");


y este es el xml

Código XML :

<menu>
   
   <item title="Home"/>
   <item title="About us"/>
   <item title="Products"/>
   <item title="Laboratories"/>
   <item title="Contact"/>

</menu>


porfavor si alguien me pudiera ayuda ya intente muchas cosa seor nada funciona
PD: necesito ponerle al xml el nombre del archivo k kiero k cargue ejemplo contact contacto.swf porfa favor alguna alma k se apiade de mi :( :cry:

Por tjmysteri

Claber

138 de clabLevel



 

msie8
Citar            
MensajeEscrito el 06 Oct 2009 03:18 pm
agrega la ruta del swf en el xml por ejemplo:


Código XML :

<menu> 
    
   <item title="Home" swf="parte1.swf" /> 
   <item title="About us" swf="parte2.swf" /> 
   <item title="Products" swf="parte3.swf" /> 
   <item title="Laboratories" swf="parte4.swf" /> 
   <item title="Contact" swf="parte5.swf" /> 
 
</menu>


y al cargar con el boton en tu codigo pones la ruta y lo completas con el nombre del swf

Por ipalmeros

45 de clabLevel



 

firefox

 

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