A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Alert.addEventListener help

  1. #1
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386

    Alert.addEventListener help

    Hi All,

    I am using the Alert Component but having a bit of difficulty.

    The help files say that I can add a click event to the Alert to capture when it have been clicked. To do this they add an eventListener to the Alert. When I do this, exactly as they have in the help files it returns an error "The property being referenced does not have the static attribute."

    How do you listen for an Alert box to be clicked and take action when it is?


    Thanks.

    _t
    I don't feel tardy.

  2. #2
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi,

    May try this example (Requires an Alert component in the Library, and a button on stage named "myButton" -to launch the Alert-):

    AS:
    PHP Code:
    // IMPORTAN: This script REQUIRES:
    // 1) An "Alert" component in the library
    // 2) A button on the stage named "myButton"  (to launch the Alert)

    import mx.controls.Alert;

    // USE this button to launch the Alert
    myButton.onRelease=function(){
        
    showPopUp() // Launch the Alert window
    }

    function 
    showPopUp(){
        
    myAlert=mx.controls.Alert.show("Hello there""Test Alert"Alert.CANCEL |Alert.OK
        
    myAlert.setSize(300,120)
        
    myAlert.closeButton=true // Add a small close but (x) at the top right of window
        
    myAlert.addEventListener("click"HandleEvent);
    }


    function 
    HandleEvent(evt:Object){

        var 
    ButtonID=evt.detail
        
        
    if (ButtonID==Alert.CANCEL){
            
    trace("CANCEL clicked")
        } else if (
    ButtonID==Alert.OK){
            
    trace("OK clicked")
        } else{  
    // When the small close button on window clicked
            
    trace("The small Button (x) clicked")
            
    evt.target.deletePopUp();
        }
    }

    trace('NOTE: Need a button on stage named "myButton"'
    See the output window for the events when click the Alert buttons..

    Regards!

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center