Simple tips to realize the marquee effect in flex(with source code)

Location-NEWS-128x128If you’ve considered the marquee effect when you built a news board in your web application? The Simple tips show how to realize the marquee effect in flex. Because it based on Canvas and Text component, you could change the font size, color, background and scroll speed freely. If you put mouse on frame, the marquee effect will be paused.  
View source is enabled in the following example

Full source code:

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" 
  3.     creationComplete="complete()" viewSourceURL="srcview/index.html">
  4.     <mx:Script>
  5.         <![CDATA[
  6.             private function complete():void
  7.             {
  8.                 move_up.yFrom = cs.height - 6;  
  9.                 move_up.yTo = 0 - tt.height + 6;
  10.                 move_up.repeatCount = 0; //loop
  11.                 move_up.repeatDelay = 0; //loop time
  12.                 move_up.duration = 6000; //the time of scroll once
  13.                 move_up.play();
  14.             }
  15.            
  16.             private function move_pause():void
  17.             {
  18.                 move_up.pause()//pause
  19.             }
  20.            
  21.             private function move_resume():void
  22.             {
  23.                 move_up.resume(); //start from the pause position
  24.             }
  25.         ]]>
  26.     </mx:Script>
  27.     <mx:Move id="move_up" target="{tt}" />
  28.     <mx:Panel width="250" height="200" layout="absolute" title="Anouncement" 
  29.         fontSize="13" horizontalCenter="0" verticalCenter="0">
  30.         <mx:Canvas id="cs" width="100%" height="100%" left="0" top="0" 
  31.             verticalScrollPolicy="off" mouseOver="move_pause()" mouseOut="move_resume()">
  32.             <mx:Text id="tt" width="94%" horizontalCenter="0"
  33.                 text="Ntt.cc was created br Minidxer in January of 2008 as a site dedicated to the prolification of Macromedia/Adobe Flex and JavaScript/Ajax." verticalCenter="0">
  34.             </mx:Text>
  35.         </mx:Canvas>
  36.     </mx:Panel>
  37. </mx:Application>
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Reddit
  • Technorati
  • StumbleUpon
  • Twitter
RSS Enjoy this Post? Subscribe to Ntt.cc

RSS Feed   RSS Feed     Email Feed  Email Feed
You can leave a response, or trackback from your own site.

6 Responses to “Simple tips to realize the marquee effect in flex(with source code)”

  1. [...] Author and source « Installing Papervision3D on Flash and Flex [...]

  2. RE says:

    Thanks!
    That was just what I needed to move my project forward.

  3. Rafael Brazil says:

    first,i’m sorry but my english isnt very good ok?
    how can i to crontrol the velocity?

  4. Ntt.cc says:

    move_up.duration = 6000; //the time of scroll once

  5. saurabh says:

    thanks gr8 help..!!

  6. saurabh says:

    what about horizontal marquee?? plz throw some light.

Leave a Reply