Hello,

I had a chat consisting of a text field, a text area and 2 buttons
to scroll the text area up and down. It worked fine.

Then I've decided to put all that stuff together inside of 1 mc,
the AS 2.0 style. Unfortunately the buttons and the mouse
wheel have stopped working and I haven't managed to fix them.

I'm probably missing something very minor. Could someone
please take a look at my code at http://preferans.de/chat/

I'm also pasting my class file here, since it is quite simple:

class Chat extends MovieClip {
        private var field_txt:TextField;
        private var area_txt:TextField;
        private var up_btn:Button;
        private var down_btn:Button;
                        
        public function Chat() {
                // will implement wheel scrolling myself
                this['mouseWheelEnabled'] = false;

                Key.addListener(this);
                Mouse.addListener(this);
                
                update_buttons();
        }
        
        public function onKeyDown() {
                if (Key.getCode() == Key.ENTER &&
                    field_txt.text != '' &&
                    Selection.getFocus() == targetPath(field_txt)) {
                        setText(getText());
                        Selection.setFocus(field_txt);
                }
        }
        
        public function onMouseDown() {
                if (Selection.getFocus() == targetPath(down_btn)) {
                        area_txt.scroll--;
                        update_buttons();
                } else if (Selection.getFocus() == targetPath(up_btn)) {
                        area_txt.scroll++;
                        update_buttons();
                }
        }
        
        public function onMouseWheel(lines:Number) {
                area_txt.scroll -= lines;
                update_buttons();
        }
        
        public function getText():String {
                var str:String = field_txt.text;
                field_txt.text = '';
                return str;
        }
        
        public function setText(str:String) {
                area_txt.scroll = area_txt.maxscroll;
                area_txt.text += newline + str;
        }
        
        private function update_buttons():Void {
                up_btn._visible   = (area_txt.scroll > 1 ? true : false);
                down_btn._visible = (area_txt.scroll < area_txt.maxscroll ? 
true : false);
        }
}

Thank you
Alex

--
http://preferans.de
_______________________________________________
[email protected]
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