I’ve solved the silly error I’ve made, but Thanks to _kp for the friendly reply!
I’m new with AS3 and Basically what i’m trying to do is to load an xml file
format below:
<?xml version="1.0" encoding="utf-8"?>
<buttons>
<button>
<name>Introduction</name>
<text>
<![CDATA[ VALID HTML CODE ]]>
</text>
</button>
<buttons>
and load a list of name to the list (list) to the left and the html code to the right (textArea).
there’s only 1 place (frame 1) with AS3 code:
(I’ve dragged the Textarea component and list component in the library and they show up … i just can’t solve the error…)
import fl.controls.*;
import flash.net.*;
import flash.text.*;
var myTextArea = new TextArea();
var myList = new List();
addChild(myTextArea);
addChild(myList);
myTextArea.width = 400;
myTextArea.length = 580;
myTextArea.x = 420;
myTextArea.y = 10;
myList.width = 400;
myList.length = 580;
myList.x = 10;
myList.y = 10;
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);
/*
function onLoaded(e:Event):void
{
trace(e.target.data);
}
*/
myList.addEventListener(Event.CHANGE, itemChange);
function itemChange(e:Event):void
{
myTextArea.text = myList.selectedItem.data;
}
var xml:XML;
function onLoaded(e:Event):void
{
xml = new XML(e.target.data);
var il:XMLList = xml.button;
for(var i:Number=0;i<il.length();i++)
{
myList.addItem({label:il.name.text()*,
data:il.text.text()*});
trace(il.name*);
trace(il.text*);
}
}
loader.load(new URLRequest("helpfile_v002.xml"));
I got the below error:
ReferenceError: Error #1074: Illegal write to read-only property length on fl.controls.TextArea.
at test002_fla::MainTimeline/frame1()
when i Ctrl Enter on the fla file.
Any help is really really appreciated since i’m lost on what i’m doing wrong…