次のようなアクションスクリプトでキャンバスを作成しています:
private var cvs_preview:Canvas = null;
private function show_preview():void
{
this.cvs_preview = new Canvas();
this.cvs_preview.id = "cvs_preview_1";
this.cvs_preview.setStyle('backgroundColor', 0x000000);
this.cvs_preview.setStyle('backgroundAlpha', 1);
this.cvs_preview.setStyle('borderColor', 0x417FDD);
this.cvs_preview.setStyle('cornerRadius', 10);
this.cvs_preview.setStyle('borderStyle', 'solid');
this.cvs_preview.setStyle('dropShadowEnabled', true);
var pt:Point = image.localToGlobal(new Point(image.x, image.y));
this.cvs_preview.x = pt.x - 50;
this.cvs_preview.y = pt.y - 50;
this.cvs_preview.height = 200;
this.cvs_preview.width = 250;
//this.cvs_preview.addEventListener(FlexEvent.CREATION_COMPLETE, get_focus_on_canvas);
//this.cvs_preview.focusManager.setFocus(
//this.cvs_preview.addEventListener(MouseEvent.CLICK, end_preview_on_focus_change);
this.cvs_preview.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE, end_preview_on_focus_change);
Application.application.addChild(this.cvs_preview); //add as top-most visible container
btn_mini_preview.enabled = false;
}
したがって、フォーカスの変更時に「end_preview_on_focus_change()」を実行したい
しかし、これは機能していません。
私の理解では、そもそもキャンバスに焦点が合っていないと思います。キャンバスの作成が完了した後、 focusManager.setFocus を使用してそれを実行しようとしていました。それでもエラーが発生します。
Creation.Complete で試していたコードは次のとおりです。
private function get_focus_on_canvas(e:FlexEvent)
{
focusManager.setFocus(e.target);
//Alert.show("testing img complete");
}
これにより、「1118: 関連付けられていない可能性のある型 mx.managers:IFocusManagerComponent への静的型 Object を持つ値の暗黙の強制」というエラーが表示されます。
基本的に、キャンバスのフォーカスアウトイベントを使いたいだけです。
誰かがこれを手伝ってくれますか...私は長い間この問題に取り組んできました。
よろしくジーシャン