
Hi.....
I want to know about
What does calling preventDefault() on an event do? How is this enforced?
please give me an example for that
Thanks

Ans:
The methods of the Event class can be used in event listener functions to affect the behavior of the event object. Some events have an associated default behavior. For example, the doubleClick event has an associated default behavior that highlights the word under the mouse pointer at the time of the event. Your event listener can cancel this behavior by calling the preventDefault() method. You can also make the current event listener the last one to process an event by calling the stopPropagation() or stopImmediatePropagation() method.
for example:
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.TextEvent;
[SWF(width=550, height=400)]
public class Main extends Sprite {
public function Main() {
var tf:TextField = new TextField();
addChild(tf);
tf.width = stage.stageWidth;
tf.height = stage.stageWidth;
tf.type = TextFieldType.INPUT;
tf.wordWrap = true;
tf.addEventListener(TextEvent.TEXT_INPUT, onTextFieldTextInput);
}
private function onTextFieldTextInput(event:TextEvent):void {
var tf:TextField = event.target as TextField;
if (tf.text.indexOf(event.text) > -1) {
event.preventDefault();
}
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.