scrollpane (與所有 List 系元件) 自動捲動小技巧

In actionscript   September 28, 2005 - 11:57 am

今天遇到一個小問題,我希望當scrollpane裏面的項目增加時,scrollbar能自動捲到最底部。

結果把手冊翻一遍只找到 vPosition 可以控制 scrollbar的垂直位置,但沒說該怎麼定位到最底部。

後來想想不對,既然 textarea之類的元件能用 maxVPosition 與 maxHPosition兩個屬性,那mm沒有理由不在所有List系 (List, Combobox, DataGrid, Tree, Scrollpane)組件都加入這個屬性,因此我就實驗性質的打了:

Actionscript:
  1. sp.vPosition = sp.maxVPosition;

結果立刻成功,只要加上eventlisetener就可以在內容變動時自動捲動。

後來我順便用 maxVPosition 當關鍵字查了mm online doc與flashcoder,發現online doc裏仍然完全沒提,但flashcoder則有一篇討論,可見知道這招的人不多啊~(只是自動捲動不該是List元件最基本也最重要的功能之一嗎?怎麼會變成undocumented feature ?)

by admin

留言回應

hidden

您的留言會先經過站長認証後才刊登在網站上。
your comments will be approved by Administrator before appearing on the page.

Trackback this post  |  Subscribe to the comments via RSS Feed

mobile phone