Log in

View Full Version : Resolved load image into holder mc from xmal as3



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);
}

evan
06-16-2009, 04:32 AM
THis is it


var myxml:XML;
var textdata:String;
//var for image to load
var jpgdata:String;
var loader:URLLoader= new URLLoader();

/*var rect1:Sprite = new Sprite();
rect1.graphics.beginFill(0xFFCC

00);
rect1.graphics.drawRect(200, 200, 200, 200);
//rect1.buttonMode = true;
addChild(rect1);
*/


loader.addEventListener(Event.COMPLETE,loadComplete);

loader.load(new URLRequest("myxml3.xml"));

function loadComplete(evt:Event):void
{

myxml = new XML(evt.target.data);
loader.removeEventListener(Event.COMPLETE,loadComplete);
//trace(myxml.Content);
textdata=myxml.Content;
jpgdata=myxml.pics;
trace (textdata);
trace (jpgdata);
textbox.text=textdata;
holder.alpha=.5;

var pictLdr:Loader = new Loader();
var pictURL:String = jpgdata;
var pictURLReq:URLRequest = new URLRequest(pictURL);
pictLdr.load(pictURLReq);
holder.addChild(pictLdr);

// holder.load(jpgdata);



}