Salut,

pour updater les properties comme scrollH, scrollV, etc..
bref tout ce qui est en rapport avec du scrolling

il faut écouter Event.SCROLL


apres, je pense que ce que tu veux faire c'est un scrolling
automatique sur le bas de page,
pour lire des logs ou afficher une console, etc...

voici un example
-----
package gfx
{
    import flash.events.Event;
    import flash.events.TextEvent;
    import flash.text.AntiAliasType;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.text.TextFormat;

    public class Console extends TextField
    {

        public static var defaultFormat:TextFormat = new TextFormat();
                          defaultFormat.font       = "Courier New";
                          defaultFormat.size       = 10;
                          defaultFormat.color      = 0x555555;

        private var _autoScroll:Boolean;

        public function Console( width:Number = -1, height:Number =
-1, autoScroll:Boolean = false )
        {
            super();

            background      = true;
            backgroundColor = 0xFFFFFF;
            textColor       = 0x555555;
            embedFonts      = false;
            wordWrap        = true;
            selectable      = true;
            antiAliasType   = AntiAliasType.ADVANCED;
            type            = TextFieldType.DYNAMIC;

            if( width > -1 ) { this.width = width; }
            if( height > -1) { this.height = height; }

            _hookEvents();

            this.autoScroll = autoScroll;
        }

        private function _hookEvents():void
        {
            addEventListener( Event.SCROLL, onScroll );
            addEventListener( Event.CHANGE, onChange );
            addEventListener( TextEvent.TEXT_INPUT, onTextInput );
        }

        private function onScroll( event:Event ):void
        {
            trace( "onScroll()" );
            if( autoScroll ) { scrollV = maxScrollV; }
        }

        private function onChange( event:Event ):void
        {
            trace( "onChange()" );
        }

        private function onTextInput( event:TextEvent ):void
        {
            trace( "onTextInput()" );
        }

        public function get autoScroll():Boolean
        {
            return _autoScroll;
        }

        public function set autoScroll( value:Boolean ):void
        {
            _autoScroll = value;
        }

        public function write( message:String, format:TextFormat =
null ):void
        {
            if( format == null )
            {
                format = defaultFormat;
            }

            var startIndex:int = text.length;
            var endIndex:int   = startIndex + message.length;
            appendText( message );
            setTextFormat( format, startIndex, endIndex );
        }

        public function writeLine( message:String, format:TextFormat =
null ):void
        {
            write( message + "\n", format );
        }

    }
}
-----


usage:
-----
package
{
    import flash.display.Sprite;
    import flash.text.TextFormat;

    import gfx.Console;

    [SWF(width="550", height="400", backgroundColor='0xcccccc',
frameRate='24', pageTitle='test', scriptRecursionLimit='1000',
scriptTimeLimit='60')]
    public class console_gui extends Sprite
    {
        public var console:Console;

        private var _errorFormat:TextFormat;

        public function console_gui()
        {
            _errorFormat = new TextFormat();
            _errorFormat.font       = "Courier New";
            _errorFormat.size       = 10;
            _errorFormat.color      = 0xff0000;

            console = new Console( 400, 200, true );

            addChild( console );

            for( var i:uint = 0; i < 30; i++ )
            {
                console.writeLine( "hello world " + i );
            }

            console.writeLine( "end line", _errorFormat );

        }
    }
}

-----


et perso, j'utilise meme pas de var field j'herite direct du TextField
pour ajouter un comportement custom ;)

zwetan

-- 
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes FCNG.
Pour envoyer un message à ce groupe, adressez un e-mail à [email protected].
Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse 
[email protected].
Pour plus d'options, consultez la page de ce groupe : 
http://groups.google.com/group/fcng?hl=fr

Répondre à