Search code examples
flashactionscript-3texttextfieldtlf

How I can access in Actionscript the "text" property of a TLF text created in the Flash IDE


I created a TLF Text with the Flash IDE in the main document.
I've assigned it an instance name with the IDE

When I try to access the text with Actionscript I cannot access the text field.
Of course if I transform in the IDE the text in classic dynamic text it works as expected

I feel very stupid and I suspect it has an obvious solution but I cannot find any info about the subject

// instance name is "myText"

trace(this.myText);
>> null

trace(this.getChildAt(0));    
>> [object Movie Clip]

trace(this.getChildbyName("myText"));
>> null

Solution

  • The following code might be of help.

    var markup:XML = 
        <TextFlow xmlns='http://ns.adobe.com/textLayout/2008'>
            some text...
        </TextFlow>;
    var flow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);
    var sprite:Sprite = new Sprite();
    flow.fontFamily = 'font name...'
    flow.flowComposer.addController(new ContainerController(sprite, width, height));
    flow.flowComposer.updateAllControllers();
    
    parent object.addChild(sprite);
    sprite.x = some
    sprite.y = where