7 Replies Latest reply on Sep 22, 2010 12:13 PM by Flex harUI

    Simulating 'CTRL + A' in ActionScript

    pgpradeep

      Hi,

      I am writing a custom automation agent for Flex.

      Here I am using :

       

      eventClassName = "mx.automation.events.TextSelectionEvent";
      eventType = TextSelectionEvent.TEXT_SELECTION_CHANGE;

       

      and then

       

      classEvent["beginIndex"] = 0;
      classEvent["endIndex"] = TextInput.text.length;

       

      where classEvent is the Event of type eventType and name eventClassName.

       

      I am executing this with TextInput (for example) but am not getting thw whole text selected everytime(sometimes it works sometimes it doesn't).

      So, I want to simulate CTRL + A (which will indeed select the whole text).

       

      To do this I am using :

       

      eventClassName = "flash.events.KeyboardEvent";
      eventType = "keyPress";

       

      and then

       

      classEvent["keyCode"] = 65;//"A"
      classEvent["charCode"] = 97;
      classEvent["ctrlKey"] = true;

       

      When I execute this, I get a message saying that "Cannot execute method with keyCode  '65' ".

      Can someone help me to do this.

       

      Thanks,

      Pradeep.