2009-07-29 6 views
1

私のFlexの理解が正しい場合、Flexのスキンは、オブジェクトの視覚的表現を作成するために子としてUIComponentに追加されたDisplayObjectだけです。しかし、Flashイベントモデルを正しく理解していれば、透明でないDisplayObjectが別のDisplayObjectの上にある場合、マウスイベントは一番上のDisplayObjectに移動します。重なったDisplayObjectはマウス入力を受け取りません。スキンされたFlex UIComponentはどのようにマウスイベントをキャプチャしますか?

FlexのUIComponentはスキンとしてどのように機能しますか?

答えて

1

このページでは、Flexでのイベンティングメカニズムのかなり良い説明があります:私は信じている

http://livedocs.adobe.com/flex/3/html/help.html?content=events_08.html

キーはもMouseEventはデフォルトでバブルをするということです。スキン要素はコンポーネントの表示リストの子( "rawChildren"内)として追加されるので、イベントはまだ親にバブルアップします。

0

ホストコンポーネントにMouseEventリスナーを追加することはできます。最も良い例はスキンボタンです。他のボタンのように扱います。

ホストコンポーネント内の個々のスキンコンポーネントにリスナーを追加するものの、より複雑なスキンコンポーネントです。これらのイベントは、ホストコンポーネントにも同様にバブルアップするはずです。

2

コンポーネントによってスキンの部品が追加されるため、グラフィックスをクリックできないようにするための力が与えられます。ButtonBaseクラスを見ると、これを説明するコメントが表示されます。

// DisplayObjectContainer properties. 
    // Setting mouseChildren to false ensures that mouse events 
    // are dispatched from the Button itself, 
    // not from its skins, icons, or TextField. 
    // One reason for doing this is that if you press the mouse button 
    // while over the TextField and release the mouse button while over 
    // a skin or icon, we want the player to dispatch a "click" event. 
    // Another is that if mouseChildren were true and someone uses 
    // Sprites rather than Shapes for the skins or icons, 
    // then we we wouldn't get a click because the current skin or icon 
    // changes between the mouseDown and the mouseUp. 
    // (This doesn't happen even when mouseChildren is true if the skins 
    // and icons are Shapes, because Shapes never dispatch mouse events; 
    // they are dispatched from the Button in this case.) 
関連する問題