マウスがコンポーネントの別の部分に移動したときに、さまざまなことを示すツールチップが必要です。たとえば、コンポーネントの上半分の場合は、1つのツールチップが表示されます。マウスがセグメントの下半分にある場合、ツールチップは別のものになります。私は文字列を含むパネルを返すように書かれたコードをいくつか持っています。このコードは別のコンピュータにありますので、明日はコードを投稿します。アクションスクリプトのコンポーネントのさまざまな部分のツールチップ
セグメントの異なる部分について、ActionScriptで異なるツールチップ(ツールチップ内で異なる値)を使用することは可能ですか?
私がこれまで持っているコードは次のとおりです。
MyToolTip.mxml
<?xml version="1.0"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"
implements="mx.core.IToolTip"
alpha=".9" width="325" borderColor="black" borderStyle="solid"
cornerRadius="10" horizontalAlign="center">
<mx:Script><![CDATA[
[Bindable]
public var toolTipText:String = "";
public var _text:String;
[Bindable]
public function get text():String { return _text; }
public function set text(value:String):void {}
]]></mx:Script>
<mx:HBox width="100%" height="100%">
<mx:Text text = "Text here" width = "50%"/>
<mx:Text text = "{toolTipText}" width = "50%"/>
</mx:HBox>
</mx:Panel>
そして私は、ツールチップが反対になりたい私のアクションスクリプトクラスコンポーネント。
public class MyComponent extends mx.containers.VBox {
private var tt:MyToolTip
public function MyComponent() {
this.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, toolTipCreateHandler);
this.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
tt = new MyToolTip();
}
override protected function drawFigure():void {
//Need to kick the TOOL_TIP_CREATE event...and needs to be a value (eg a SPACE).
//If blank then no tooltip is created
this.toolTip = " ";
super.drawFigure();
}
private function toolTipCreateHandler(event:ToolTipEvent):void {
var toolTipText:String = "tooltip1";
eventToolTip.toolTipText = toolTipText;
event.toolTip = tt;
}
private function mouseOverHandler(event:MouseEvent):void {
//perhaps I need to be more efficient here and only fire
//when the mouse goes into top half or bottom half
//This does not appear to update the toolTipText in the view
var halfwayUp:Number = getBounds(this).height/2;
if (event.localY < halfwayUp) {
eventToolTip.toolTipText = "tooltip2";
}
else {
eventToolTip.toolTipText = "tooltip1";
}
}
}
}
既に表示されているときにツールチップを更新する方法についてのヘルプや説明は素晴らしいものです。
フレックスやフラッシュなどのコンポーネントフレームワークは使用していますか? –
次へ:2つのツールチップの違いは何ですか?ちょうどテキストや色、形やその他のもの? –
ツールチップはフラッシュコンポーネントにあります。私のコードは別のコンピュータ上にあるので、申し訳ありませんが、正確なコンポーネントを覚えていません。コンポーネントの内容は単なるテキストです。私はそれがうまくフォーマットされるように、パネル上にテキストのリストを入れています。基本的にはキーと値のペアの束です。キーと値のペアは、マウスがコンポーネント上をホバーする場所によって異なります。 – RNJ