The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 1 of 1

Thread: Loading images from an Array generated from XML

  1. #1

    Loading images from an Array generated from XML

    OK, this is my first day trying to use AS3 and I'm kind of confused on how to load an image onto the screen and then be able to resize it, scale it, etc..

    I'm loading up to 5 images in from an XML file that will be generated on a server. (right now I'm just using a test.xml file).

    Normally I would load the images into dynamically created movie clips (whatever0_mc through whatever4_mc generated by code in AS2). But I can't seem to get anything working.. I've looked on the internet and read through some information but I'm still just REALLY confused... this is what I have so far. To make it easier on me in the future, I've put different code on different layers so I can look at it closer.. I've separated the code into the different layers they're on here:

    import; // URL Loader Import for Images
    import; // URL Requests Import for Images
    import flash.display.Loader; // Loader
    import; // Progress for Loader
    import flash.text.TextField; // Imports for Text Fields
    import flash.display.Sprite; // Imports Sprite stuff for loaded Images
    import flash.display.Bitmap; // Imports stuff to display a bitmap
    var imgLoader:Loader = new Loader(); // Initialize Image Loader
    // Listeners for the Image Loaders //
    function showPreloader(evt:Event):void {
        trace("-- ** showPreloader ** --");
    function showProgress(evt:ProgressEvent):void {
        trace("-- ** showProgress ** --");
        var totalLoaded:Number = evt.bytesTotal;
        var currentLoaded:Number = evt.bytesLoaded;
        var thePercent:Number = (currentLoaded * 100) / totalLoaded;
        loadProgress_txt.text = thePercent + "%"; // Show bytes loaded
    function showLoadResult(evt:Event):void {
        trace("-- ** showLoadResult ** --");
    // Setup Variables //
    var imageArray:Array = new Array();
    var galleryTitle:String;
    var numPhotos:Number;
    var gallerySubmitter:String;
    // XML Info //
    XML.ignoreComments = true;
    XML.ignoreWhitespace = true;
    var galleryXML:XML;
    var xmlLoader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest("test.xml");
    xmlLoader.addEventListener(Event.COMPLETE, XMLComplete);
    function XMLComplete(evt:Event):void {
        trace("-- ** XMLComplete ** --");
        var loader:URLLoader = as URLLoader;
        if (loader != null){
            galleryXML = new XML(;
            galleryTitle = galleryXML.children()[0].attributes()[0];
            numPhotos = galleryXML.children()[0].attributes()[1];
            gallerySubmitter = galleryXML.children()[0].attributes()[2];
            trace("galleryTitle: " + galleryTitle);
            trace("numPhotos: " + numPhotos);
            trace("gallerySubmitter: " + gallerySubmitter);
            for(var i:Number = 0; i<numPhotos; i++) {
            } // for(var i:Number = 0; i<numPhotos; i++)
            trace("loading: images\\gallery\\" + imageArray[0]);
            var imgRequest:URLRequest = new URLRequest("images\\gallery\\" + imageArray[0]); // Request the Image into the Loader
        } else { // if (loader != null){
            trace("loader is not a URLLoader!");
        } // if (loader != null){
    } // function onComplete(event:Event):void {
    // End XML Info //
    Can anyone point me in the next direction? thanks...

    I've uploaded the files too but you'll have to change out images and the path to the images if you want to test it.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012