【问题标题】:How I can access in Actionscript the "text" property of a TLF text created in the Flash IDE如何在 Actionscript 中访问在 Flash IDE 中创建的 TLF 文本的“文本”属性
【发布时间】:2010-10-01 17:05:54
【问题描述】:

我在主文档中使用 Flash IDE 创建了 TLF 文本。
我已经使用 IDE 为其分配了一个实例名称

当我尝试使用 Actionscript 访问文本时,我无法访问文本字段。
当然,如果我在 IDE 中转换经典动态文本中的文本,它会按预期工作

我觉得自己很愚蠢,我怀疑它有一个明显的解决方案,但我找不到任何关于该主题的信息

// instance name is "myText"

trace(this.myText);
>> null

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

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

【问题讨论】:

    标签: flash actionscript-3 text textfield tlf


    【解决方案1】:

    以下代码可能会有所帮助。

    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
    

    【讨论】:

    【解决方案2】:

    我认为你在学习 Flash 课程。

    我无法访问 Flash 类代码上的 TLF Text 实例,但它可以在框架中的 ActionScript 上运行。在 ACTIONS - FRAME 中编辑代码。

    【讨论】:

    • 无法将脚本附加到框架,因为我需要从自定义类访问文本。
    猜你喜欢
    • 2015-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多