Removing a Button Event Listener on a Specific Frame and Reactivating it on Next Frame

Hi , i am trying to develop a Slideshow where Next Button needs to behave in a certain way on a specific Frame , lets say a Specific Condition is met only then Next Button would work , I have been able to achieve that but problem is the Button Retains its Event Listener even on the next Frame , whereas  i have already included removeEventListener on the next frame with a new Function for the button , but its doesnt take it like that.
Can anyone help please ?

Hello Ned,
I have fixed the issue with few Frame , but where we have the conditions to be met on two consecutive frames , I am not able to achieve that.
here is the Code on my first Frame.
FRAME1
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
mc_prog.width = 0;
//LIBRARIES TO BE IMPORTED ///////////////////////////////////////////////////////////
import flash.events.MouseEvent;
//VARIALBLES INITIATED
var score:Number = 0;
var questions:Number = 0;
var qtotal:Number = 11;
var attempt:Number = 0;
var indexframe:int;
indexframe = this.totalFrames - 1;
var notes:Array = new Array();
var count:int;
count = 0;
var backcounter:int;
backcounter = 0;
var count2:int;
count2 = 0;
var backcounter2:int;
backcounter2 = 0;
var count3:int;
count3 = 0;
var backcounter3:int;
backcounter3 = 0;
// MOVIE CLIPS INITITATED ////////////////////////////////////////////////////////////////
var volbutton1:volcontrol;//VOLUME BUTTON ROLLOVER MOVIE CLIP
volbutton1 = new volcontrol();
var clist:courselist;//VOLUME COURSE LIST ROLLOVER MOVIE CLIP
clist = new courselist();
var pop1:Mc_slide9 = new Mc_slide9;
pop1 = new Mc_slide9;
var pop2:Mc_slide13 = new Mc_slide13;
pop2 = new Mc_slide13;
var pop3:Mc_slide17 = new Mc_slide17;
pop3 = new Mc_slide17;
//BUTTONS INITIATED
btn_nxt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);//NEXT SLIDE BUTTON
btn_bck.addEventListener(MouseEvent.CLICK, backbtn);//BACK BUTTON
btn_loc.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage); //LIST OF COURSES BUTTON
btn_notice1.addEventListener(MouseEvent.CLICK, loadnotice1);
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
btn_notice2.addEventListener(MouseEvent.CLICK, loadnotice2);
pop2.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn2);
btn_notice3.addEventListener(MouseEvent.CLICK, loadnotice3);
pop3.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn3);
//VOLUME BUTTON ROLL OVER FUNCTION EVENT LISTENERS ///////////////////////////////////////
btn_vol.addEventListener(MouseEvent.ROLL_OVER,vol);
btn_vol.addEventListener(MouseEvent.ROLL_OUT,volout);
btn_loc.addEventListener(MouseEvent.ROLL_OVER,coursel);
btn_loc.addEventListener(MouseEvent.ROLL_OUT,corlist);
// FUNCTIONS INITIATED /////////////////////////////////////////////////////////////////
function fl_ClickToGoToNextFrame(event: MouseEvent): void
  nextFrame();
