Show
Ignore:
Timestamp:
02/19/08 11:56:31 (11 months ago)
Author:
nobu
Message:

ととりあえず動くよ

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Theme-1/nobu/Panel.as

    r10 r11  
    33    import flash.events.Event; 
    44    import flash.text.TextField; 
     5    import flash.text.TextFieldAutoSize; 
    56    import flash.text.TextFormat; 
    67    import lib.display.MovieClipExt; 
     
    89    public class Panel extends MovieClipExt 
    910    { 
    10         public function Panel() 
    11         { 
    12             // do nothing. 
    13         } 
    14  
    15         public function initialize(p_args:Object=null):void 
     11        public function Panel(p_args:Object=null) 
    1612        { 
    1713            p_args = p_args || {}; 
    1814            title.htmlText = '<a href="'+p_args.link+'">'+p_args.title+'</a>'; 
    19             description.text = p_args.description.replace(/\r\n/g, "").replace(/\r/g, "").replace(/\n/g, ""); 
     15            title.autoSize = TextFieldAutoSize.LEFT; 
     16            description.autoSize = TextFieldAutoSize.LEFT; 
     17            description.text = p_args.description 
     18                                     .replace(/\r\n/g, "\n") 
     19                                     .replace(/\r/g, "\n") 
     20                                     .split("\n") 
     21                                     .join('') 
     22                                     .substr(0, 100) + '...'; 
     23        } 
     24 
     25        override protected function wakeUp(evt:Event):void 
     26        { 
     27            addEventListener(Event.ENTER_FRAME, slideDescription, false, 0, true); 
     28            super.wakeUp.call(this, evt); 
     29        } 
     30 
     31        private function slideDescription(evt:Event):void 
     32        { 
     33            description.x -= 5; 
     34            if (Math.abs(description.x) > description.width) 
     35            { 
     36                parent.removeChild(this); 
     37            } 
     38        } 
     39 
     40        override protected function sleep(evt:Event):void 
     41        { 
     42            removeEventListener(Event.ENTER_FRAME, slideDescription, false); 
     43            super.sleep.call(this, evt); 
    2044        } 
    2145    }