as3 rollovers for a textfield - example 1

Please by all means let me know, if there is a better way to accomplish this idea...

package
{
       
        import flash.display.Sprite;
        import flash.display.Loader;
        import flash.display.Stage;
        import flash.events.TextEvent;
        import flash.net.*;
       
        import flash.text.TextField;
        import flash.text.StyleSheet;
        import flash.events.MouseEvent;
       
       
       
        public class asRollOvers extends Sprite
        {
               
                public var videoItemBox1:TextField = new TextField();
                public var videoItemBox1Bg:Sprite = new Sprite();
               
               
                public function asRollOvers()
                {
                       
                        // --------- HTML CSS Stylesheet -----------
                       
                        // Create and initialize css
                        var asCSS:StyleSheet = new StyleSheet();
                        asCSS.setStyle("a:hover", {textDecoration:'underline'});
       
                       
                               
                        // Add video item 1 bg
                        videoItemBox1Bg.graphics.beginFill(0x000000);
                        videoItemBox1Bg.graphics.drawRect(0,0,310,60);
                        videoItemBox1Bg.graphics.endFill();
                        videoItemBox1Bg.alpha = 0.05;
                        videoItemBox1Bg.x = 0;//stage.stageWidth/2-square.width/2;
                        videoItemBox1Bg.y = 0;//stage.stageHeight/2-square.height/2;
                       
                        stage.addChild(videoItemBox1Bg);
                       
                        // Add video txt item 1
                        videoItemBox1.width = 310;
                        videoItemBox1.height = 60;
                        videoItemBox1.x = 0;
                        videoItemBox1.y = 0;
                        videoItemBox1.border = false;
                        videoItemBox1.wordWrap = true;
                        videoItemBox1.styleSheet = asCSS;
                        videoItemBox1.addEventListener(MouseEvent.MOUSE_OVER, mouseOverVideoItemBox1);
                        videoItemBox1.addEventListener(MouseEvent.MOUSE_OUT, mouseOutVideoItemBox1);
                       
                        videoItemBox1.htmlText = "<font face='Georgia, Times New Roman, Times, serif' color='#ffffff' size='22'><i><a href='http://www.google.com'>TEXT CONTENTS</a></i></font>";
                       
                        stage.addChild(videoItemBox1);
                       
                }
               
                // Video Item 1 - Rollovers
                public function mouseOverVideoItemBox1(event:MouseEvent):void {
                        videoItemBox1Bg.alpha = 1;
                }
               
                public function mouseOutVideoItemBox1(event:MouseEvent):void {
                        videoItemBox1Bg.alpha = 0.05;
                }
               
        }
}




Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.
Bg