Hello!

I'd like to draw a green rectangle underneath 2 TextFields.

As my flash app. will have WIDTH=100% in the HTML-page,
I'd like to handle the eventual resizing of it. For that I've registered
an onResize-listener at the Stage (see the resize() function below).

While resizing works ok for the both TextFields (called area_txt
and field_txt), it fails for the green rectangle: the old rectangle
doesn't get erased. Does anybody please have an advice for me?
I don't see any Stage.clear() method in the help-docs...

I've prepared a complete test case below, please copy-paste it
and resize the movie window and you'll see the problem I have:

createEmptyMovieClip('back_mc', getNextHighestDepth());

createTextField('area_txt', getNextHighestDepth(), 5, 5, 5, 5);
with (area_txt) {
        border = true;
        multiline = true;
        textColor = 0xFFFFFF;
}

createTextField('field_txt', getNextHighestDepth(), 5, 5, 5, 5);
with (field_txt) {
        border = true;
        type = 'input';
        textColor = 0xFFFFFF;
}

resize();

Stage.scaleMode = 'noScale';
var resizeListener:Object = new Object();
resizeListener.onResize = resize;
Stage.addListener(resizeListener);

function resize() {
        trace("Stage size: " + Stage.width + " x " + Stage.height);
        var text_width:Number = 3 * Stage.width / 4;
        var text_left:Number  = 10;
        
        // draw a rectangle with a cut-off corner       
        with (back_mc) {
                _alpha = 50;
                moveTo(text_left + 8, 30);
                lineStyle(0, 0xFFFFFF, 100);
                beginFill(0x008000, 100);
                lineTo(text_left + text_width, 30);
                lineTo(text_left + text_width, 290);
                lineTo(text_left, 290);
                lineTo(text_left, 30 + 8);
                endFill();
        }
        with (area_txt) {
                _x = text_left;
                _y = 30;
                _width = text_width;
                _height = 240;
        }
        with (field_txt) {
                _x = text_left;
                _y = 270;
                _width = text_width;
                _height = 20;
        }
}

Also I wonder, if there is a way to encapsulate the rectangle
drawing code insided the back_mc MovieClip? Then I'd just
have to position it and to change its _width and _height and
wouldn't need to touch its drawing guts (i.e. OOP-encapsulation).

I've tried create a MovieClip symbol and to put this code
into its 1st frame, but that didn't work (nothing was drawn):

                _alpha = 50;
                moveTo(8, 0);
                lineStyle(0, 0xFFFFFF, 100);
                beginFill(0x008000, 100);
                lineTo(_width, 0);
                lineTo(_width, _height);
                lineTo(0, _height);
                lineTo(0, 8);
                endFill();

Thank you
Alex

--
http://preferans.de
_______________________________________________
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