包 | 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, 11:04 AM Z