I have Internet

Yeah, I have internet also

  • Blog Random rants
  • Portfolio An showcase of past work
  • Contact Hire Me

July 19, 2010
Posted by admin

TextLayoutFramework Fun

So, I though I would post some findings about the tlf that have been coming up recently in my irc/forums

Problem : Links in the spark TextArea don’t dispatch
Solution : Make sure that you set textArea.mouseChildren=true and/or textArea.textDisplay.mouseChildren = true

Problem : I need to create dynamic elements and append to the main textFlow ( ie chat system)
Solution:

var mainTextFlow:TextFlow

var importer:ITextImporter = TextConverter.getImporter(TextConverter.TEXT_LAYOUT_FORMAT, v);

var flowMarkupToAdd:String=<flow:TextFlow xmlns:flow = 'http://ns.adobe.com/textLayout/2008'>
<flow:div id='container' color='{messageColor}' fontStyle='{fontStyle}' fontSize='{messageSize}' fontFamily='{messageFont}'>{message}</flow:div></flow:TextFlow>;

var newTextFlow:TextFlow = importer.importToFlow(flowMarkupToAdd)
if (importer.errors) // check for errors
			{
				for each (var error:String in importer.errors)
				{
					trace("addLine:: Error", error);

				}

			}

mainTextFlow.addChild(newTextFlow.getElementByID('container').deepCopy()); // deep copy container and add to main text flow

Problem : How do I listen to custom events from a LinkElement?
Solution :

var link:LinkElement = new LinkElement();
link.href="event:helloWorld";
textFlow.addChild(link);
var span:SpanElement = new SpanElement();
span.text="hello";
link.addChild(span);

textFlow.addEventListener("helloWorld",textFlow_clickHandler);

function textFlow_clickHandler(e:FlowElementMouseEvent):void{
var link:LinkElement = LinkElement(e.flowElement);
trace("My Link ",link.getText()) // should output "hello"
}

Hopefully this will help some folks out

No Comments

Posted Under Actionscript

No Comments Yet

You can be the first to comment!

Leave a comment

* = Required

    • Posts
    • Twitter
    • Flickr
     

    Signing A Black...

    Blackberry

     

    ScriptUIFlexSer...

    Uncategorized

     

    TextLayoutFrame...

    Actionscript

    Sorry... I have not linked my Twitter
    to my blog yet
    Sorry... I have not set my Flickr
    account up yet
  • Categories

    • Actionscript
    • Blackberry
      • Playbook
    • Uncategorized
  • Archives

    • 2011
      • January
      • March
      • April
    • 2010
      • January
      • April
      • June
      • July
      • August
      • December

This site is using the Handgloves WordPress Theme
Designed & Developed by George Wiscombe

Subscribe via RSS