Flash Builder 4 -> RichEditableText

Posted by muchag | ActionScript 3.0,Flash Builder 4 |
初回投稿:2010-07-19 (月) 5:11:58 | 最終更新:2010-07-25 (日) 2:22:59

HTML タグの反映

[mxml][/mxml]

Actionscript 3.0 on Flex 4

  1. import flashx.textLayout.conversion.TextConverter;
  2. import flashx.textLayout.elements.Configuration;
  3. import flashx.textLayout.elements.TextFlow;
  4. import flashx.textLayout.formats.TextDecoration;
  5. import flashx.textLayout.formats.TextLayoutFormat;
  6.  
  7. private function init():void {
  8.     var txt:String = "Check out our website at <a href='http://blog.flexexamples.com/' target='_top'>flexexamples.com</a>.";
  9.  
  10.     var cfg:Configuration = TextFlow.defaultConfiguration;
  11.  
  12.     var normalFmt:TextLayoutFormat = new TextLayoutFormat(cfg.defaultLinkNormalFormat);
  13.     normalFmt.color = 0xFF0000; // red
  14.     normalFmt.textDecoration = TextDecoration.NONE;
  15.  
  16.     var hoverFmt:TextLayoutFormat = new TextLayoutFormat(cfg.defaultLinkHoverFormat);
  17.     hoverFmt.color = 0xFF00FF; // purple
  18.     hoverFmt.textDecoration = TextDecoration.UNDERLINE;
  19.  
  20.     cfg.defaultLinkNormalFormat = normalFmt;
  21.     cfg.defaultLinkHoverFormat = hoverFmt;
  22.  
  23.     ret.textFlow = TextConverter.importToFlow(txt, TextConverter.TEXT_FIELD_HTML_FORMAT, cfg);
  24. }

Flex Examples:Customizing the appearance or a hyperlink in a TextFlow object in Flex 4
こちらよりの丸パクリ。。。
 

リンクの実装(a タグ)
Actionscript 3.0 on Flex 4

  1. import flashx.textLayout.elements.LinkElement;
  2. import flashx.textLayout.events.FlowElementMouseEvent;
  3. import mx.controls.Alert;
  4.  
  5. private function init():void {
  6.     var myString:String = "検索サイト:<a href="http://www.google.com/">Google</a>";
  7.     myString.replace(/^<a href=(^.*$)>$/, "<a href=$1 click=\"linkElement_clickHandler(event);\">");
  8.  
  9.     var myRichEditableText:RichEditableText = new RichEditableText();
  10.     myRichEditableText.text = myString;
  11. }
  12.  
  13. protected function linkElement_clickHandler(event:FlowElementMouseEvent):void {
  14.     var linkEl:LinkElement = event.flowElement as LinkElement;
  15.     event.stopImmediatePropagation();
  16.     event.preventDefault();
  17. }

<参考サイト>
Flex Examples:Creating a LinkElement in a Spark RichEditableText control in Flex 4
 

テキストの折り返し

width プロパティを設定しないと折り返しは実現しない。

Posted by muchag | ActionScript 3.0,Flash Builder 4 |
初回投稿:2010-07-19 (月) 5:11:58 | 最終更新:2010-07-25 (日) 2:22:59

コメントはまだありません »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment