0

我已经索引了图像,如下所示:

<s:Image id="imgListaTaskAnalysis0" left="20" top="110" width="200" height="200"/>
<s:Image id="imgListaTaskAnalysis1" left="20" top="360" width="200" height="200"/>
<s:Image id="imgListaTaskAnalysis2" left="20" top="360" width="200" height="200"/> 

等等..

我想把它们放在一个数组中,所以:

public var arrayImg:Array = new Array(imgListaTaskAnalysis0,imgListaTaskAnalysis1,imgListaTaskAnalysis2);

但我不能给他们一个来源:

for(var i:Number=0;i<=arrayImg.length;i++)
                arrayImg[i].source = cuboImmagini.path;

这种方式行不通,不给他们任何来源..有办法做到这一点吗?

这是我项目中感兴趣的部分:

public var arrayImg:Array = new Array(imgListaTaskAnalysis0,imgListaTaskAnalysis1);
/*          DICHIARAZIONE IMMAGINI          */
public var cuboImmagini:Object = {path:"../assets/cuboImmagini.png"};
public var exit:Object = {path:"../assets/exit.png"};
public var home:Object = {path:"../assets/home.png"};
/*          FINE DICHIARAZIONE IMMAGINI     */

/*          FUNZIONI            */

//  cambiaPagina
public function cambiaPagina(prossimaPagina:String):void
{   
currentState = prossimaPagina;
}

// chiudiApplicazione
protected function chiudiApplicazione(event:MouseEvent):void    
{
NativeApplication.nativeApplication.exit();
}
public function carica():void
        {
            arrayImg[0].source = cuboImmagini.path;
            arrayImg[1].source = home.path;
            cambiaPagina("HomePage");
        }
        /*          FINE FUNZIONI       */
    ]]>
</fx:Script>
<s:states>
    <s:State name="PaginaPresentazione"/>
    <s:State name="HomePage"/>
    <s:State name="ListaTaskAnalysis"/>
    <s:State name="ScegliAzioneTaskAnalysis"/>
</s:states>
<fx:Declarations>
</fx:Declarations>


    <!-- =================================== MXML =================================== -->

    <!-- =================================== PaginaPresentazione =================================== -->
<s:Group id="gruppoPaginaPresentazione" includeIn="PaginaPresentazione" left="0" right="0" top="0" bottom="0"
         horizontalCenter="0" verticalCenter="0">
    <s:Button id="btnPresentazione" right="10" bottom="10" label="INIZIA"
              click="carica()"/>
</s:Group>
    <!-- =================================== HomePage =================================== -->
<s:Group id="gruppoHomePage" includeIn="HomePage,PaginaPresentazione" left="0" right="0" top="0"
         bottom="0" horizontalCenter="0" verticalCenter="0">

    <s:Button id="btnVaiTaskAnalysis" includeIn="HomePage" width="600" height="90"
              label="TASK ANALYSIS" click="cambiaPagina('ListaTaskAnalysis')" fontSize="50"
              horizontalCenter="0" verticalCenter="80"/>
    <s:Button id="btnVaiStorieSociali" includeIn="HomePage" width="600" height="90"
              label="STORIE SOCIALI" fontSize="50" horizontalCenter="0" verticalCenter="-80"/>

</s:Group>
    <!-- =================================== /HomePage =================================== -->

<s:Group id="gruppoListaTaskAnalysis" includeIn="ListaTaskAnalysis" left="0" right="0" top="0" bottom="0"
         horizontalCenter="0" verticalCenter="0">
    <s:Group id="gruppoBottoniListaTaskAnalyis" left="0" right="0" top="0" height="90"
             horizontalCenter="0">
        <s:Button id="btnExitListaTaskAnalysis" right="10" top="5" width="80" height="80"
                  icon="assets/exit.png"  click="chiudiApplicazione(event)"/>
        <s:Button id="btnHomeListaTaskAnalysis" right="100" top="5" width="80" height="80"
                  icon="assets/home.png" click = "cambiaPagina('HomePage')"/>
    </s:Group>
    <s:Image id="imgListaTaskAnalysis0" left="20" top="110" width="200" height="200"
             source="assets/cuboImmagini.png"/>
    <s:Image id="imgListaTaskAnalysis1" left="20" top="360" width="200" height="200"/>
    <s:Button id="btnSegreto1" left="10" bottom="10" width="90" height="90" alpha="0.1" click="combinazioneSegreta(1)"/>
    <s:Button id="btnSegreto2" right="10" bottom="10" width="90" height="90" alpha="0.1" click="combinazioneSegreta(2)"/>

</s:Group>
<s:Group id="gruppoListaTaskAnalysis0" includeIn="ScegliAzioneTaskAnalysis" left="0" right="0"
         top="0" bottom="0" horizontalCenter="0" verticalCenter="0">
    <s:Group id="gruppoBottoniListaTaskAnalyis0" left="0" right="0" top="0" height="90"
             horizontalCenter="0">
        <s:Button id="btnExitScegliAzioneTaskAnalysis0" right="10" top="5" width="80" height="80"
                  icon="assets/exit.png"  click="chiudiApplicazione(event)"/>
        <s:Button id="btnHomeScegliAzioneTaskAnalisys" right="100" top="5" width="80" height="80"
                  icon="assets/home.png" click = "cambiaPagina('HomePage')"/>
    </s:Group>

</s:Group>
    <!-- =================================== /HomePage =================================== -->

提前致谢..

4

1 回答 1

0

我解决了这个问题。我在创建图像时将它们放入数组中:

<s:Image id="img" creationComplete = "loadImage(event,this.img,0) />
---------------------------------------------------------------------
public function loadImage(e:FlexEvent,img:Image,num:Number):void
{
  array[num] = img;
}

不管怎么说,还是要谢谢你..

于 2012-08-06T12:21:17.913 回答