WEB Any Flash ActionScript 3.0 guru's in here?

Discussion in 'OT Technology' started by MikeTheVike1, Jan 8, 2008.

  1. MikeTheVike1

    MikeTheVike1 OT Supporter

    Joined:
    Aug 29, 2002
    Messages:
    5,840
    Likes Received:
    0
    I'm teaching myself as I go, currently I'm working with very basic XML files and loading them into flash.

    Basically what I want to do is read all the images in the XML file, and put them into an array that I can access to perform tweens and stuff on them. I have the XML file loaded into flash, but I'm having problems with loading it into an Array, and then accessing them. if anyone wants to take a look at my code so far, that would be awesome...

    I'm getting this error right after the trace("good to go") command using my current code....

    TypeError: Error #1006: value is not a function.
    at portfolio_test_03_fla::MainTimeline/loadIMG()
    at portfolio_test_03_fla::MainTimeline/imgLoaded()

    Code:
    stop();
    
    //Declare variables
    var imgArray:Array = new Array();
    var imageLoader:Loader; 
    var xml:XML;
    var xmlList:XMLList; 
    var xmlLoader:URLLoader = new URLLoader(); 
    xmlLoader.load(new URLRequest("xmldata/images.xml")); 
    var xmlLength:int = 0;  
    
    xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); 
    
    function xmlLoaded(event:Event) :void {     
         xml = XML(event.target.data);
         xmlList = xml.children();     
         xmlLength = xmlList.length();     
         //trace(xmlLength);
    
         for (var i:int = 0; i<xmlLength; i++) {
              imageLoader = new Loader();
              imageLoader.load(new URLRequest(xmlList[i].attribute("href")));
              imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoaded);
         }
    }
    
    function imgLoaded(event:Event) :void {
         imgArray.push(imageLoader);        
         trace(imgArray.length);         
         trace("xmlLength" + " " + xmlLength);        
         if (imgArray.length == xmlLength) {            
              loadIMG();         
         } 
    } 
    
    function loadIMG() {     
         trace("good to go");     
         for (var j:int = 0; j<imgArray.length(); j++) {         
              trace(imgArray[j]);         
              addChild(imgArray[j]);     
         } 
    }
    

    And if anyone is messing with AS3 and wants my code for a simple image viewer that slides pictures in with "next" and "previous" buttons, I'll post it.
     

Share This Page