Event in flex

Event in flex

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

View Answers

October 26, 2010 at 11:24 AM

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();
               }
          }

     }

}









Related Tutorials/Questions & Answers:
Flex event
Flex event  Hi.... Please tell me about How to create your own event in flex? Thanks
Flex event
Flex event  hi...... How to capture and event if the component is disabled? please give an example..... Thanks in advance
Advertisements
Flex event
Flex event  Hi.... please tell me about How does Flex event...: In the capturing phase, Flex examines an event target?s ancestors in the display list to see...: In the targeting phase, Flex invokes the event dispatcher?s listeners. No other nodes
Flex event
Flex event  Hi... please give me the answer with example What is event Bubbling? Thanks in advance  Event Bubbling: In the bubbling phase, Flex examines an event?s ancestors for event listeners. Flex starts
Event in flex
Event in flex  Hi..... I want to know about What does calling preventDefault() on an event do? How is this enforced?ADS_TO_REPLACE_1 please give... of the Event class can be used in event listener functions to affect the behavior
Flex event
Flex event  Hi..... I have a problem regarding obj.addEventListener(MouseEvent.CLICK, MouseClickHAndler); in this obj should inherit which class? please give the name of that class......... Thanks
Event in flex
Event in flex  Hi..... can you tell me about that How do you make component participate in event mechanism?ADS_TO_REPLACE_1 Thanks   Ans: Extend EventDispatcher or any subclass of it or implement IEventDispatcher
Flex event
Flex event  Hi..... How many events are fired when your focus goes in one text box, you enter some text and then press tab? Please give the name of all events which is used in this..... Thanks
Flex Add Event Listener example
in flex components. Here in the example only mouse event is added... on the flex components or it can be said as event listeners handles the event... Flex addEventListener example   
Event handler for Visual Component in Flex 4
Event Handler for Visual Components in flex4: Flex are provide event driven... or change in the interface. This is alled Event. Flex provide the ability to create event listener for the particular event that handle event when event
Flex event phase detection example
Flex event phase detection example   ... flex checks containers like VBox  for the event listeners for handling.... In Targeting phase flex just triggers the event and in the Bubbling phase flex re-begins
Flex dispatch event example
Flex dispatchEvent example       The example below demonstrates the working of flex dispatchEvent() method. Method works like a driver that drives the event
Flex terminating event flow example
Flex terminating event flow example       In the example below, how to terminate an event flow... events on the flex controls and containers. A mouse click event on button
Flex adding single event on varied components Example
Flex single event on varied components   ... event MouseEvent.MOUSE_DOWN, are created on two flex check boxes controls... the pop-up windows. So with this example a clear idea for adding single event
Flex Examples
you will learn about how to dispatch or run away an event.   Flex Circle...Flex Examples In this section we will see some examples in Flex. This section will help you in to create applications using flex. In this page you will get
FLex Tree
FLex Tree  I want to change the node name in flex tree my code is: Company:XML = <Element name ="Element" code="400"> <{newChild} name... to update the variable newChild and newChild1 on click event. I have click handler
Flex target property example
Flex target property example       In coding the below flex application we have use an event object property  target . We also have another event object property
Flex Looping
Flex Looping  I need example for flex looping mechanisam example
ToggleButtonBar in Flex
ToggleButton in Adobe Flex: Flex provides ToggleButtonBar , which is a set... is selected, a single event called itemClick is dispatched... the ToggleButtonBar controls dispatch an itemClick event and pass an  object
Flex - Framework
Flex  database conectivity in flex
Sitemap Adobe Flex Tutorial
| Flex current target property | Flex single event on varied components | Flex Circle drawing | Flex target property | Flex event phase detection | Flex terminating event flow | Flex data binding | Flex KeyboardEvent
addEventListner in flex
(event:Event):void{ Alert.show('welcome to Flex World'); } </mx...addEventListner in flex  Hi..... How do you add event listeners...); } public function Handler1():void{ t1.text = 'click event disabled
ButtonBar in Flex
ButtonBar: Flex provides ButtonBar controls which is a horizontal or vertical set of related buttons. When any button is selected, a single event called... controls dispatch an itemClick event and pass an  object of type
Flex Combobox
Flex Combobox  flex combobox with database as dataprovider   You can visit the following link for detailed tutorial on the topic. May this will be helpful to you. http://www.roseindia.net/flex/flex-combo-box.shtml
Flex basic
Flex basic  Hi...... please just tell me about Can we run Flex applications in MAC? Thanks
Flex and Java
Flex and Java  hi..... Please give similiarities between Java and Flex. Thanks
Flex and Java
Flex and Java  Hi...... Give the name of Collection which can be mapped to java and Flex and vice-versa. please give the name of all collections which is used in flex and java.. Thanks
Flex and Java
Flex and Java  Hi.... What are the config files that are used to connect Java and Flex applications? Please provide the solution of this prob so i connect java and flex.... Thanks
Flex as a Service
Flex as a Service  Hi....... just tell me about How do I run Flex as a service? please give me an example if possible Thanks  Ans: Flex is not a server. It is the pert of your web application. you can use
Flex Updates
Flex Updates  Sir, first Thanks For Good Resource for Every One! i am New to Flex... but,in Current Updates Tell Us Flex Becomes To down!(Sorry To say).. May I know Future groom & Advantage of Flex Over Other Web
Flex Component Life Cycle
Flex Component Life Cycle  hi.... please tell me about What is Flex Component Life Cycle? Thanks  Ans: There are following pase of flex component life cycle. 1. Initialization phase 2. Update phase 3
Flex basic
Flex basic  Hi.......... I want to know about What is localToGlobal and globalToLocal in flex? please give me ans ASAP..... Thanks
Flex application
Flex application  Hi..... What kind of applications you can create from flex? please give the name of these applications....... Thanks
Flex basic
Flex basic  Hi.... can you tell me about Is Flex OS specific or operating system independent? please give the description about it....... Thanks
Flex basic
Flex basic  Hi.... I want to know Do we need any plugins to run Flex applications? please give the ans ASAP....... Thanks
Flex difference
Flex difference  Hi.... please tell me about What is the difference between Flex 2.0 and Flex 3.0? Thanks  Ans: There are some advantages of Flex3.0 over Flex 2.0 they are following: 1. Faster compilation time
Adding a flex table in another flex table column
Adding a flex table in another flex table column  how to add a flex table in another flex table column
Flex Tutorials
of flex dispatchEvent() method. Method works like a driver that drives the event... away an event.   Flex custom mxml tags... indexes.   Flex single event on varied
Flex basic
Flex basic  Hi.... Can flex application communicate with each other on the client? please give me the answer ASAP.....ADS_TO_REPLACE_1 Thanks   Ans: See the LocalConnection API In the flex documentation. ADS
Flex with JSP
Flex with JSP  i want to draw chart in jsp page using flex. how can i do that? any solution??   Flex charts You can visit the following links: http://www.roseindia.net/tutorial/flex/flex4/components/charteffect.html
Flex basic
Flex basic  Hi...... Please tell me about What are non-visual components in flex? What class do they extend? please give the name of these components....... Thanks
Flex Managers
Flex Managers  Hi... Please tell me about How to override Managers? give me an example for that.... Thanks
Image in Flex
Image in Flex  Hi..... Can you manipulate images using Flex programs? please give me the example....... Thanks
Metadata in flex
Metadata in flex  Hi......... please tell me about the meta data in flex. Thanks
XML in flex
XML in flex  Hi... just tell me about What is e4X and XML in flex? Thanks
Mask in Flex
Mask in Flex  Hi...... Is it possible to create 'gradient mask' in flex? please give me the ans ASAP..... Thanks in advance
Adobe flex
Adobe flex  Hi... please give me the description about What is Adobe Flex? Thanks
Advantage of Flex
are the Advantages and Disadvantages of flex? Thanks   Advantages: Flex IDE is very capable. Flex output is a movie and images is the major part of this movie. you can not directly download the flex running file. When we right click
Life-Cycle of flex application
flash builder 4 the following event sets the lifeCycle of flex application. 1... text. When Flex dispatches the preinitialize event, the children, including...Life-Cycle of flex application  hi..... Please tell me What
Output of flex
Output of flex  hi....... please provide the name of the output file. What is the output of flex applications? please rply ASAP........ Thanks

Ads