root/Theme-1/nobu/Panel.as

Revision 11, 1.5 kB (checked in by nobu, 9 months ago)

ととりあえず動くよ

Line 
1 package
2 {
3     import flash.events.Event;
4     import flash.text.TextField;
5     import flash.text.TextFieldAutoSize;
6     import flash.text.TextFormat;
7     import lib.display.MovieClipExt;
8
9     public class Panel extends MovieClipExt
10     {
11         public function Panel(p_args:Object=null)
12         {
13             p_args = p_args || {};
14             title.htmlText = '<a href="'+p_args.link+'">'+p_args.title+'</a>';
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);
44         }
45     }
46 }
Note: See TracBrowser for help on using the browser.