salim_designer
11-28-2007, 07:02 AM
I just tried Flex help to create a component using Actionscript. I found a code which creates a textArea, where if we press control+z the textArea will be empty
Here is the class file:
package myComponents
{
// myComponents/DeleteTextArea.as
import mx.controls.TextArea;
import flash.events.KeyboardEvent;
public class DeleteTextArea extends TextArea {
// Constructor
public function DeleteTextArea() {
// Call super().
super();
// Add event listener for keyDown event.
addEventListener("keyDown", myKeyDown);
}
// Define private keyDown event handler.
private function myKeyDown(eventObj:KeyboardEvent):void {
// Check to see if Ctrl-Z pressed. Keycode for Z is 90.
if (eventObj.ctrlKey && eventObj.keyCode == 90)
text = "";
}
}
}
Here is the file that I am using the component:
<?xml version="1.0"?>
<!-- MainDeleteTextAreaProps.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:DeleteTextArea wordWrap="true" text="My Message"/>
</mx:Application>
I don't know why the code is not working nor I am getting any error
Here is the class file:
package myComponents
{
// myComponents/DeleteTextArea.as
import mx.controls.TextArea;
import flash.events.KeyboardEvent;
public class DeleteTextArea extends TextArea {
// Constructor
public function DeleteTextArea() {
// Call super().
super();
// Add event listener for keyDown event.
addEventListener("keyDown", myKeyDown);
}
// Define private keyDown event handler.
private function myKeyDown(eventObj:KeyboardEvent):void {
// Check to see if Ctrl-Z pressed. Keycode for Z is 90.
if (eventObj.ctrlKey && eventObj.keyCode == 90)
text = "";
}
}
}
Here is the file that I am using the component:
<?xml version="1.0"?>
<!-- MainDeleteTextAreaProps.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<MyComp:DeleteTextArea wordWrap="true" text="My Message"/>
</mx:Application>
I don't know why the code is not working nor I am getting any error