flex 滾動資訊,類似marquee的展現

kenchow126發表於2012-04-11

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
     creationComplete="complete()">
     <mx:Script>
         <![CDATA[
          import mx.controls.Alert;
             private function complete():void
             {
                 move_up.yFrom = cs.height - 6;     //"加6減6是為了首尾連線更加自然"
                 move_up.yTo = 0 - zz.height + 6;   //同上
                 move_up.repeatCount = 0; //無限次重複
                 move_up.repeatDelay = 0; //重複時間,毫秒
                 move_up.duration = 10000; //滾動一次的時間,毫秒
                                
                
                 move_up.play();

             }
           
             private function move_pause():void
             {
                 move_up.pause();   //暫停
             }
           
             private function move_resume():void
             {
                 move_up.resume(); //從暫停位置開始
             }
             private function sendto(flag:String):void{
              Alert.show(flag);
             }
         ]]>
     </mx:Script>
     <mx:Move id="move_up" target="{cs}" />
     <mx:Panel width="250" height="458" layout="absolute" title="公告欄"
         fontSize="13" horizontalCenter="0" verticalCenter="0" verticalScrollPolicy="off" horizontalScrollPolicy="off" mouseOver="move_pause()" mouseOut="move_resume()">
         <mx:VBox id="cs" width="220" height="100%" >
             <mx:Text id="zz" text="zzzzzzzzzzzzz" click="sendto('zz');"/>
             <mx:Text id="ww" text="wwwwwwwwwwwww" click="sendto('ww');"/>
             <mx:Text id="hh" text="hhhhhhhhhhhhh" click="sendto('hh');"/>
         </mx:VBox>
     </mx:Panel>
</mx:Application>

相關文章