Results 1 to 2 of 2

Thread: load image into holder mc from xmal as3

  1. #1
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default load image into holder mc from xmal as3

    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);
    }
    Last edited by Snookerman; 06-16-2009 at 06:38 AM.

  2. #2
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default this works -finally

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



    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •