Apache flex 将字符串强制转换为要在flex中修改的图像Id

Apache flex 将字符串强制转换为要在flex中修改的图像Id,apache-flex,string,image,casting,Apache Flex,String,Image,Casting,我正在尝试修改一个图像,它是从字符串中浇铸的: [Embed(source='map.swf', symbol='wZero')] [Bindable] private var wZero:Class; [Embed(source='map.swf', symbol='wOne')] [Bindable] private var wOne:Class; public function setInactiveElements () : void { trace ("setInactiv

我正在尝试修改一个图像,它是从字符串中浇铸的:

[Embed(source='map.swf', symbol='wZero')]
[Bindable]
private var wZero:Class;

[Embed(source='map.swf', symbol='wOne')]
[Bindable]
private var wOne:Class;

public function setInactiveElements () : void {
    trace ("setInactiveElements called");
    inactiveElements : Array = mapMan.getInactiveElements();
    for each ( var element : String in inactiveElements ) {
        trace ("inactiveElement: " + element );
        Image(element).alpha = 0.5;
                // also tried: 
                (element as Image).alpha =  0.5;
    }
}
在inactiveElements数组中有一组ImageID(way_0,way_1,…),我试图设置每个图像的alpha值

<mx:Image source="{wZero}" id="way_0"/>
<mx:Image source="{wOne}" id="way_1"/>

通过跟踪,我得到了正确的ImageId字符串,但转换为图像失败

TypeError:Error#1009:Der Zugriff 本征值法 这是无效的 莫格利奇

你需要:

Image(this[element]).alpha = 0.5;
字符串
永远不能成为
图像
。图像是键入
字符串
元素



如果此解决方案不起作用,请发布更多代码。

太好了!!非常感谢!它起作用了!