Re: [Flashcoders] Inspectable parameters ignored in my 1st component
Implicit getter/setters are called *before* the constructor of the class. This allows you to set properties in the initObj (the last parameter) when using attachMovie var bubble = attachMovie("Bubble", "bubble_mc", getNextHighestDepth(), {text:"Hello World"}); regards, Muzak - Original Message - From: "Alexander Farber" <[EMAIL PROTECTED]> To: Sent: Sunday, March 18, 2007 2:46 PM Subject: Re: [Flashcoders] Inspectable parameters ignored in my 1st component > Thanks, I see - > > On 3/18/07, Michael Boski <[EMAIL PROTECTED]> wrote: >> what you want to do is add an inittext varible to hold the param until >> you finish initializing you text box and then push it in. >> >> this code works/ I tested it. >> >> the lines I added are 3 and have "// line added MOB" at the end of them. > >> private function createChildren():Void { >> rect_mc = this.createEmptyMovieClip('rect_mc', >> this.getNextHighestDepth()); >> text_txt = this.createTextField('text_txt', >> this.getNextHighestDepth(), 0, 0, 20, 20); >> text_txt.autoSize = true; >> text_txt.text = inittext; // line added MOB >> size(); >> } > >> [Inspectable(defaultValue="Set in TestCase.as - does not work", >> type='String')] >> public function set text(str:String):Void { >> inittext = str; // line added MOB >> text_txt.text = str; >> invalidate(); >> } > > - the text_txt is undefined when the set text() function > is called for the 1st time. I wonder what is the order > of how the functions are getting called: > > parameters from comp. inspector are being set > init() is called > createChildren() > and then? size(), draw()? > > Regards > Alex ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Inspectable parameters ignored in my 1st component
Thanks, I see - On 3/18/07, Michael Boski <[EMAIL PROTECTED]> wrote: what you want to do is add an inittext varible to hold the param until you finish initializing you text box and then push it in. this code works/ I tested it. the lines I added are 3 and have "// line added MOB" at the end of them. private function createChildren():Void { rect_mc = this.createEmptyMovieClip('rect_mc', this.getNextHighestDepth()); text_txt = this.createTextField('text_txt', this.getNextHighestDepth(), 0, 0, 20, 20); text_txt.autoSize = true; text_txt.text = inittext; // line added MOB size(); } [Inspectable(defaultValue="Set in TestCase.as - does not work", type='String')] public function set text(str:String):Void { inittext = str; // line added MOB text_txt.text = str; invalidate(); } - the text_txt is undefined when the set text() function is called for the 1st time. I wonder what is the order of how the functions are getting called: parameters from comp. inspector are being set init() is called createChildren() and then? size(), draw()? Regards Alex ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Inspectable parameters ignored in my 1st component
what you want to do is add an inittext varible to hold the param until you finish initializing you text box and then push it in. this code works/ I tested it. the lines I added are 3 and have "// line added MOB" at the end of them. MIke boski.com import mx.core.UIComponent; /* simple component, a text field inside of yellow rectangle */ class TestCase extends UIComponent { static var symbolName:String = 'TestCase'; static var symbolOwner:Object = TestCase; var className:String = 'TestCase'; public var inittext:String; // line added MOB private var bb_mc:MovieClip; private var rect_mc:MovieClip; private var text_txt:TextField; function TestCase() { } private function init():Void { super.init(); bb_mc.unloadMovie(); } private function createChildren():Void { rect_mc = this.createEmptyMovieClip('rect_mc', this.getNextHighestDepth()); text_txt = this.createTextField('text_txt', this.getNextHighestDepth(), 0, 0, 20, 20); text_txt.autoSize = true; text_txt.text = inittext; // line added MOB size(); } // invoked when component is resized private function size():Void { super.size(); invalidate(); } // called after invalidate() private function draw():Void { super.draw(); var w = text_txt.textWidth + 16; var h = text_txt.textHeight + 16; //trace(text_txt.text + ': ' + w + ' x ' + h); with (rect_mc) { clear(); lineStyle(0, 0x00, 100); beginFill(0x66, 100); moveTo(0, 0); lineTo(w, 0); lineTo(w, h); lineTo(0, h); lineTo(0, 0); endFill(); } } [Inspectable(defaultValue="Set in TestCase.as - does not work", type='String')] public function set text(str:String):Void { inittext = str; // line added MOB text_txt.text = str; invalidate(); } public function get text():String { return text_txt.text; } } On 3/18/07, Alexander Farber <[EMAIL PROTECTED]> wrote: Hello Nel and others, On 3/14/07, Johannes Nel <[EMAIL PROTECTED]> wrote: > [Inspectable(defaultValue="8", type="Number")] > > On 3/14/07, Alexander Farber <[EMAIL PROTECTED]> wrote: > > I'm trying to create a component representing a comic-like > > chat bubble and while it mostly functions fine, > > I have a problem, that the 2 parameters here are ignored > > (full source code: http://preferans.de/flash/Bubble.as ): sorry it takes me sometime to reply, because I only do flash at weekends and evenings when I have time. Your suggestion unfortunately doesn't help anything. I have prepared a simple test case - a simple component, with a text field inside a yellow rectangle. There is 1 inspectable value - "text", changed by 2 set/get functions. My problem is that eventhough I see the "text" in the component inspector (Alt-F7), changing the value there doesn't have any effect, the initial text isn't displayed: import mx.core.UIComponent; /* simple component, a text field inside of yellow rectangle */ class TestCase extends UIComponent { static var symbolName:String = 'TestCase'; static var symbolOwner:Object = TestCase; var className:String = 'TestCase'; private var bb_mc:MovieClip; private var rect_mc:MovieClip; private var text_txt:TextField; function TestCase() { } private function init():Void { super.init(); bb_mc.unloadMovie(); } private function createChildren():Void { rect_mc = this.createEmptyMovieClip('rect_mc', this.getNextHighestDepth()); text_txt = this.createTextField('text_txt', this.getNextHighestDepth(), 0, 0, 20, 20); text_txt.autoSize = true; //text_txt.text = 'Only this works as default?'; size(); } // invoked when component is resized private function size():Void { super.size(); invalidate(); } // called after invalidate() private function draw():Void { super.draw(); var w = text_txt.textWidth; var h = text_txt.textHeight; //trace(text_txt.text + ': ' + w + ' x ' + h); with (rect_mc) { clear(); lineStyle(0, 0x00, 100); beginFill(0x66, 100); moveTo(0, 0);
Re: [Flashcoders] Inspectable parameters ignored in my 1st component
Hello Nel and others, On 3/14/07, Johannes Nel <[EMAIL PROTECTED]> wrote: [Inspectable(defaultValue="8", type="Number")] On 3/14/07, Alexander Farber <[EMAIL PROTECTED]> wrote: > I'm trying to create a component representing a comic-like > chat bubble and while it mostly functions fine, > I have a problem, that the 2 parameters here are ignored > (full source code: http://preferans.de/flash/Bubble.as ): sorry it takes me sometime to reply, because I only do flash at weekends and evenings when I have time. Your suggestion unfortunately doesn't help anything. I have prepared a simple test case - a simple component, with a text field inside a yellow rectangle. There is 1 inspectable value - "text", changed by 2 set/get functions. My problem is that eventhough I see the "text" in the component inspector (Alt-F7), changing the value there doesn't have any effect, the initial text isn't displayed: import mx.core.UIComponent; /* simple component, a text field inside of yellow rectangle */ class TestCase extends UIComponent { static var symbolName:String = 'TestCase'; static var symbolOwner:Object = TestCase; var className:String = 'TestCase'; private var bb_mc:MovieClip; private var rect_mc:MovieClip; private var text_txt:TextField; function TestCase() { } private function init():Void { super.init(); bb_mc.unloadMovie(); } private function createChildren():Void { rect_mc = this.createEmptyMovieClip('rect_mc', this.getNextHighestDepth()); text_txt = this.createTextField('text_txt', this.getNextHighestDepth(), 0, 0, 20, 20); text_txt.autoSize = true; //text_txt.text = 'Only this works as default?'; size(); } // invoked when component is resized private function size():Void { super.size(); invalidate(); } // called after invalidate() private function draw():Void { super.draw(); var w = text_txt.textWidth; var h = text_txt.textHeight; //trace(text_txt.text + ': ' + w + ' x ' + h); with (rect_mc) { clear(); lineStyle(0, 0x00, 100); beginFill(0x66, 100); moveTo(0, 0); lineTo(w, 0); lineTo(w, h); lineTo(0, h); lineTo(0, 0); endFill(); } } [Inspectable(defaultValue="Set in TestCase.as - does not work", type='String')] function set text(str:String):Void { text_txt.text = str; invalidate(); } function get text():String { return text_txt.text; } } Full source code is here: http://preferans.de/flash/ Thank you for any comments Alex ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] Inspectable parameters ignored in my 1st component
[Inspectable(defaultValue="8", type="Number")] On 3/14/07, Alexander Farber <[EMAIL PROTECTED]> wrote: Hello Flash coders, I'm trying to create a component representing a comic-like chat bubble and while it mostly functions fine, I have a problem, that the 2 parameters here are ignored (full source code: http://preferans.de/flash/Bubble.as ): class Bubble extends UIComponent { ... private var __padding:Number = 8; public var text_txt:TextField; ... private function createChildren():Void { ... text_txt = this.createTextField('text_txt', this.getNextHighestDepth(), 0, 0, 200, 20); with (text_txt) { multiline = true; autoSize = true; //text = 'Only this works as default?'; } size(); } ... [Inspectable(defaultValue=8)] function set padding(val:Number):Void { __padding = val; text_txt._x = text_txt._y = __padding / 2; invalidate(); } function get padding():Number { return __padding; } [Inspectable(defaultValue='Set in Bubble.as')] function set text(str:String):Void { text_txt.text = str; if (interval != 0) clearInterval(interval); interval = setInterval(this, 'hide', timeout * 1000); _visible = true; invalidate(); } function get text():String { return text_txt.text; } } What I mean by "ignored" is that regardless of which values I enter into the Component Inspector (Alt+F7) for "padding" and "text" - only the values from Bubble.as will be taken (please see above): private var __padding:Number = 8; //text = 'Only this works as default?'; Does anybody have an idea what am I doing wrong here? All files are at http://preferans.de/flash/ Thank you. Regards Alex ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- j:pn http://www.lennel.org ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Inspectable parameters ignored in my 1st component
Hello Flash coders, I'm trying to create a component representing a comic-like chat bubble and while it mostly functions fine, I have a problem, that the 2 parameters here are ignored (full source code: http://preferans.de/flash/Bubble.as ): class Bubble extends UIComponent { ... private var __padding:Number = 8; public var text_txt:TextField; ... private function createChildren():Void { ... text_txt = this.createTextField('text_txt', this.getNextHighestDepth(), 0, 0, 200, 20); with (text_txt) { multiline = true; autoSize = true; //text = 'Only this works as default?'; } size(); } ... [Inspectable(defaultValue=8)] function set padding(val:Number):Void { __padding = val; text_txt._x = text_txt._y = __padding / 2; invalidate(); } function get padding():Number { return __padding; } [Inspectable(defaultValue='Set in Bubble.as')] function set text(str:String):Void { text_txt.text = str; if (interval != 0) clearInterval(interval); interval = setInterval(this, 'hide', timeout * 1000); _visible = true; invalidate(); } function get text():String { return text_txt.text; } } What I mean by "ignored" is that regardless of which values I enter into the Component Inspector (Alt+F7) for "padding" and "text" - only the values from Bubble.as will be taken (please see above): private var __padding:Number = 8; //text = 'Only this works as default?'; Does anybody have an idea what am I doing wrong here? All files are at http://preferans.de/flash/ Thank you. Regards Alex ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com