1 Reply Latest reply on Jul 26, 2011 9:56 AM by Flex harUI

    Flash crashes when using Keyboard.capsLock in Linux environments

    jamesweir

      When using Keyboard.capsLock in ActionScript, causes the flash player to crash in Linux environments.

       

      NOTE: THIS WORKS ON MAC AND WINDOWS ENVIRONMENTS

       

      This is reproducible on:

       

      Ubuntu 10.04, 10.10, 11.04

      Fedora: 13, 14, 15

      Browser: firefox

      Flash Player versions: 10.1.X, 10.3.X

       

      Here is some code to reproduce the problem.  I have created a new TextInput component (called PasswordTextInput) and added it to a simple Application.

       

      Unsure if this is related to the Limitation in release notes for flash player 10.1:

      "Alt and Caps Lock Keys do not send KeyDown or KeyUp events from Soft Keyboard."

       

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml" displayAsPassword="true"

        keyDown="handleKeyDown(event);" keyUp="handleKeyDown(event);" focusIn="init();">

      <mx:Script>

      <![CDATA[

      import mx.controls.Image;

       

      private var _image:Image;

       

      [Embed (source="/assets/CAPLOCK.png")]

      public static const CAPLOCK:Class;

       

      override protected function createChildren():void {

      super.createChildren();

      _image = new Image();

      _image.source = CAPLOCK;

      addChild(DisplayObject(_image));

      }

       

      override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {

      super.updateDisplayList(unscaledWidth, unscaledHeight);

      this._image.width = 17;

      this._image.height = 17;

      this._image.x = this.width - this._image.width - 4;

      this._image.y = (this.height - this._image.height)/2;

      this.textField.width = this.width - this._image.width - 5;

                                      // COMMENING THE NEXT LINE, THE CRASH NO LONGER HAPPENS

      //this._image.visible = Keyboard.capsLock;

      this._image.toolTip = "CAPS LOCK";

      }

       

      private function capLockCheck():void {

                                      // COMMENTING OUT ALL THIS CODE, THE CRASH NO LONGER HAPPENS

      if (Keyboard.capsLock){

      this._image.visible = true;

      this.textField.width = this.width - this._image.width - 5;

      } else {

      this._image.visible = false;

      this.textField.width = this.width;

      }

      }

       

      private function init():void {

      capLockCheck();

      }

      private function handleKeyDown(event:KeyboardEvent):void{

      capLockCheck();

      }

      ]]>

      </mx:Script>

      </mx:TextInput>