我在使用 Flex 4.6 时遇到了一个非常奇怪的错误,其中包含一段非常简单的代码。
for ( var j=0 ; j< chip_num; j++)
{
isoChip = new IsoChip();
//isoChip.type=(IsoChip.YELLOW_CHIP); //<<<<<<<<<DOESNOT WORK HERE
isoChip.scaleX = isoChip.scaleY=1//0.45 ;
isoChip.x= i + 10 * i + 5 ;
isoChip.y= y_num;
addElement(isoChip);
isoChip.type=(IsoChip.YELLOW_CHIP); //<<<<<<<<<<<<<<WORKS HERE ONLY
y_num = y_num - 2.5 //IsoChip.height ;
}
拥有这个组件:IsoChip.mxml 组件
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="23" height="20" initialize="init()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
public static const BLUE_CHIP:String = "blueChip" ;
public static const BLACK_CHIP:String = "blackChip" ;
public static const YELLOW_CHIP:String = "yellowChip" ;
public function init(type_val_str="blueChip")
{
blueChip.visible= false;
blackChip.visible =false ;
yellowChip.visible = false ;
//type = type_val_str ;
}
function set type(type_val_str:String)
{
switch( type_val_str)
{
case IsoChip.BLUE_CHIP:
trace(">",IsoChip.BLUE_CHIP)
blueChip.visible = true;
blackChip.visible = false ;
yellowChip.visible = false ;
break;
case IsoChip.BLACK_CHIP:
trace(">",IsoChip.BLACK_CHIP)
blueChip.visible = false ;
blackChip.visible = true ;
yellowChip.visible = false ;
break;
case IsoChip.YELLOW_CHIP:
trace(">",IsoChip.YELLOW_CHIP)
blueChip.visible = false;
blackChip.visible = false ;
yellowChip.visible = true;
break;
}
}
]]>
</fx:Script>
<s:SWFLoader id="blueChip" x="0" y="0" width="23" height="20" source="../swf/blue-iso-chip.swf"/>
<s:SWFLoader id="yellowChip" x="-16" y="5" width="23" height="20" source="../swf/yellow-iso-chip.swf"/>
<s:SWFLoader id="blackChip" x="4" y="9" width="23" height="20" source="../swf/black-iso-chip.swf"/>
</s:Group>
真的是bug吗。还是我做错了什么??