array data taking XML value is not taking css value in as3

Posted by Sagar S. Ranpise on Stack Overflow See other posts from Stack Overflow or by Sagar S. Ranpise
Published on 2010-03-25T13:10:44Z Indexed on 2010/03/25 13:13 UTC
Read the original article Hit count: 310

Filed under:
|
|
|

I have xml structure all data comes here inside CDATA

I am using css file in it to format text and classes are mentioned in xml Below is the code which shows data but does not format with CSS. Thanks in advance!

var myXML:XML = new XML(); var myURLLoader:URLLoader = new URLLoader(); var myURLRequest:URLRequest = new URLRequest("test.xml"); myURLLoader.load(myURLRequest);

//////////////For CSS/////////////// var myCSS:StyleSheet = new StyleSheet(); var myCSSURLLoader:URLLoader = new URLLoader(); var myCSSURLRequest:URLRequest = new URLRequest("test.css"); myCSSURLLoader.load(myCSSURLRequest); myCSSURLLoader.addEventListener(Event.COMPLETE,processXML);

var i:int; var textHeight:int = 0; var textPadding:int = 10; var txtName:TextField = new TextField(); var myMov:MovieClip = new MovieClip(); var myMovGroup:MovieClip = new MovieClip(); var myArray:Array = new Array();

function processXML(e:Event):void {
myXML = new XML(myURLLoader.data); trace(myXML.person.length()); var total:int = myXML.person.length(); trace("total" + total);

for(i=0; i<total; i++)
{
    myArray.push({name: myXML.person[i].name.toString()});
    trace(myArray[i].name);
}

processCSS();

}

function processCSS():void { myCSS.parseCSS(myCSSURLLoader.data);

for(i=0; i<myXML.person.length(); i++)
{

    myMov.addChild(textConvertion(myArray[i].name));
    myMov.y = textHeight;
    textHeight += myMov.height + textPadding;
    trace("Text: "+myXML.person[i].name);
    myMovGroup.addChild(myMov);
}
this.addChild(myMovGroup);

}

function textConvertion(textConverted:String) { var tc:TextField = new TextField(); tc.htmlText = textConverted; tc.multiline = true; tc.wordWrap = true; tc.autoSize = TextFieldAutoSize.LEFT; tc.selectable = true; tc.y = textHeight; textHeight += tc.height + textPadding; tc.styleSheet = myCSS; return tc; }

© Stack Overflow or respective owner

Related posts about as3-actionscript

Related posts about css