evan
06-12-2009, 07:08 PM
I can get text to load into a textbox but I am doing something wrong with getting the image to load.
I have gone through the actionscript tutorial on gotoandlearn but it is in AS2
I would be infinitely grateful if anyone can show me what is wrong with my code!
here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<main>
<Content>
In this xml document there are nodes the main element is called the root and nested nodes within nodes are reffered to as
children, this xml document has a root called main and two child nodes called "content" and "images"
there are alltogether five node kinds, element,attribute,text node , comment,processing instruction.
</Content>
<images>
picone.jpg
</images>
</main>
here is the actionscript:
var myxml:XML;
var textdata:String;
//var for image to load
var jpgdata:String;
var loader:URLLoader= new URLLoader();
var holder:MovieClip= new Holder();
addChild(holder);
holder.x=500;
holder.y=300;
loader.addEventListener(Event.COMPLETE,OnComplete);
loader.load(new URLRequest("myxml3.xml"));
function OnComplete(evt:Event):void
{
myxml = new XML(evt.target.data);
loader.removeEventListener(Event.COMPLETE,OnComplete);
//trace(myxml.Content);
textdata=myxml.Content;
jpgdata=myxml.images;
//trace (textdata)
textbox.text=textdata;
//holder(jpgdata);
//thumb_loader.load(new URLRequest(thumb_url));
trace(jpgdata);
holder.load(jpgdata);
}
I have gone through the actionscript tutorial on gotoandlearn but it is in AS2
I would be infinitely grateful if anyone can show me what is wrong with my code!
here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<main>
<Content>
In this xml document there are nodes the main element is called the root and nested nodes within nodes are reffered to as
children, this xml document has a root called main and two child nodes called "content" and "images"
there are alltogether five node kinds, element,attribute,text node , comment,processing instruction.
</Content>
<images>
picone.jpg
</images>
</main>
here is the actionscript:
var myxml:XML;
var textdata:String;
//var for image to load
var jpgdata:String;
var loader:URLLoader= new URLLoader();
var holder:MovieClip= new Holder();
addChild(holder);
holder.x=500;
holder.y=300;
loader.addEventListener(Event.COMPLETE,OnComplete);
loader.load(new URLRequest("myxml3.xml"));
function OnComplete(evt:Event):void
{
myxml = new XML(evt.target.data);
loader.removeEventListener(Event.COMPLETE,OnComplete);
//trace(myxml.Content);
textdata=myxml.Content;
jpgdata=myxml.images;
//trace (textdata)
textbox.text=textdata;
//holder(jpgdata);
//thumb_loader.load(new URLRequest(thumb_url));
trace(jpgdata);
holder.load(jpgdata);
}