Add Enter Frame event listener : Frame Event « Animation « Flash / Flex / ActionScript






Add Enter Frame event listener

 
package {
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.text.TextField;
    import flash.events.Event;

    public class Main extends Sprite {
        private var _bitmap:BitmapData= new BitmapData(100, 100, false, 0xffffffff);
        private var _textfield:TextField= new TextField(  );

        public function Main(  ) {
            var image:Bitmap = new Bitmap(_bitmap);
            addChild(image);
            _bitmap.noise(1000, 0, 255, 1|2|4, false);
    
            addChild(_textfield);
            _textfield.y = 100;
    
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
    
        public function onEnterFrame(event:Event):void {
            var colorVal:Number = _bitmap.getPixel(mouseX, mouseY)
            _textfield.text = "#" + colorVal.toString(16).toUpperCase(  );
        }
    }
}

        








Related examples in the same category

1.Designated Frame Rate Versus Actual Frame Rate
2.Measuring the actual frame rate
3.Animating with the ENTER_FRAME Event: Animating a TextField horizontally
4.Move TextField in animation