Hey all, Im not that new to AS, though this been very twitchy with me. I found an example of putting in text dynamically into a ScrollingPane object. I followed the code but I just cannot get it to work for me. This happens constantly that for some reason it will not just work.
What I am trying to do is that using a query string I pass it some variables, that tell it were to look in an xml file. And all I want it to do is be able to use that one flash file, to display different texts depending on what variables I send it. Also using the parameters in the HTML I tell it its sizes that is should be, and it will adjust accordingly the scrolling pane and all.
Here is the code:
Code:
function loadXML(loaded)
{
_root.xmlPane._height=Stage.height;
_root.xmlPane._width=Stage.width;
xmlPane._x=0;
xmlPane._y=0;
_root.createEmptyMovieClip("xml_mc",2);
xml_mc._height=Stage.height-5;
xml_mc._width=Stage.width-5;
myTextFormat = new TextFormat();
myTextFormat.font = "xmlText";
myTextFormat.color="#ffffff";
myTextFormat.size=12;
_root.xml_mc.createTextField(xmlTextField,2,0,30,Stage.width, Stage.height);
_root.xml_mc[xmlTextField].embedFonts= true;
_root.xml_mc[xmlTextField].setNewTextFormat(myTextFormat);
_root.xml_mc[xmlTextField].setTextFormat(myTextFormat);
_root.xml_mc[xmlTextField].border = true;
_root.xml_mc[xmlTextField].text="This is a test";
trace(xml_mc[xmlTextField].text);
_root.xmlPane.setScrollContent(_root.xml_mc[xmlTextField]);
xmlNode=this.firstChild;
total=xmlNode.childNodes.length;
for (i=0;i<total;i++)
{
section1=xmlNode.childNodes[i].attributes.name;
if (section1==_root.page)
{
total2=xmlNode.childNodes[i].childNodes.length;
for (x=0;x<total2;x++)
{
section2=xmlNode.childNodes[i].childNodes[x].attributes.section;
if (section2==_root.section)
{
}
}
}
}
}
Stage.align="TL";
Stage.scaleMode="exactFit";
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("texts.xml");
xmlData is the var for loading up the xml.
xmlNode are the nodes within the xml.
xmlPane is the ScrollingPane,
xml_mc is the empty movie clip,
xmlTextField is the text field that goes into xml_mc.
If I put the sizing coding outside of the loadXML, it will not resize even if put before xmlData. When tracing
_root.xml_mc[xmlTextField] it does display "This is a test", but will not bring it up in the the scolling pane.
Any help I would appreciate very much. Thank you
NeoSpawn