Para empezar éste es mi xml:
---------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<enlaces>
<texto1 px="384" py="57" ix="-100" tiempoI="0" tiempoF="20"><![CDATA[<font color="#FFFFFF" face="Tahoma" size="25"><b>xxxxxxxxxxxxxxxxxxx</b></font>]]></texto1>
<texto2 px="383" py="56" ix="-100" tiempoI="0" tiempoF="20"><![CDATA[<font color="#000000" face="Tahoma" size="25"><b>xxxxxxxxxxxxxxxxxxx</b></font>]]></texto2>
<texto3 px="384" py="153" ix="-200" tiempoI="0" tiempoF="240"><![CDATA[<font color="#FFB03C" face="Arial" size="18">xxxxxxxxxx<a href="http://xxxxxx.xxx.xx"><u>XXXXXXXXX</u></a> xxxxxxxxxxxx</font>]]></texto3>
<texto4 px="383" py="152" ix="-200" tiempoI="0" tiempoF="240"><![CDATA[<font color="#FFFFFF" face="Arial" size="18">xxxxxxxxxx<a href="http://xxxxxx.xxx.xx"><u>XXXXXXXXX</u></a> xxxxxxxxxxxx</font>]]></texto4>
</enlaces>
---------------------------------------------------------------------
Este es el código que sí funciona, pero no es dinámico:
---------------------------------------------------------------------
Stage.scaleMode = "noscale";
miXML = new XML();
miXML.ignoreWhite = true;
miXML.onLoad = function(succes) {
if (succes) {
var parent = this.firstChild.childNodes;
texto_txt1 = parent[2].firstChild.nodeValue;
texto_txt2 = parent[3].firstChild.nodeValue;
var mc:MovieClip = createEmptyMovieClip("nuevo",1);
var mcTexto:MovieClip = mc.createEmptyMovieClip("textoxxx",2);
//texto1
mcTexto.createTextField("texto1", 1, 384, 153, 100, 100);
mcTexto.texto1.html = true;
mcTexto.texto1.selectable = false;
mcTexto.texto1.multiline = true;
mcTexto.texto1.autoSize = "center";
mcTexto.texto1.htmlText = texto_txt1;
//texto2
mcTexto.createTextField("texto2", 2, 374, 143, 100, 100);
mcTexto.texto2.html = true;
mcTexto.texto2.selectable = false;
mcTexto.texto2.multiline = true;
mcTexto.texto2.autoSize = "center";
mcTexto.texto2.htmlText = texto_txt2;
//mascara//
mcMascara = mc.createEmptyMovieClip("mascara",1);
mcMascara.lineStyle(1,0xFF00FF,100);
mcMascara.beginFill(0xFFCC00,100);
mcMascara.moveTo(200,150);
mcMascara.lineTo(375,150);
mcMascara.lineTo(375,175);
mcMascara.lineTo(200,175);
mcMascara.lineTo(200,150);
mcMascara.endFill();
mcTexto.setMask(mcMascara);
//animar//
mc._x=0;
mc._y=0;
mcTexto._x = 50;
onEnterFrame = function(){
mcTexto._x -= 5;
if(mcTexto._x < -350) {
mcTexto._x = 50;
}}
}
};
miXML.load("xxx.xml");
---------------------------------------------------------------------
Este es el código que quiero implementar que es dinámico pero tiene defectos, igual que el anterior pero con un par de diferencias:
---------------------------------------------------------------------
this.onLoad = function(){
//cT=4;
ict=1;
fct=7;
}
Stage.scaleMode = "noscale";
miXML = new XML();
miXML.ignoreWhite = true;
miXML.onLoad = function(succes) {
if (succes) {
var parent = this.firstChild.childNodes;
for(i=0; i<parent.length; i++){
texto_txt = new Array(parent[i].firstChild.nodeValue);
trace(texto_txt.join());
//texto_txtt = new Array(texto_txt);
//texto_txt[i] = parent[i].firstChild.nodeValue;
////POSICIONES////
_root["textoPX"+i] = parent[i].attributes.px;
_root["textoPY"+i] = parent[i].attributes.py;
////Pos Inicial////
_root["textoIX"+i] = parent[i].attributes.ix;
////Tiempo Inicio////
_root["textoTI"+i] = parent[i].attributes.tiempoI;
////Tiempo Fin////
_root["textoTF"+i] = parent[i].attributes.tiempoF;
var mc:MovieClip = createEmptyMovieClip("nuevo",1);
var mcTexto:MovieClip = mc.createEmptyMovieClip("textoxxx",2);
for(cT=ict; cT<fct; cT++){
mcTexto.createTextField("texto"[cT], cT, 384, 153, 100, 100);
mcTexto.texto[cT].html = true;
mcTexto.texto[cT].selectable = false;
mcTexto.texto[cT].multiline = true;
mcTexto.texto[cT].autoSize = "center";
mcTexto.texto[cT].htmlText = texto_txt[cT];
}
}
//mascara//
mcMascara = mc.createEmptyMovieClip("mascara",1);
mcMascara.lineStyle(1,0xFF0000,100);
mcMascara.beginFill(0xFF6600,100);
mcMascara.moveTo(180,150);
mcMascara.lineTo(585,150);
mcMascara.lineTo(585,175);
mcMascara.lineTo(180,175);
mcMascara.lineTo(180,150);
mcMascara.endFill();
mcTexto.setMask(mcMascara);
//animar//
mc._x=0;
mc._y=0;
mcTexto._x = 600;
onEnterFrame = function(){
mcTexto._x -= 5;
if(mcTexto._x < -500) {
mcTexto._x = 600;
}}
}
};
miXML.load("xxx.xml");
Por último quisiera que opinen sobre esta otra versión del código, que sí funciona, sí es dinámica, pero no le pude aplicar la máscara:
-------------------------------------------------------------------------------------------------
//////VERSION AUTOMATICA (DINAMICA)/////////////////////////////
Stage.scaleMode = "noscale";
miXML = new XML();
miXML.ignoreWhite = true;
miXML.onLoad = function(succes) {
if (succes) {
var parent = this.firstChild.childNodes;
for(i=0; i<parent.length; i++){
_root["texto_txt"+i] = parent[i].firstChild.nodeValue;
////POSICIONES////
_root["textoPX"+i] = parent[i].attributes.px;
_root["textoPY"+i] = parent[i].attributes.py;
////Pos Inicial////
_root["textoIX"+i] = parent[i].attributes.ix;
////Tiempo Inicio////
_root["textoTI"+i] = parent[i].attributes.tiempoI;
////Tiempo Fin////
_root["textoTF"+i] = parent[i].attributes.tiempoF;
}
var mc:MovieClip = createEmptyMovieClip("nuevo",1);
var mcTexto:MovieClip = mc.createEmptyMovieClip("texto",2);
//texto//
for(cT=ict; cT<fct; cT++){
createTextField("texto"+cT, cT, _root["textoPX"+cT], _root["textoPY"+cT], "", "");
_root["texto"+cT].html = true;
_root["texto"+cT].selectable = false;
_root["texto"+cT].multiline = true;
_root["texto"+cT].autoSize = "center";
_root["texto"+cT].htmlText = _root["texto_txt"+cT];
//mascara//
mcMascara = mc.createEmptyMovieClip("mascara",1);
mcMascara.lineStyle(1,0xFF0000,100);
mcMascara.beginFill(0xFF6600,100);
mcMascara.moveTo(180,150);
mcMascara.lineTo(585,150);
mcMascara.lineTo(585,175);
mcMascara.lineTo(180,175);
mcMascara.lineTo(180,150);
mcMascara.endFill();
mcTexto.setMask(mcMascara);
}
}
};
miXML.load("xxx.xml");
this.onLoad = function(){
ict = 6;
fct = 8;
tM = new Array();
//tM = [2];
tiempo = 0;
tiempoFin = 180;
itm = 6;
ftm = 8;
}
//Funcion textoMover
this.onEnterFrame = function(){
for(tM=itm; tM<ftm; tM++){
if(tiempo < 5){
_root["texto"+[tM]]._x = _root["textoIX"+[tM]];
}
}
for(tM=itm; tM<ftm; tM++){
if(tiempo < _root["textoTF"+[tM]]){
_root["texto"+[tM]]._x += +5;
}
}
for(tM=itm; tM<ftm; tM++){
if(tiempo > _root["textoTF"+[tM]]){
_root["texto"+[tM]]._x = _root["textoIX"+[tM]];
}
if(tiempo > _root["textoTF"+[tM]]){
tiempo = 0;
}
}
++tiempo;
}
----------------------------------------------------------------------------------------
Esta última versión fué lo más cerca de llegar a donde quería, pero no le pude aplicar la máscara, sabía que creando la máscara con código sería la única forma de lograr que funcione, había intentado de todo, creando la máscara manualmente en una capa del flash, etc. El problema resulta ser que no puedo crear el textField de esta manera:
mcTexto.createTextField("texto"+cT, cT, _root["textoPX"+cT], _root["textoPY"+cT], "", "");
pero sí puedo hacer lo mismo sin definir la ruta, (tal como está en el código):
createTextField("texto"+cT, cT, _root["textoPX"+cT], _root["textoPY"+cT], "", "");
Por favor diganme cual es mi problema, y si existe una manera más prolija de concretar el asunto, tal vez como crear de manera más eficiente los arrays, etc. Muchas gracias por su apoyo.
