套件 | flashx.textLayout.elements |
類別 | public final class LinkState |
繼承 | LinkState Object |
語言版本: | ActionScript 3.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
linkState
屬性定義一組常數。
相關 API 元素
公用常數
常數 | 定義自 | ||
---|---|---|---|
ACTIVE : String = "active" [靜態]
作用中狀態的值,當您在連結上方按住滑鼠時,即會產生此狀態。 | LinkState | ||
HOVER : String = "hover" [靜態]
停留狀態的值,而當您在連結上方拖曳滑鼠時,即會產生此狀態。 | LinkState | ||
LINK : String = "link" [靜態]
正常 (預設連結狀態) 的值。 | LinkState |
常數詳細資訊
ACTIVE | 常數 |
public static const ACTIVE:String = "active"
語言版本: | ActionScript 3.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
作用中狀態的值,當您在連結上方按住滑鼠時,即會產生此狀態。
HOVER | 常數 |
public static const HOVER:String = "hover"
語言版本: | ActionScript 3.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
停留狀態的值,而當您在連結上方拖曳滑鼠時,即會產生此狀態。
LINK | 常數 |
public static const LINK:String = "link"
語言版本: | ActionScript 3.0 |
執行階段版本: | Flash Player 10, AIR 1.5 |
正常 (預設連結狀態) 的值。
範例 如何使用本範例
LinkStateExample.as
此範例會將事件偵聽程式新增至 LinkElement,以偵聽下列滑鼠事件:CLICK、MOUSE_DOWN、MOUSE_OUT、ROLL_OVER、ROLL_OUT。發生上述其中一種事件時,此範例會確認連結是否處於停留狀態。如果是,則會顯示事件類型及
linkState
值。
package flashx.textLayout.elements.examples { import flash.display.Sprite; import flash.events.MouseEvent; import flashx.textLayout.container.ContainerController; import flashx.textLayout.elements.LinkElement; import flashx.textLayout.elements.LinkState; import flashx.textLayout.elements.ParagraphElement; import flashx.textLayout.elements.SpanElement; import flashx.textLayout.elements.TextFlow; import flashx.textLayout.events.FlowElementMouseEvent; import flashx.textLayout.formats.TextLayoutFormat; public class LinkStateExample extends Sprite { public function LinkStateExample() { var textFlow:TextFlow = new TextFlow(); var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat(); textLayoutFormat.fontFamily = "Arial, Helvetica, _sans"; textLayoutFormat.fontSize = 18; textFlow.hostFormat = textLayoutFormat; var p:ParagraphElement = new ParagraphElement(); var span:SpanElement = new SpanElement(); var link:LinkElement = new LinkElement(); link.addEventListener(MouseEvent.CLICK, checkState); link.addEventListener(MouseEvent.MOUSE_DOWN, checkState); link.addEventListener(MouseEvent.MOUSE_UP, checkState); link.addEventListener(MouseEvent.ROLL_OVER, checkState); link.addEventListener(MouseEvent.ROLL_OUT, checkState); span.text = "Text that includes a link to "; link.href = "http://www.adobe.com"; var linkSpan:SpanElement = new SpanElement(); linkSpan.text = "Adobe's website"; link.addChild(linkSpan); p.addChild(span); p.addChild(link); textFlow.addChild(p); textFlow.flowComposer.addController(new ContainerController(this,stage.stageWidth, stage.stageHeight)); textFlow.flowComposer.updateAllControllers(); } public function checkState(event:FlowElementMouseEvent):void { var link:LinkElement = LinkElement(event.flowElement); if(link.linkState == LinkState.HOVER) { trace("Event type is: " + event.type); trace("Link state is: " + link.linkState); } } } }
Tue Jun 12 2018, 03:47 PM Z