1 Reply Latest reply on Jun 25, 2009 3:07 PM by Ned Murphy

    adding functionality to images imported externally using MovieClipLoader

    Grant Corley

      Hi,

       

      I'm creating an image scroller in AS2 that pulls images into Flash from an external folder, as determined by an XML file. The program use a MovieClipLoader to load the external images into series of empty, and temporarily invisible, movie clips that are created inside a for loop. Once the attached listener determines that the clips are all loaded, their visibility is turned on and they begin scrolling.

       

      Everything had been going fine, until I tried to add functionality to each of the four images that had been loaded. All I want to do is generate a trace statement that says "success" when I mouse over each of the four external images in the scroller.  I can use that as a springboard to continue working...

       

      Here is the problem: "Success" IS traced out upon rollover, but only once — when you roll over the last image that was pulled in from the RSS feed and into the for loop. It does not apply to any of the other images. It seems like the functionality on the other images is created but them somehow instantly destroyed or overwritten as the for loop continues to run and the MovieClipListener updates itself. But I am not sure.

       

      If this were simply a series of movie clips or images being pulled in from the Flash library, I wouldn't have this problem. However, the external images and the MovieClipLoader are confusing things.

       

      Have you run into a similar issue before? Any ideas of another way I should look at this?

       

      An abbreviated version of the code I'm working with is below. Thanks in advance for any advice you can provide...

       

       

      Grant

       

       

        //START FOR LOOP PULLING FROM XML FILE  {.... ---------------------------------------------------------
       
        //create movie clip that will hold next image pulled in from XML file
        var cImageHolder:MovieClip = scrollerBase.createEmptyMovieClip("imageHolder" + i + whichRow, scrollerBase.getNextHighestDepth());
       
         var mcLoader:MovieClipLoader = new MovieClipLoader();//create the Movie Clip Loader
         var mclListener:Object = new Object(); //create the Listener
         mcLoader.addListener(mclListener); //attach the Listener to the Loader
       

         //now load the external image into the empty movie clip generated above

         mcLoader.loadClip(nameOfImageToLoad, cImageHolder); //1st parameter is a predetermined String; 2nd parameter is mc to load image into
        
         
        
         mclListener.onLoadComplete = function( ) {     

                //the function below should be getting applied to every image in the scroller,

                 //but it is only getting applied to the last one read from the XML file
       

                     functionality(cImageHolder); //establish the functionality on the image
             

                 }

       


        
        // } ...END FOR LOOP------------------------------------------------------------------------------------- -------------------------

       


       
      function functionality(mc:MovieClip){
             mc.onRollOver = function(){
                  trace("SUCCESS");
                 }
           }