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, 0x000000, 100);
                        beginFill(0xFFFF66, 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, 0x000000, 100);
                       beginFill(0xFFFF66, 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

_______________________________________________
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

Reply via email to