function backbtn(event:MouseEvent):void{
   prevFrame();
function fl_ClickToGoToWebPage(event: MouseEvent): void {
  navigateToURL(new URLRequest("https://www.onlineinduction.com/fmgl/courselist.php?ist=2&type=Vendor Employee Inductions"), "_self");
//VOLUME BUTTON ROLLOVER EFFECT FUNCTION
function vol(e:MouseEvent):void
  addChild(volbutton1);
  //popup_instance.width = 675;
  //popup_instance.height = 300;
   if(this.currentFrame == 2)
    volbutton1.x = 150;
    volbutton1.y = 528;
   else{
    volbutton1.x = 278;
    volbutton1.y = 528;
  function volout (e:MouseEvent):void {
    removeChild(volbutton1);
   function coursel(e:MouseEvent):void {
   addChild(clist);
    if(this.currentFrame == 2)
     clist.x = 85;
     clist.y = 532;
    else if(this.currentFrame == 5){
     clist.x = 115;
     clist.y = 325;
    else{
     clist.x = 175;
     clist.y = 532;
  function corlist (e:MouseEvent):void {
    removeChild(clist);
function loadnotice1(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
  if ( count == 1 && stage.contains(pop1))
   removeChild(pop1);
    if(count == 1)
     nextFrame();
    else
     addChild(pop1);
     pop1.x = 40;
     pop1.y = 120;
     count = 1;
  trace("Counter Value:" + count);
function loadnotice2(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
  if ( count2 == 1 && stage.contains(pop2))
   removeChild(pop2);
    if(count == 2)
     nextFrame();
    else
     addChild(pop2);
     pop2.x = 40;
     pop2.y = 120;
     count2 = 1;
  trace("Counter Value:" + count);
function loadnotice3(Event:MouseEvent):void//FRAME 9 FUNCTION FOR IMPORTANT NOTICE
  if ( count3 == 1 && stage.contains(pop3))
   removeChild(pop3);
    if(count == 3)
     nextFrame();
    else
     addChild(pop3);
     pop2.x = 40;
     pop2.y = 120;
     count2 = 1;
  trace("Counter Value:" + count);
function nextframe9(event: MouseEvent): void
    if(count == 1 && stage.contains(pop1) )
       removeChild(pop1);
    if(count == 1)
     nextFrame();
    else
     addChild(pop1);
     pop1.x = 40;
     pop1.y = 120;
     count = 1;
function nextframe13(event: MouseEvent): void
    if(count2 == 1 && stage.contains(pop2) )
       removeChild(pop2);
    if(count2 == 1)
     nextFrame();
    else
     addChild(pop2);
     pop2.x = 40;
     pop2.y = 120;
     count2 = 1;
function nextframe17(event: MouseEvent): void
    if(count3 == 1 && stage.contains(pop3) )
       removeChild(pop3);
    if(count3 == 1)
     nextFrame();
    else
     addChild(pop3);
     pop3.x = 40;
     pop3.y = 120;
     count3 = 1;
function backbtnscript1(event:MouseEvent):void
   if(stage.contains(pop1) )
      removeChild(pop1);
      backcounter = 1;
      trace("back" + backcounter);
      prevFrame();
function unloadbtn1 (e:MouseEvent):void {
  removeChild(pop1);
function backbtnscript2(event:MouseEvent):void
   if(stage.contains(pop2) )
      removeChild(pop2);
      backcounter2 = 1;
      trace("back" + backcounter2);
      prevFrame();
function unloadbtn2 (e:MouseEvent):void {
  removeChild(pop2);
function backbtnscript3(event:MouseEvent):void
   if(stage.contains(pop3) )
      removeChild(pop3);
      backcounter3 = 1;
      trace("back" + backcounter3);
      prevFrame();
function unloadbtn3 (e:MouseEvent):void {
  removeChild(pop3);
//SLIDE COUNTER
and here is the Code on all the Frames where I need to call in specific Listeners
FOR EXAMPLE ON FRAME 8,9,10,
Here Is the Code ,
FRAME 8
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
count = 0;
backcounter = 0;
btn_nxt.addEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
btn_bck.addEventListener(MouseEvent.CLICK, backbtn);
btn_bck.removeEventListener(MouseEvent.CLICK , backbtnscript1);
btn_nxt.removeEventListener(MouseEvent.CLICK , nextframe9);
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
//btn_notice1.addEventListener(MouseEvent.CLICK , loadnotice1);
FRAME 9
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
//POPUP FUNCTION
count = 0;
btn_nxt.removeEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
btn_bck.removeEventListener(MouseEvent.CLICK, backbtn);
btn_bck.addEventListener(MouseEvent.CLICK , backbtnscript1);
btn_nxt.addEventListener(MouseEvent.CLICK , nextframe9);
btn_notice1.addEventListener(MouseEvent.CLICK , loadnotice1);
FRAME 10
stop();
slidecounter.text = String(this.currentFrame - 1 + "/" + indexframe);
count = 0;
backcounter = 0;
btn_nxt.addEventListener(MouseEvent.CLICK , fl_ClickToGoToNextFrame);
btn_bck.addEventListener(MouseEvent.CLICK, backbtn);
btn_bck.removeEventListener(MouseEvent.CLICK , backbtnscript1);
btn_nxt.removeEventListener(MouseEvent.CLICK , nextframe9);
pop1.closebtn.addEventListener(MouseEvent.CLICK, unloadbtn1);
I am repeating this Pattern on each frame set where I need these Listeners ,
Problem is with the next one where I have two consecutive frames have different conditions to meet, any ideas how would I disable and enable listeners respectively on these frames ?
I hope I am not confusing this very much ?;(

Similar Messages

  • How do I remove a user? ( the name is greyed out and has a check next to it )

    I cannot remove a user ( my wife ) from my Macbook. I go to Sys. Pref, Accounts, and unlock the lock ( I'm the Admin ). I'm able to click on and highlight the guest account but that's not what I want to delete. My wife's user name is greyed out and it has a check mark by it. I'm unable to highlight it so that I can remove it. There's gotta be a simple fix, right? Please help. Thanks,  Michael K.

    Which version of Mac OS X?
    To delete a printer you have to select the printer (on the left), then click the - (minus sign). Which part of this is greyed out?

  • How can I check if a function is or is not called from the event listener? in Flash CS4 (AS3)

    Hi,
    I came across a little problem.
    I put an event listener inside a for loop and the for loop inside a function.
    I want the for loop to end as soon as the event listener inside the for loop calls its function.
    Here is the general code for a better picture.
    Code:
    this.addEventListener(Event.ENTER_FRAME, function#1);
    function function#1(event:Event):void{
              if(something is true){
                        for(var i = 0; i < numOfmy_mcs; i++){
                                  this["my_mc_"+String(i)].addEventListener(MouseEvent.CLICK, function#2);
    function function#2(e:Event):void{
    //do something cool here
    Thank you for any help!

    kglad wrote:
    that for-loop (if it executes), defines listeners for interactive objects.  that will complete long before any object is clicked.
    Well yes but it does it again and again (frames per second times seconds = number of times it goes through the code if i'm not mistaken), because it is inside a function, and through testing i found out that it works like this:
    Example:
    there are 5 my_mc's in my project: (my_mc_0, my_mc_1, my_mc_2, my_mc_3, my_mc_4)
    if i click my_mc_0 function#2 is called and executed. BUT only after the loop finishes (i know this from tons of testing)...which is unnecessary since you cannot click two places at once. This might not be a problem in this example because i am only using 5 my_mc's buy if i use 500000000 my_mc's it would make a lot of difference.
    is there a way to stop the loop if the function is called?
    ...maybe there is a better way to write it, the only alternative i know that works is if i manually write every single listener and this also is logical in this example but as i said next to impossible if the numbers get bigger.
    -Note
    I didn't specify this earlier but function#2 makes the if statement false so it wont jump back into it.
    Thank you for the help I really appreciate it!
    3rd edit...don't know what's wrong with me

  • Which object in hierarchy should add event listener?

    Hello all,
    I'm quite new to the whole OOP thing, and one of the things I keep wondering about is this:
    Which class should listen for events if the choice is between a contained class or a containing class?
    For example:
    An instance of Game holds an instance of Board which holds an array of instances of fields.
    This might be a scenario for a simple board game, I guess (In my case I am working on Reversi).
    A player should click a field to place a piece on it. I could let the Field class listen for the click event,
    but when a player places a piece, other pieces might have to flip, so an object at a higher level should handle this (board / game / maybe another object).
    So in order to make sure this happens, I could let the field object listen for the event and than tell the higher-level-object to do his thing, or I could
    let the higher-level-object add an event listener on the field object, and than both flip the nescesary pieces as well as tell the field to add a piece on itself.
    Could anyone explain which and why either solution (or maybe a third on) is better?
    Thanks for your time!

    qdudu wrote:
    Hello all,
    I'm quite new to the whole OOP thing, and one of the things I keep wondering about is this:
    Which class should listen for events if the choice is between a contained class or a containing class?The class that can respond to the events should implement the Listener.
    For example:
    An instance of Game holds an instance of Board which holds an array of instances of fields.
    This might be a scenario for a simple board game, I guess (In my case I am working on Reversi).
    A player should click a field to place a piece on it. I could let the Field class listen for the click event,
    but when a player places a piece, other pieces might have to flip, so an object at a higher level should handle this (board / game / maybe another object).Sounds like Board would be a good choice, then.
    So in order to make sure this happens, I could let the field object listen for the event and than tell the higher-level-object to do his thing, or I could
    let the higher-level-object add an event listener on the field object, and than both flip the nescesary pieces as well as tell the field to add a piece on itself.Sounds like the field object can't do much except forward the event to the real handler. In that case I'd vote for the higher-level-object as the listener.
    Could anyone explain which and why either solution (or maybe a third on) is better?In this case it could be either one. Try both and see. But based on the little you've posted here I'd vote for the higher-level-object, the Board.
    %

  • Event listener on inline graphic

    Hi
    Is there a way to add an event listener to an inline graphic.
    I cant seem to find much... or any help concerning this in
    the forums.
    I remember reading a post about this a while back where
    someone wanted to add a doubble click to an inline graphic without
    success. Has that been resolved?
    Im desperate to get this working and any help would be much
    appreciated
    Thank you

    HI
    Thanks again for the reply. Check StatusChangeEvent.status
    for "ready" works perfectly.
    Sorry to ask more questions on this topic but I cant find
    documentation or info anywhere else. If you could give me a link I
    would be happy to go that route...
    I added an event listener to the inline graphic and gave it a
    name as follows:
    ILG.graphic.name = LIG.source.toString();
    ILG.graphic.addEventListener(MouseEvent.MOUSE_OVER,
    ILGhandeler);
    then when I trace the target I get //instance23
    eg trace(e.target.name) //instance23
    but if I do the following I get the source that im looking
    for:
    trace(e.target.parent.parent.name) // path/to/graphic.
    1) Is what IM doing good practise?
    2) can I add the source to something other than the .name
    //eg ILG.graphic.theurl = ILG.source.toString();
    3) Is there a way to target and replace or update an
    ILGElement just by knowing its source.
    ie (replace or update) ILGElement where LIGElement.source ==
    "theurl"
    Help with this will be awesome. Thank you for your patience

  • Checkin for a specific username and password

    i have an html page where i enter username and password..now if i want that for a specific username and password only the next page say next.html is displayed otherwise the same page is diaplayed sayin that the usrename and password is to be reenterd...how can i do this servlets..also do tell me where to store the username and password

    I am sorry, I lost some code in cut and pasting it
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;   
    public class LoginServlet extends HttpServlet{
            private Connection con;
            private PreparedStatement pstmt;
            private Statement stmt;
            private ResultSet rs;
            private String pass = "";
            private String login,password,done;
            private HttpSession session;
            public void doPost(HttpServletRequest request,HttpServletResponse response)
            throws ServletException, IOException{
                    login = ""+request.getParameter("login");
                    password = ""+request.getParameter("password");
                    done = ""+request.getParameter("done");
                    session = request.getSession(true);
                    PrintWriter out = response.getWriter();
                    try{
                            Class.forName("oracle.jdbc.driver.OracleDriver");
                    }catch(Exception e){
                            out.println(e.getMessage());
                    try{
                            con = DriverManager.getConnection("jdbc:oracle:thin:scott/[email protected]:1521:csapw");
                            if(!(password.equals("")&&login.equals(""))){
                                    pstmt = con.prepareStatement("select password from logon where login = ?");
                                    pstmt.setString(1,login);
                                    rs = pstmt.executeQuery();
                                                         pass = "";
                                    while(rs.next()){
                                            pass = rs.getString(1);
                                    if(pass.equals(password)){
                                            session.setAttribute("login",login);
                                            if(done.equals("null")){
                                                    done = "";
                                                    pass = "";
                                                    response.sendRedirect("/ksenji/quiz2/shoponline.jsp");
                                            }else{
                                                    response.sendRedirect(done.substring(5));
                                    else{
                                            response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
                            else{
                                    response.sendRedirect("/ksenji/quiz2/login.jsp?"+done);
                    }catch(SQLException ex){
                            out.println(ex.getMessage());
               

  • Removing event listener from a button.

    I've added a "click" event listener to a button, but I'd like to remove it once the button is clicked, so it's not active/clickable any longer. Here's the basic code:
    sym.$('button').click(function(){
         //here I need to make this button not clickable any longer
    Thank you.

    one way...
    sym.$('button').click(function(){
         //here I need to make this button not clickable any longer
         // do smething here then unbind click handler
                sym.$('button').unbind( "click" );
    unbind documentation here.
    hth
    Darrell

  • Can't remove event listener from Image

    I'm clearly missing something and would appreciate some help.  I'm trying to run an event handler when an Image completes loading,  then remove the handler so that it won't  run again should the image be reloaded later.
    The problem that I'm having is that the event handler simply wont' go away, despite calling removeEventListener on the Image object.
    The following example demonstrates the problem (the example doesn't actually do anything useful...it's just the shortest example to demonstrate the problem).  (To run the  app, you'll have to provide any ol' JPEG file named "myImage.jpg" in the "src" directory of your project).
    What I expect to happen is :
         1) on startup, the image loads and loadComplete() runs.
         2)  loadComplete removes the event Listener so that subsequent re-loads won't re-fire the handler.  I only want the handler to  run once.
         3) "loadComplete" shoudl  be displayed in the Debug console.
         4) A button click should display only "Changing  Image" in the Debug console
    What I get instead is that the loadComplete handler isn't  removed, and every  time I click the button, loadComplete runs when the image is re-loaded   (i.e., every button click results in both "Change Image" AND "loadComplete"  being displayed in the Debug console).
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Image width="655" height="181" source="myImage.jpg" id="myImage" autoLoad="true" scaleContent="true" complete="loadComplete()" x="100" y="100"/>
        <mx:Button x="100" y="341" label="Button" click="click(event)"/>
        <mx:Script>
            <![CDATA[
                private function loadComplete():void
                    trace ("loadComplete");
                    myImage.removeEventListener("complete", loadComplete);
                private function click(evt:Event):void
                    trace ("Changing Image");
                    myImage.load("myImage.jpg");    //  Reload same image; it's just an example
            ]]>
        </mx:Script>
    </mx:Application>

    Hi,
    You can remove only event listeners that you added with the addEventListener() method in an ActionScript block. You cannot remove an event listener  that was defined in the MXML tag, even if it was registered using a call  to the addEventListener()method that was made inside a tag attribute.
    Check this page for reference.
    http://livedocs.adobe.com/flex/3/html/help.html?content=events_05.html
    You can modify the code a bit a get it working
    <mx:Image width="655" height="181" id="myImage" scaleContent="true"
              x="100" y="100"
              creationComplete="myImage_creationCompleteHandler(event)"/>
    private function myImage_creationCompleteHandler(event:FlexEvent):void
         myImage.addEventListener("complete",myImage_completeHandler);
         myImage.load("myImage.jpg");
    private function myImage_completeHandler(event:Event):void
         myImage.removeEventListener("complete",myImage_completeHandler);

  • Search for records in the event viewer after the last run (not the entire event log), remove duplicate - Output Logon type for a specific OU users

    Hi,
    The following code works perfectly for me and give me a list of users for a specific OU and their respective logon types :-
    $logFile = 'c:\test\test.txt'
    $_myOU = "OU=ABC,dc=contosso,DC=com"
    # LogonType as per technet
    $_logontype = @{
        2 = "Interactive" 
        3 = "Network"
        4 = "Batch"
        5 = "Service"
        7 = "Unlock"
        8 = "NetworkCleartext"
        9 = "NewCredentials"
        10 = "RemoteInteractive"
        11 = "CachedInteractive"
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0""
    or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>" -ComputerName
    "XYZ" | ForEach-Object {
        #TargetUserSid
        $_cur_OU = ([ADSI]"LDAP://<SID=$(($_.Properties[4]).Value.Value)>").distinguishedName
        If ( $_cur_OU -like "*$_myOU" ) {
            $_cur_OU
            #LogonType
            $_logontype[ [int] $_.Properties[8].Value ]
    #Time-created
    $_.TimeCreated
        $_.Properties[18].Value
    } >> $logFile
    I am able to pipe the results to a file however, I would like to convert it to CSV/HTML When i try "convertto-HTML"
    function it converts certain values . Also,
    a) I would like to remove duplicate entries when the script runs only for that execution. 
    b) When the script is run, we may be able to search for records after the last run and not search in the same
    records that we have looked into before.
    PLEASE HELP ! 

    If you just want to look for the new events since the last run, I suggest to record the EventRecordID of the last event you parsed and use it as a reference in your filter. For example:
    <QueryList>
      <Query Id="0" Path="Security">
        <Select Path="Security">*[System[(EventID=4624 and
    EventRecordID>46452302)]]</Select>
        <Suppress Path="Security">*[EventData[Data[@Name="SubjectLogonId"]="0x0" or Data[@Name="TargetDomainName"]="NT AUTHORITY" or Data[@Name="TargetDomainName"]="Window Manager"]]</Suppress>
      </Query>
    </QueryList>
    That's this logic that the Server Manager of Windows Serve 2012 is using to save time, CPU and bandwidth. The problem is how to get that number and provide it to your next run. You can store in a file and read it at the beginning. If not found, you
    can go through the all event list.
    Let's say you store it in a simple text file, ref.txt
    1234
    At the beginning just read it.
    Try {
    $_intMyRef = [int] (Get-Content .\ref.txt)
    Catch {
    Write-Host "The reference EventRecordID cannot be found." -ForegroundColor Red
    $_intMyRef = 0
    This is very lazy check. You can do a proper parsing etc... That's a quick dirty way. If I can read
    it and parse it as an integer, I use it. Else, I just set it to 0 meaning I'll collect all info.
    Then include it in your filter. You Get-WinEvent becomes:
    Get-WinEvent -FilterXml "<QueryList><Query Id=""0"" Path=""Security""><Select Path=""Security"">*[System[(EventID=4624 and EventRecordID&gt;$_intMyRef)]]</Select><Suppress Path=""Security"">*[EventData[Data[@Name=""SubjectLogonId""]=""0x0"" or Data[@Name=""TargetDomainName""]=""NT AUTHORITY"" or Data[@Name=""TargetDomainName""]=""Window Manager""]]</Suppress></Query></QueryList>"
    At the end of your script, store the last value you got into your ref.txt file. So you can for example get that info in the loop. Like:
    $Result += $LogonRecord
    $_intLastId = $Event.RecordId
    And at the end:
    Write-Output $_intLastId | Out-File .\ref.txt
    Then next time you run it, it is just scanning the delta. Note that I prefer this versus the date filter in case of the machine wasn't active for long or in case of time sync issue which can sometimes mess up with the date based filters.
    If you want to go for a date filtering, do it at the Get-WinEvent level, not in the Where-Object. If the query is local, it doesn't change much. But in remote system, it does the filter on the remote side therefore you're saving time and resources on your
    side. So for example for the last 30 days, and if you want to use the XMLFilter parameter, you can use:
    <QueryList>
    <Query Id="0" Path="Security">
    <Select Path="Security">*[System[TimeCreated[timediff(@SystemTime) &lt;= 2592000000]]]</Select>
    </Query>
    </QueryList>
    Then you can combine it, etc...
    PS, I used the confusing underscores because I like it ;)
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Remove event listener from loaded external swf

    I have a main movie timeline that loads an external swf. When I unload the swf from the main timeline I get an error from this:  my_FLVPlybk.addEventListener(VideoEvent.COMPLETE, vidEnd);
    is there any way to remove the event listener from the loaded swf from the main timeline?
    THANKS!

    if you're publishing for fp 10+, use unloadAndStop() applied to your swf's loader.  that has a fair chance of solving the problem.
    if that fails, you should explicitly stop my_FLVPlybk.

  • How to remove event listener when all the MoviClip are off the stage

    Hi i am newbie to as3,
        I am creating animation using as3 in which i duplicate the circle ten time,then pushing into an array and giving random motion. When all the duplicate object goes outside the stage then i should remove the event listener. But right now when one duplicate object goes off the stage the event listener is removed. Thanks in advance

    //---------code for creating random bubble movement------//
    var bubbleNo:Number = 10;
    var vx:Number = .3;
    var vy:Number = .5;
    var bubbles:Array = new Array();
    var bubbleRadius:Number = 9;
    var myColor:ColorTransform = this.transform.colorTransform;
    init();
    function init():void {
    for(var i:Number = 0; i<bubbleNo; i++){
              var bubble = new newBall();
    bubble.x = Math.random() * stage.stageWidth;
    bubble.y = Math.random() * stage.stageHeight;
    //bubble.color = Math.random
    //trace("bubble.x=="+bubble.x+"bubble.y=="+bubble.y);
    bubbles.push(bubble);
    myColor.color = Math.random() * 0xFFFFFF
    bubble.transform.colorTransform = myColor;
    addChild(bubble);
              addEventListener(Event.ENTER_FRAME,createBubble);
    //addEventListener(Event.ENTER_FRAME,createBubble);
    function createBubble(event:Event):void{
    for(var k:Number = bubbles.length-1; k>0; k--){
              var bubble = (newBall)(bubbles[k]);
              bubble.x += vx;
              bubble.y += vy;
              if(bubble.x - 18 > stage.stageWidth || bubble.x + 18 < 0  || bubble.y - 18 > stage.stageHeight || bubble.y + 18 < 0){
                        removeChild(bubble);
                        bubbles.splice(k, 1);
                        //trace("out"+bubbles.length);
                        if(bubbles.length <= 0 );
                                  removeBubble();
                                  trace(bubbles.length);
                                  //removeEventListener(Event.ENTER_FRAME,createBubble)
                        trace("all Bubbles cleared");
                        function removeBubble():void{
                                  removeEventListener(Event.ENTER_FRAME,createBubble)

  • Remove button from Ribbon in a specific toolbar

    Hi,
    I have created a custom list using feature. the list contains 7 content types inheriting from another custom content type. I have set the toolbar type for different views to "None".
    I want to remove the attach file option from Actions group in Ribbon. I tried the solution given in
    http://sharepoint.stackexchange.com/questions/32606/remove-button-from-ribbon-in-a-specific-toolbar
    by specifying custom action with
     the Registration type "ContentType" and registration Id "Content Type Id" for all the content types.
    <CustomAction
    Id="RemoveUploadButton"
    Location="CommandUI.Ribbon"
    RegistrationType="ContentType"
    RegistrationId="{firstcontenttypeid}">
    <CommandUIExtension>
    <CommandUIDefinitions>
    <CommandUIDefinition
    Location="Ribbon.ListItem.Actions" />
    </CommandUIDefinitions>
    </CommandUIExtension>
    </CustomAction>
    <CustomAction
    Id="RemoveUploadButton"
    Location="CommandUI.Ribbon"
    RegistrationType="ContentType"
    RegistrationId="{secondcontenttypeid}">
    <CommandUIExtension>
    <CommandUIDefinitions>
    <CommandUIDefinition
    Location="Ribbon.ListItem.Actions" />
    </CommandUIDefinitions>
    </CommandUIExtension>
    </CustomAction>
    but still the attach file option is appearing in ribbon under item tab. When I set the toolbar type to "Standard" attach file option disappear.
    Please help. TIA
    -Harry

    Hi,
    I tried to reproduced your issue like this: Create a custom Item Content Type, apply it to a custom list. Then I create a custom action for this custom Content Type with the
    code you provided.
    The outcome is: When I set the Toolbar Type as “Full Toolbar” or “Show Toolbar”, the “Attach File” button disappear as expected, when I set the Toolbar Type as “Summary Toolbar”
    or “No Toolbar”, the “Attach File” button appears again.
    Anyway, I will try to work on it or involve someone familiar with this topic to further look at this issue.
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Patrick Liang
    TechNet Community Support

  • Help with event listener

    I'm having some trouble trying to figure out how this event listener will work.
    The main application is building an arrayCollection of a calendarDay custom components which is displayed by a DataGroup.
    Within each calendarDay custom component i may create an arrayList of a DriverDetailComponent custom components displayed within the calendarDay by a DataGroup.
    If a user double clicks on the DriverDetailComponent that is two layers in I would like to change states of the main application.  I'm having trouble figuring out what item in the main application to set the listener on.  Please help.
    I can't figure out how to post the below as scrollable code snips so this is very long.
    Main application code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="components.*"
                   preinitialize="readDataFile()"
                   creationComplete="buildRowTitles()"
                   width="1024" height="512"  backgroundColor="#A4BDD8">
        <s:states>
            <s:State name="State1"/>
            <s:State name="driverDetailState"/>
        </s:states>
        <!--
        <fx:Style source="EventCalendar.css"/>
        creationComplete="readDataFile()"    creationComplete="driversList.send()"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->       
            <mx:DateFormatter id="myDateFormatter"
                              formatString="EEE, MMM D, YYYY"/>
            <!--<s:HTTPService id="driversList"
                           url="files/drivers.xml"
                           result="driversList_resultHandler(event)"
                           fault="driversList_faultHandler(event)"/>
            <s:HTTPService id="postDriversList"
                           url="files/drivers.xml"
                           method="POST"
                           result="postDriversList_resultHandler(event)"
                />-->
            <!--<s:Move id="expandTab"
                    target="{labelTab}"
                    xBy="250"/>-->
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.TruckDriver;
                import components.calendarDay;
                import events.CancelChangeDriversEvent;
                import events.ChangeDriversEvent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.containers.Form;
                import mx.controls.Alert;
                import mx.controls.CalendarLayout;
                import mx.core.FlexGlobals;
                import mx.core.IVisualElement;
                import mx.core.WindowedApplication;
                import mx.printing.FlexPrintJob;
                import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
                import mx.rpc.xml.SimpleXMLEncoder;
                import spark.components.Application;
                import utilities.FormatUtil;
                import utilities.ObjectToXML;
                /* public var prefsFile:File; */ // The preferences prefsFile
                [Bindable] public var driversXML:XML; // The XML data
                public var stream:FileStream; // The FileStream object used to read and write prefsFile data.
                public var fileName:String="driversArrayCollection";
                public var directory:String = "AceTrackerData";
                public var dataFile:File = File.documentsDirectory.resolvePath(directory + "\\" + fileName);
                [Bindable]
                public var drivers:ArrayCollection=new ArrayCollection();
                private var fileStream:FileStream;
                [Bindable]
                public var calendarDayArray:ArrayCollection = new ArrayCollection;
                public var i:int;
                [Bindable]
                public var weekOneTitle:String;
                [Bindable]
                public var weekTwoTitle:String;
                [Bindable]
                public var weekThreeTitle:String;
                [Bindable]
                public var weekFourTitle:String;
                public var day:Object;
                protected function readDataFile():void
                    if(dataFile.exists)
                        fileStream = new FileStream();
                        fileStream.open(dataFile, FileMode.READ);
                        drivers = fileStream.readObject() as ArrayCollection;
                        fileStream.close();
                    else
                        drivers = new ArrayCollection();
                        var driver:TruckDriver = new TruckDriver("New", "Driver", 000);
                        drivers.addItem(driver);
                        saveData(drivers);
                    buildCalendarArray();
                protected function buildCalendarArray():void
                    calendarDayArray.removeAll();
                    for (i=0; i<28; i++)
                        var cd:calendarDay = new calendarDay;
                        cd.dateOffset= i-7
                        cd.drivers=drivers;
                         cd.addEventListener("editDriverEvent",editDriverEvent_Handler);
                        calendarDayArray.addItem(cd);
              private function saveData(obj:Object):void//this is called on the postDriversList result handler to create and write XML data to the file
                    var fs:FileStream = new FileStream();
                    fs.open(dataFile, FileMode.WRITE);
                    /* fs.writeUTFBytes(myXML); */
                    fs.writeObject(drivers);
                    fs.close();
                protected function driverschedule1_changeDriversHandler(event:ChangeDriversEvent):void
                    saveData(drivers); 
                    readDataFile();//i read the drivers file again, this refreshes my data, and removes any temporary data that may have been stored in the drivers array
                    buildCalendarArray();
                    currentState = 'State1';//this hides the driversdetail window after we've clicked save
                    /* postDriversList.send(event.driverInfo); */  //this needs to be different
                    /* Alert.show("TEST"); */
                protected function driverschedule1_cancelChangeDriversHandler(event:CancelChangeDriversEvent):void
                    /* Alert.show("Changes have been canceled."); */
                    readDataFile();//this re-reads the saved data file so that the changes that were made in the pop up window
                    // are no longer reflected if you reopen the window
                    buildCalendarArray();
                    currentState = 'State1';  //this hides the driversdetail window after we've clicked cancel
                protected function buildRowTitles():void
                    var calendarDay0:Object;
                    var calendarDay6:Object;
                    calendarDay0=calendarDayArray.getItemAt(0);
                    calendarDay6=calendarDayArray.getItemAt(6);
                    weekOneTitle = calendarDay0.getDayString() + " - " + calendarDay6.getDayString();
                    weekTwoTitle=calendarDayArray.getItemAt(7).getDayString()+ " - " + calendarDayArray.getItemAt(13).getDayString();
                    weekThreeTitle=calendarDayArray.getItemAt(14).getDayString()+ " - " + calendarDayArray.getItemAt(20).getDayString();
                    weekFourTitle=calendarDayArray.getItemAt(21).getDayString()+ " - " + calendarDayArray.getItemAt(27).getDayString();
            ]]>
        </fx:Script>
        <s:Group height="100%" width="100%">
            <s:layout>
                <s:BasicLayout/>  <!--This is the outermost layout for the main application MXML-->
            </s:layout>
        <s:Scroller width="95%" height="100%"  >
        <s:Group height="100%" width="100%"  ><!--this groups the vertically laid out row titles hoizontally with the large group of calendar days and day titles-->
            <s:layout>
                <s:HorizontalLayout/>
            </s:layout>
        <s:Group height="95%" width="50" ><!--this is the group of row titles layed out vertically-->
            <s:layout>
                <s:VerticalLayout paddingLeft="40" paddingTop="35"/>
            </s:layout>
            <s:Label text="{weekOneTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekTwoTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center" />
            <s:Label text="{weekThreeTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
            <s:Label text="{weekFourTitle}"
                     rotation="-90"
                     backgroundColor="#989393"
                     height="25%" width="115"
                     fontWeight="normal" fontSize="15"
                     paddingTop="4" textAlign="center"  />
        </s:Group>
        <s:Group height="100%" width="100%" >
            <!--this vertically groups together the horizontal day names group and the tile layout datagroup of calendar days-->
            <s:layout>
                <s:VerticalLayout paddingLeft="5"/>
            </s:layout>
        <s:Group width="100%" >
            <s:layout><!--this group horizontal layout is for the Day names at the top-->
                <s:HorizontalLayout paddingTop="10"/>
            </s:layout>
            <s:Label id="dayNames" text="Sunday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Monday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Tuesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Wednesday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Thursday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Friday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
            <s:Label text="Saturday" width="16%" fontWeight="bold" fontSize="18" textAlign="center"/>
        </s:Group>
            <!--<s:SkinnableContainer width="16%">-->
                <s:DataGroup id="calendarDataGroup"
                             dataProvider="{calendarDayArray}"
                             itemRenderer="{null}"  resizeMode="scale"
                              height="100%" width="100%"
                              >  <!--  I had to use a null renderer because otherwise each instance is added in a group container renderers.DriverScheduleRenderer-->
                    <s:layout >
                        <s:TileLayout requestedColumnCount="7" />
                    </s:layout>
                </s:DataGroup>
            <!--</s:SkinnableContainer>-->
        <!--<mx:FormItem label="Today's Date:">
            <s:TextInput id="dateToday"
                         text="{myDateFormatter.format(testDate)}"/>
        </mx:FormItem>-->
        <!--<components:DriverSchedule drivers="{drivers}"
                                   changeDriversEvent="driverschedule1_changeDriversHandler(event)"/>-->
            <s:HGroup>  <!--this groups together my drivers button and my print button at the bottom of the calendar-->
            <s:Button id="showDriverDetailButton"
                      label="Driver List"
                      click="currentState = 'driverDetailState'">
                <!--</s:Button>
                <s:Button id="printButton"
                    label="Print"
                    >  click="printButton_clickHandler(event)"-->
                </s:Button>
            </s:HGroup>    <!--this is the end of the small hgroup which pairs my drivers button with the print button-->                  
        </s:Group><!--this ends the vertical grouping of the day names and the tile layout calendar-->   
    </s:Group>        <!--this ends the horizontal grouping of the calendar (names and days) with the week labels at the left-->
        </s:Scroller>
            <s:SkinnableContainer includeIn="driverDetailState"
                                  width="95%" height="95%"  horizontalCenter="0" verticalCenter="0"
                                  backgroundColor="#989898" backgroundAlpha="0.51">
                <s:BorderContainer horizontalCenter="0" verticalCenter="0">
                <components:DriverSchedule id="driverSchedule"
                                            drivers="{drivers}"
                                           changeDriversEvent="driverschedule1_changeDriversHandler(event)"
                                           cancelChangeDriversEvent="driverschedule1_cancelChangeDriversHandler(event)"
                                           />
                </s:BorderContainer>
            </s:SkinnableContainer>
        </s:Group>  <!--end of basic layout group-->
    </s:WindowedApplication>
    </code>
    calendarDay.mxml code:
    <code>
    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx"
             creationComplete="initDay()"
              width="100%">  <!--width="16%" height="25%"  width="160" height="112"-->
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
            <mx:DateFormatter id="myDateFormatter"
                              formatString="MMM D"/>
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import components.CalendarDay;
                import components.DriverDetailComponent;
                import events.EditDriverEvent;
                import mx.collections.ArrayCollection;
                import mx.collections.ArrayList;
                import mx.controls.CalendarLayout;
                import mx.controls.DateField;
                [Bindable]
                public var todayCollection:ArrayCollection = new ArrayCollection;
                [Bindable]
                public var todayList:ArrayList=new ArrayList; //arraylist created as data provider for dataGroup, this is where all drivers with an arrival date of today are added
                [Bindable]
                public var currDate:Date =new Date; //this will be used to contain the current real world date
                [Bindable]
                public var calDate:Date = new Date; //this is used below to determine the date of the calender day that is being created
                [Bindable] 
                public var todaysDate:CalendarDay;
                [Bindable]
                public var currDay:int;
                [Bindable]
                public var dateOffset:int;
                public var drivers:ArrayCollection= new ArrayCollection();
                   public var driver:Object;  
                public var rowLabel:String;
                public function initDay():void
                    todaysDate  = new CalendarDay(currDate, currDate.day, dateOffset)//currDate represents the day the operating system says today is
                        currDay=todaysDate.returnDate().getDate();//currDay is an int representing the day of the month
                        calDate=todaysDate.returnDate();//calDate represents the actual date on the calendar (MM-DD-YYY) that is currently being evaluated
                        /* if (currDay ==currDate.getDate()) //i want to highlight the day if it is in fact today
                            cont.styleName="Today";
                            if (calDate.getDate() == currDate.getDate())
                            calDayBorder.setStyle("backgroundColor", "#FFFF00");
                        else
                            calDayBorder.setStyle("backgroundColor", "#EEEEEE");
                         addDrivers(); 
                    return;
                  public function addDrivers():void
                       var count:int = 0;
                      /*var driverDetail:DriverDetailComponent;
                      var driver =  */
                    for each (driver in drivers)
                    {//i check the date value based on data entry of mm-dd-yy format against the calculated date for the day
                        //the calender is building and if it is equal the drivers information is added to this day of the calendar
                        if (DateField.stringToDate(driver.arrivalDate,"MM/DD/YYYY").getDate() == calDate.getDate())
                                var driverDetail:DriverDetailComponent = new DriverDetailComponent; //i create a new visual component that adds the id and destination to the calendar day
                                driverDetail.driverid = drivers[count].id; //i feed the id property which is the truck# - firstName
                                driverDetail.driverToLoc=drivers[count].toLoc; //i feed the toLoc which is the current destination of the driver
                                driverDetail.driverArrayLocation=count;   //here i feed the location of this driver in the "drivers" array so i know where it's at for the click listener
                                todayList.addItem(driverDetail);
                            //this concatenates the drivers truck number first name and destination to display in the calendar day
                                /* todayList.addItem(driver.truckNumber + " - " + driver.firstName + " - " + driver.toLoc); */
                    count ++;
                public function getDayString():String
                    rowLabel =myDateFormatter.format(calDate);
                    return rowLabel;
            ]]>
        </fx:Script>
        <s:BorderContainer id="calDayBorder" width="160" styleName="Today" cornerRadius="2" dropShadowVisible="true" height="100%">
            <s:layout>
                <s:BasicLayout/>   
            </s:layout>
            <!--I need to make a custom item renderer for my calendar days that limits the height and width of the day, and also puts the items
            closer together so i can fit maybe 5 drivers on a single day-->
            <s:DataGroup dataProvider="{todayList}"
                         itemRenderer="spark.skins.spark.DefaultComplexItemRenderer"
                         bottom="-2"
                         width="115" left="2">  <!--width="94%"  width="100"  width="16%"-->
                <s:layout >
                    <s:VerticalLayout gap="-4"/> <!--The reduced gap pushes the drivers together if there are serveral on one day. This helps cleanly show several drivers on one day-->
                </s:layout>
            </s:DataGroup >
            <s:Label  text="{currDay}" right="3" top="2" fontSize="14" fontWeight="bold"/>
        </s:BorderContainer>
    </s:Group>
    </code>
    DriverDetailComponent code:
    <code><?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             xmlns:mx="library://ns.adobe.com/flex/mx">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <fx:Metadata>
            [Event(name = "editDriverEvent", type="events.EditDriverEvent")]
        </fx:Metadata>
        <fx:Script>
            <![CDATA[
                import events.EditDriverEvent;
                import mx.controls.Alert;
                [Bindable]
                public var driverid:String;
                [Bindable]
                public var driverArrayLocation:int;
                [Bindable]
                public var driverToLoc:String;
                protected function label1_doubleClickHandler(event:MouseEvent):void
                    Alert.show("You have selected " +driverid +" at location "  + driverArrayLocation.toString() +" in the drivers ArrayCollection.");
                    var eventObject:EditDriverEvent = new EditDriverEvent("editDriverEvent",driverArrayLocation);
                    dispatchEvent(eventObject);
            ]]>
        </fx:Script>
        <s:Label id="driverDetailLabel" text="{driverid} - {driverToLoc}"  doubleClick="label1_doubleClickHandler(event)" doubleClickEnabled="true"/>
    </s:Group>
    </code>

    lkb3 wrote:
    I'm trying to add a listener to [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|my dialog box], so that when it pops up, the cursor is in the text box, but then if the user clicks a button other than the default, the cursor reverts back into the text box.
    The code I have is this:
      // BUILD DIALOG BOX
    JLabel option_label = new JLabel("Select a search option:");
    // Create the button objects
    JRadioButton b1 = new JRadioButton("Search PARTS by name");
    JRadioButton b2 = new JRadioButton("Search ASSEMBLIES by name");
    JRadioButton b3 = new JRadioButton("Search DRAWINGS by name");
    JRadioButton b4 = new JRadioButton("Search all by DESCRIPTION");
    b1.setSelected(true);
    // Tie them together in a group
    ButtonGroup group = new ButtonGroup();
    group.add(b1);
    group.add(b2);
    group.add(b3);
    group.add(b4);
    // Add them to a panel stacking vertically
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
    panel.add(b1);
    panel.add(b2);
    panel.add(b3);
    panel.add(b4);
    JLabel name_label = new JLabel("Enter a search term (add *'s as required)");
    JTextField name = new JTextField(30);
    name.addComponentListener(new ComponentListener() {
    public void componentHidden(ComponentEvent ce) { }
    public void componentMoved(ComponentEvent ce) { }
    public void componentResized(ComponentEvent ce) {
    ce.getComponent().requestFocus();
    public void componentShown(ComponentEvent ce) { }
    Object[] array = { option_label, panel, name_label, name };
    // GET INPUT FROM USER
    int res = JOptionPane.showConfirmDialog(null, array, "Select", JOptionPane.OK_CANCEL_OPTION);
    String searchTerm = name.getText();This sucessfully has the focus in the text box when opened; is there a way to get the focus to go back into the text box after the user clicks a radio button?
    Thanks!
    [this JOptionPane pane dialog box|http://beidlers.net/photos/d/516-1/search_screenshot.JPG|dialog Joption]
    you will need to add ItemListener to the JRadioButtons

  • URGENT : EVENT Listener Problem

    Hi All,
    Thanks for your time. I am facing a Small issue with Event
    dispatcher and Add Event listener. Well i will explain the problem.
    I am having one MovieClip named BUTTON_SET and i gave
    "ButtonSet.as" as linkage Class.
    Inside that BUTTON_SET i am having some Buttons and they are
    also having "UIButton.as" as linkage class
    UIButton Dispatching press and release events, But unable to
    capture it using ButtonSet Class. Here with i have attached the
    Code and i gave the Source URL Too.
    upto my Knowledge : UIButton class is not initiated When the
    ButtonSet is ready to addListener.
    Please Help me to fix this.
    if i don't find a solution i need to change all my class
    structures.
    CLICK HERE FOR SOURCE
    CODE

    According to your Code, When you are calling the InitHandler
    Functionction the Buttons may/may not be Initiated. So use the
    Enterframe to check whether its loaded or not.
    Write down this in the ButtonSet to replace the init Handler
    Call.
    this.onEnterFrame = Delegate.create(this, initHandler);
    inside the initHandler remove the function This will help you
    if you are not using any Enterframe for any other manipulation)
    delete this.onEnterFrame;

  • How to add event listener?

    i want to add event listener when i click on a button in mxml, the event listener should be added in the action script file, how to do this?
    can anyone help? urgent!!!

    Hi Lakshmi,
    You can do this just put all the script in the mxml block in seperate AS file as shown below... Observe that I have included an AS file named Script.as and removed the script block form mxml and moved to this Script.as file. Place the Script.as file in your src folder ....
    // Main mxml file....
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="onCreationComplete()">
        <mx:Script source="Script.as"/>
    <mx:TextArea id="textArea" width="300" height="100" />
    <mx:Button id="myButton" label="Click ME"/>
    </mx:Application>
    //Script.as file
    import mx.controls.Alert;
                private function onCreationComplete():void
                 myButton.addEventListener(MouseEvent.CLICK, onButtonClick);
                private function onButtonClick(event:MouseEvent):void
                 Alert.show("Button is Clicked");
    Thanks,
    Bhasker

Maybe you are looking for