ITeye博客

flash 移动文字 改进

hwpok · 2009-09-12 18:55 · FLASH · Markdown

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.text.TextField;

    public class MovingText extends Sprite
    {
        private var txt:TextField;
        private var info:String;
        private var ti:uint;
        
        public function MovingText()
        {
            txt = new TextField();
            txt.width =100;
            txt.textColor=0xffff00;
            txt.selectable=false;
            
            txt.x=10;
            txt.y=100;
            this.addChild(txt);
            
            info="There is not way that a bee cound bee able to fly";
            info += "Their wings are too small to get it's fat little body off the ground.";
            
            ti=0;
            this.stage.frameRate=10;
            this.addEventListener(Event.ENTER_FRAME,enterFrame);
        }
        
        public function enterFrame(e:Event):void
        {
            txt.text = info.substr(++ti,20);
            if(ti>=info.length)
            {
                 ti=0;
            }
        }
    }
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。