我只需要知道如何在它newImage.source = "asset/%myArray%";
上面的数组中设置它的源。我确信有一个简单的解决方案。我只是不确定如何在谷歌上表达这个问题......
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete = "init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
//Gabe Dougherty
//n221
//9-27-12
import mx.controls.Image;
//array of movies
public var myArray:Array = ["batman.jpg","cabin.jpg","christmasVaction.jpg","inception,jpg"];
//init function
public function init():void{
//loops 4 times
for(var i:Number = 0; i < myArray.length; i++){
var arrayEntry:String = myArray[i];
//makes new image
var newImage:Image = new Image();
//sets the image source for each image
newImage.source = "asset/%myArray%";
//adds the image to the stage
grpMovies.addElement(newImage);
}
}
]]>
</fx:Script>
<s:HGroup id="grpMovies" x="430" y="61" width="200" height="200">
</s:HGroup>
</s:Application>