6 Replies Latest reply on Jul 9, 2009 10:36 PM by Flex harUI

    Problement with Display object

    bolo972-GhWGNa

      Hello,

       

      With this code i can't show two times same display object

       

      Can you help me ?

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">

      <mx:Script>

      <![CDATA[

       

      private var a:Array = new Array();

      private var b:Array = new Array();

      private var counter:int = 0;

       

      private function init ():void

      {

      a.push("http://dutron.files.wordpress.com/2008/12/sourire-de-cochon.jpg");

      a.push("http://www.lanature.fr/fond-ecran/photos/petit-cochon.jpg");

      a.push("http://www.coloriagesanimaux.net/animaux/cochons/cochon.jpg");

       

      loadSlide();

      }

       

      private function loadSlide():void

      {

      trace("loadSlide");

      var imgLoader:Loader = new Loader()  ;

       

      imgLoader.load (new URLRequest(a[counter]));

      imgLoader.contentLoaderInfo.addEventListener (Event.COMPLETE,imageLoaded);

       

      }

       

       

      private function imageLoaded (e:Event):void

      {

      b.push(e.target.content);

        

      if (counter == (a.length - 1))

      {

      - trace("all slides images");

      }

      else

      {

      counter++;

      loadSlide ();

      }

      }

       

       

      public function showSlide(e:Event):void

      {

      var cLoader:DisplayObject = b[e.currentTarget.selectedIndex];

       

      if(cLoader)

      {

      contentImage.source = cLoader ;

      }

       

      }

       

      ]]>

      </mx:Script>

      <mx:HBox>

      <mx:ComboBox change="showSlide(event)" >

            <mx:ArrayCollection>

               <mx:Object label="AL" data="1"/>

               <mx:Object label="AK" data="2"/>

               <mx:Object label="AR" data="3 Rock"/>

            </mx:ArrayCollection>

         </mx:ComboBox>

      <mx:Image  id="contentImage" />

      </mx:HBox>

       

      </mx:Application>