![](/img/trans.png)
[英]1119: Access of possibly undefined property No through a reference with static type Class
[英]Why is the compiler complaining about a possibly undefined property
我有一個非常簡單的Flex 4(Gumbo)練習程序。
package
{
import mx.controls.ColorPicker;
import mx.controls.Label;
import mx.events.ColorPickerEvent;
import flash.display.Sprite;
public class testClass extends Sprite
{
private var cPicker:ColorPicker = new ColorPicker();
private var lbl:Label;
public function testClass()
{
cPicker.addEventListener(ColorPickerEvent.CHANGE,
colorPicker_change);
cPicker.move(10, 10);
addChild(cPicker);
lbl = new Label();
lbl.text = cPicker.hexValue;
lbl.move(10, 40);
addChild(lbl);
}
private function colorPicker_change(evt:ColorPickerEvent):void
{
lbl.text = cPicker.hexValue; // ff0000
}
}
}
但是在命令行上使用'mxmlc.exe testClass.as'構建之后,我得到...
C:\\ src> mxmlc testClass.as加載配置文件C:\\ flex_sdk_4 \\ frameworks \\ flex-config.xml C:\\ src \\ testClass.as(21):col:32錯誤:通過a訪問可能未定義的屬性hexValue靜態類型為mx.controls:ColorPicker的引用。
lbl.text = cPicker.hexValue; ^
C:\\ src \\ testClass.as(28):col:32錯誤:通過靜態類型為mx.controls:ColorPicker的引用訪問可能未定義的屬性hexValue。
lbl.text = cPicker.hexValue; // ff0000 ^
為什么它認為cPicker是靜態的? 還是那個cPicker.hexValue是未定義的?
而且,即使使用import關鍵字在代碼中導入了ColorPicker庫之后,我似乎也不得不在命令行中將其導入以進行構建。 那是對的嗎?
根據我對文檔的閱讀, hexValue
不是ColorPicker上的可用屬性。 你是說selectedColor
嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.