Contact me off list and I will send you the Fla as files I used. cheers
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dennis Hart Sent: Thursday, January 12, 2006 11:23 AM To: Flashcoders mailing list Subject: Re: [Flashcoders] Adding Texfield to MovieClip via Composition Class Thanks for your help gentlemen. I reread the code that I entered when I started this thread and realized that I did overlook the critical "public var tab_mc;" in this email, however I did in fact have it in my Tab.as file declared as - " private var tab_mc:MovieClip;" - I don't think it would have compiled otherwise. I thought perhaps the 'private' declaration was the problem so I switched it to 'public', but still no text field. Robert - I created a new sandbox, added your class code below then created a new "Tab.fla" in the same folder, added a new MovieClip to the Library named "Tab", exported it for ActionScript: identifier: "Tab" ActionScript 2.0 Class: "Tab" and did the same for the new font "ArialBold" I added to the library - ActionScript 2.0 Class: "ArialBold" Then placed your code. . . var oTxt:Tab = new Tab("howdy",ds, 1); ds.howdy.label_txt.text = "new text"; . . . on frame one of the _root level of the "tab.fla" and I see nothing. . . Btw I am using flash 8. . . Any ideas? I am baffled. > Actually I just tried it and it worked: > class Tab { > public var label_txt:TextField; > public var tab_fmt:TextFormat; > public var tab_mc; > > 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; > } > > } > > And used: > > var oTxt:Tab = new Tab("howdy",ds, 1); > ds.howdy.label_txt.text = "new text"; > > Am I missing the problem? > > Cheers > Robert > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Robert > A. Colvin > Sent: Thursday, January 12, 2006 10:12 AM > To: Flashcoders mailing list > Subject: RE: [Flashcoders] Adding Texfield to MovieClip via Composition > Class > > You will need to use a separate function say : > Public function applyText(name:String, target:MovieClip, depth:Number, > x:Number, y:Number){ > > tab_mc = target.attachMovie("Tab", name, depth); > } > Don't forget if you are attaching this class to the library symbol, the > first time it is used will instantiate the class only once. > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Dennis > Hart > Sent: Thursday, January 12, 2006 10:08 AM > To: Flashcoders mailing list > Subject: [Flashcoders] Adding Texfield to MovieClip via Composition > Class > > 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 > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders