Comunidad de diseño web y desarrollo en internet online

inquietud sobre links en XML + AS2

Citar            
MensajeEscrito el 09 Oct 2009 09:26 pm
Tengo un template realizado en flash + xml. El archivo index.swf tiene un menu, que se forma con un XML y, clickeando en cada item se abre en el stage cada modulo (por ejemplo: Contacto, News, Slideshow, etc). Estos modulos, a su vez, tienen cada uno su propio XML donde se define su contenido en particular. Algunos XML de estos modulos permiten poner hiperlinks, como en cualquier HMTL. Es decir: <a href://"... etc. Y estos abren obviamente una url externa.

Y aqui viene mi inquietud: es posible que, esos links, en lugar de abrir una url externa, abran otro de los modulos, reemplazando al que esta en esos momentos en el stage? Es decir, que si yo clickeo en una imagen (o banner) que hay en el modulo actual, este se cierre y abra otro de los modulos swf.

He leido que puede hacerse a traves de loadmovie, con un mc vacio o contenedor, pero he hecho mil pruebas y no consigo resolverlo. Les dejo el codigo XML y el AS que tiene uno de los modulos swf, para ver si algunos de ustedes puede guiarme hacia la solucion. Gracias de antemano a todos.

XML de la seccion Slideshow:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<content Name="SLIDESHOW">
<item Image="slideshow/image1.jpg" Delay="5000" Link="http://www.linkexterno.com">
<copy><![CDATA[<font color="#FFFFFF" size="15"><b>titulo</b></font><br>texto texto.]]></copy>
</item>


AS en slideshow.fla. (Este esta en el primer frame del mc llamado content_mc)

//
// INITIAL SETTINGS
//
import mx.transitions.Tween;
import mx.transitions.easing.*;
slideShow = true;
if (slideShow) {
bttnAutoPlay.gotoAndStop(2);
}
ID = 0;
info_mc._alpha = 0;
//
// CASCADING STYLE SHEET
//
var styles = new TextField.StyleSheet();
// Set hyperlink colour and decoration here
styles.setStyle("a:link", {color:'#00FFFF', textDecoration:'none'});
styles.setStyle("a:hover", {color:'#00FFFF', textDecoration:'underline'});
info_mc.txt.html = true;
info_mc.txt.styleSheet = styles;
//
// BANNER BUTTON
//
//Set getURL options when banner is pressed here
bannerPress = function () {
getURL(Link[ID], "_blank");
};
//
// MENU BUTTON
//
menuPress = function (obj) {
clearInterval(_global.timeInterval);
ID = obj.ID;
imageLoad();
};
//
// AUTOPLAY BUTTON
//
bttnAutoPlay.bttn.onPress = function() {
if (this._parent._currentframe == 1) {
slideShow = true;
this._parent.gotoAndStop(2);
bannerTimer();
} else {
slideShow = false;
this._parent.gotoAndStop(1);
clearInterval(_global.timeInterval);
}
};
//
// AUTOMATED BANNER FUNCTION
//
bannerTimer = function () {
trace('slideshow timer');
if (slideShow && info_mc._alpha == 0) {
clearInterval(_global.timeInterval);
ID += 1;
if (ID == total) {
ID = 0;
}
imageLoad();
}
};
//
// DISPLAY INFO TEXT
//
setText = function () {
info_mc.txt.htmlText = xmlNode.childNodes[ID].childNodes[0].firstChild.nodeValue;
info_mc.bg._width = holder_mc._width;
info_mc.txt._width = info_mc.bg._width-20;
info_mc.txt._x = info_mc.bg._x+10;
info_mc.txt._height = info_mc.txt.textHeight+10;
info_mc.bg._height = info_mc.txt._height+10;
info_mc._x = holder_mc._x;
info_mc._y = holder_mc._y+holder_mc._height-info_mc._height;
};
var tweenInfo:Tween = new Tween(info_mc, "_alpha", Strong.easeOut, 0, 0, 20, false);
//
// DETECT LARGE IMAGE ROLLOVER
//
onMouseMove = function () {
if (holder_mc.hitTest(_root._xmouse, _root._ymouse, true)) {
tweenInfo.continueTo(100);
} else {
tweenInfo.continueTo(0);
}
};
//
// BUILD BANNER DISPLAY
//
construct = function () {
for (i=0; i<total; i++) {
//Vars from XML
Image[i] = xmlNode.childNodes[i].attributes.Image;
Delay[i] = xmlNode.childNodes[i].attributes.Delay;
Link[i] = xmlNode.childNodes[i].attributes.Link;
//Build menu
menu_mc.bttn_mc.duplicateMovieClip("bttn_mc"+i, i);
menu_mc["bttn_mc"+i]._x = (menu_mc.bttn_mc._width+1)*i;
menu_mc["bttn_mc"+i].ID = i;
menu_mc["bttn_mc"+i].num_mc.num.text = i+1;
preloader_mc._x = menu_mc._x+menu_mc._width+15;
//Set menu hilight
}
imageLoad();
};
//
// CALL FUNCTION TO LOAD IMAGE
//
imageLoad = function () {
for (i=0; i<total; i++) {
if (menu_mc["bttn_mc"+i].ID == ID) {
menu_mc["bttn_mc"+i].gotoAndStop(2);
} else {
menu_mc["bttn_mc"+i].gotoAndStop(1);
}
}
var tweenAlpha:Tween = new Tween(holder_mc, "_alpha", Regular.easeOut, 100, 0, 20, false);
tweenAlpha["onMotionFinished"] = function () {
loadMovie(Image[ID], holder_mc);
};
};
//
// CALL FUNCTION ONCE IMAGE HAS LOADED
//
imageLoaded = function () {
var tweenAlpha:Tween = new Tween(holder_mc, "_alpha", Regular.easeOut, 0, 100, 40, false);
clearInterval(_global.timeInterval);
_global.timeInterval = setInterval(bannerTimer, Delay[ID]);
setText();
};
tweenAlpha["onMotionFinished"] = function () {
holder_mc.play();
};
//
// LOAD XML
//
loadXML = function (loaded) {
if (loaded) {
xmlNode = this.firstChild;
Image = [];
Delay = [];
Link = [];
total = xmlNode.childNodes.length;
headerName.text = xmlNode.attributes.Name;
} else {
trace("Error loading XML");
}
};
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("slideshow/slideshow.xml");
stop();


Gracias, esperare ansiosa sus comentarios.

Por Camila 80

1 de clabLevel



 

firefox
Citar            
MensajeEscrito el 10 Oct 2009 04:29 am
Gente, ya la solucione.
En el link del XML iria esto (suponiendo que quiero abrir la seccion news.swf desde otro modulo swf)

<a href="asfunction:_global.loadContentURL,news.swf">Ver News</a>

Y esta funcion esta determinada en el swf principal o index:

// LOAD CONTENT FROM URLS
//
_global.loadContentURL = function(Link) {
// Spit toLoad from Link if function called from hyperlink
splitLink = new Array(this);
splitLink = Link.split(",");
_global.loadContent(splitLink[0], splitLink[1], "");
};
//
Espero que a alquien le sea util.
Gracias a todos los que se tomaron el trabajo de leer mi inquietud.
Camila

Por Camila 80

1 de clabLevel



 

firefox

 

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