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 に答える