Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Explore key & mouse with Flex 
 

On this web page you will to know how to determine for a key is pressed or not when an event occurs.

 

Explore key & mouse with Flex

                         

 

On this web page you will to know how to determine for a key is pressed or not when an event occurs. In the example below two flex controls CheckBox and Button and two flex containers HBox and VBox created. Also two MouseEvent class events click and mouse over are used. Example below is coded to track the pressing of two keys shift and alt with define events CLICK and MOUSE_OVER respectively.

Function addChild  in the code is used to bring the flex controls to generate inside the flex containers. 
Function addEventListener is used to add or invoke the respective mouse events on the containers.

Syntax for using above functions:

container_id
.addChild(control_id);
control_id.addEventListener(MouseEvent.CLICK/MOUSE_OVER, a_function_name);

 

 

 

 

 

 



Amanda.mxml

<?xml version = '1.0'?>
<mx:Application 
  xmlns:mx = 'http://www.adobe.com/2006/mxml'
>

<mx:Script> 
  import mx.controls.Button;
  import mx.controls.CheckBox;
    
  public function createControls():void{
      
    var ch0:CheckBox = new CheckBox();
    ch0.label = 'Anjelina jolie'
  
    var ch1:CheckBox = new CheckBox();
    ch1.label = 'Alicia Silverstone'
        
ch0.addEventListener(MouseEvent.MOUSE_OVER, removeCheckBoxes);
ch1.addEventListener(MouseEvent.MOUSE_OVER, removeCheckBoxes);

    horizonBox.addChild(ch0);      
    horizonBox.addChild(ch1);      
    
      
    var bt0:Button = new Button();
      bt0.label = 'rachel';
    var bt1:Button = new Button();
      bt1.label = 'neo';
    
bt0.addEventListener(MouseEvent.CLICK, removeButtons);
bt1.addEventListener(MouseEvent.CLICK, removeButtons);
    
    vertical.addChild(bt0);
    vertical.addChild(bt1);
      
    
    }
    
  public function removeCheckBoxes(event:MouseEvent):void{
    if(event.altKey)
    horizonBox.removeChild(CheckBox(event.currentTarget));
    else 
      event.currentTarget.toolTip = 'Alt + mouse'
        ' arrow to get rid of this Control';
  }
    
  public function removeButtons(event:MouseEvent):void{
    if(event.shiftKey)
      vertical.removeChild(Button(event.currentTarget));
    else 
      event.currentTarget.toolTip = 'Shift + click to'
      ' get rid of this Control';
  }
  
</mx:Script>
  
  <mx:VBox id = 'vertical' >
    <mx:HBox id = 'horizonBox'/>
  
  </mx:VBox>

  <mx:Button 
    label = 'create  flex controls
    click = 'createControls()
    color = '#660000'
  />

</mx:Application> 

 

                                     
                                              
 Amanda.swf

                                         

                        

 

Download the code

 

                         

» View all related tutorials
Related Tags: c gui com class controls ui select button style control io components sed implementation component definition tag name using this

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.