0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[ActionScript][mx]スライダードラッグ中にツールチップのスタイルを更新する

Last updated at Posted at 2014-10-20

解決したい課題

スライダーのツールチップのスタイルは、以下の用に適用できる。

<fx:Style>
  .myDataTipStyle { ... }
</fx:Style>

mx.controls.HSlider(slider).dataTipStyleName = "myDataTipStyle";

しかし、スライダーのつまみをドラッグ中に上記スタイルを変更しても、ツールチップのスタイルは変更されない。

HSlider(event.currentTarget).dataTipStyleName = "otherStyle";

解決策

ドラッグイベントをハンドルして、直接ツールチップオブジェクトにスタイルを適用する。
サンプル:

slider.addEventListener(SliderEvent.THUMB_DRAG, function(event:SliderEvent):void
{
  var toolTips:IChildList = HSlider(event.currentTarget).systemManager.toolTipChildren;
  var datatip:SliderDataTip = toolTips.getChildAt(0) as SliderDataTip;
  datatip.styleName = "otherStyle";
}

補足

mx.controls.sliderClasses.Sliderの実装をみると解るように、ツールチップオブジェクトの生存期間は、つまみを押下(onThumbPress)してリリース(onThumbRelease)するまで。
ドラッグ中にテキスト等を更新しているが、Sliderに登録(dataTipStyleName)したスタイルが渡されていない。初期化時(onThumbPress)のみ。
従って、いくらSliderに対してツールチップのスタイルを更新しても更新されない結果となる。

(※sparkの方を使え、というのは無しで)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?