I am having a problem with adding a text field to an attached movieClip
through a class construct using composition.

For example:

class Tab {
    public var label_txt:TextField;
    public var tab_fmt:TextFormat;
    
    public function Tab(name:String, target:MovieClip, depth:Number,
x:Number, y:Number) {
        tab_mc = target.attachMovie("Tab", name, depth);
    }

    public function addText():Void {

        //Text Format for buttons
        tab_mc.tab_fmt = new TextFormat();
        tab_mc.tab_fmt.font = "ArialBold";
        tab_mc.tab_fmt.color = 0x000000;
        tab_mc.tab_fmt.size = 11;
        
        tab_mc.createTextField("label_txt", 20, 0, 0, 0, 0);
        tab_mc.label_txt.border = true;
        tab_mc.label_txt.autoSize = true;
        tab_mc.label_txt.multiline = false;
        tab_mc.label_txt.text = "Test String";
        tab_mc.label_txt.antiAliasType = "advanced";
        tab_mc.label_txt.embedFonts = true;
        tab_mc.label_txt.setTextFormat(tab_fmt);

    }
    
    public function setPosition(x:Number, y:Number):Void {
        tab_mc._x = x;
        tab_mc._y = y;
    }
    
}

For testing this, I created an instance of the class on frame 1 then a few
frames later, I have tried both of the two methods. The "setPosition" method
works handily, but that text field simply refuses to exist.

The "addText" method works fine when the class extends MovieClip and the
target is set to "this". . . So what is it that I am doing wrong or don't
quite understand?

Thanks

Dennis
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to