How to create many objects listening for one event

I'm experimenting with the EventDispatcher class and I have a
test class working. I want to use a loop to create a variety of
movie clips that all listen for an event that gets dispatched every
half a second. I have the event dispatching properly. My problem is
that when creating the objects, the temporary variable I use to
hold each created object has a life that extends beyond the loop in
which it is instantiated. Rather than all five created objects
changing color, only the last one changes color (see the code
below--it lives on the first frame of an FLA file).
This is not entirely surprising when I look at the code --
'this' refers to the global scope and 'square' refers to the last
created object that it pointed to. Here's the resulting trace:
handler runing, square name is square 4
this class name is global
handler runing, square name is square 4
this class name is global
handler runing, square name is square 4
this class name is global
handler runing, square name is square 4
this class name is global
handler runing, square name is square 4
this class name is global
How can I modify this code so that each square object changes
its own color?

graphics.clear in the context of that function handler in my
code would refer not to the squares but to the global scope,
wouldn't it? In which case you'd be clearing all the graphics from
your top level movie. I tried changing 'square.graphics' to just
'graphics' in my handler and my squares just remained the original
steady black.
Your code doesn't use a loop and therefore isn't re-using a
variable. You've escaped my 'logical errors' through brute force.
(BTW, I think my code would work in AS2 if I used the old-school
draw methods). Suppose you had to create 100 objects? Would you
want to manually instantiate each one, typing that function over
and over again? You'd have 500 lines of highly redundant code!
Maybe try your example using a loop instead? I think you'll
find it's pretty tough to sneak any vars like 'i' or 'square' from
the global scope into the handler--the handler refers to the
living, breathing variable rather than it's value at the time the
handler was instantiated. Furthermore, you can't sneak any
information about the square into your handler via the event object
because the event object is created in a totally different place.

Similar Messages

  • How to create a sales order for one-time customer

    Hi all,
    I have a requirement where in creating a sales order, I have to add the tax code for one-time customer. This is not the tax jurisdiction but it is a text field that you can see in Further attributes and it will store in VBPA3 table.
    My plan was create sales order first using SD_SALESDOCUMENT_CREATE or BAPI_SALESORDER_CREATEFROMDAT2. Then I used BDC of va02 for changing the salesdoc. But the problem is, we can't proceed because there's a message "TAX HAVE REDETERMINED"  that it doesn't included in recording a transaction.
    Another one is, instead of calling the standard bapi, I used BDC for VA01. Again, upon recording there was anothe message popped up "FREIGHT REDETERMINED". And it's not in the recording so we can't proceed.
    Would you know what field is for the tax code when I use SD_SALESDOCUMENT_CREATE or any standard bapi? Is there other way aside from calling a standard bapi or bdc?
    Points will be given..Thanks!

    Good afternoon Bella,
    We are in a project that exactly need this solution. Could yoy please explain me how you solve the issue ?
    Kind regards

  • How to create multiple accouting documents for one invoice for diff curr

    Hi experts/gurus,
    I have a requirement where we need to create two two different accounting documents for one invoice. The scenario is this:
    1) We are exporting goods to oversea customer, as such the currency is bill in USD
    2) We also have transportation charges using another condition type, we need to capture this charges/accrual in local currency which is MYR.
    Currently, the system will automatically convert the transporation charges to USD when we create the invoice and the accounting document will be generated in USD for both sales and transport charges.
    is there a way to fullfil the above requirement, any setting in condition type or any user exists we can used to create hte accounting documents.
    Any ideas/input is highly appreciated, points will be awarded

    Hi Wan,
       The following user exits are available in report SAPLV60B for transfer to accounting (function group V60B): So please go through these.
    ·EXIT_SAPLV60B_001: Change the header data in the structure acchd
    You can use this exit to influence the header information of the accounting document. For example, you can change the business transaction, "created on" date and time, the name of the person who created it or the transaction with which the document was created.
    ·EXIT_SAPLV60B_002: Change the customer line ACCIT
    You can use this exit to change the customer line in the accounting document. This exit is processed once the ACCIT structure is filled in with data from document header VBRK.
    ·EXIT_SAPLV60B_003: Change the customer line in costing
    The customer line is filled in differently for costing. You can use exit 003 to influence the ACCIT structure.
    ·EXIT_SAPLV60B_004: Change a GL account item ACCIT You can add information to a GL account item (such as quantity specifications) with this exit.
    ·EXIT_SAPLV60B_005: User exit for accruals
    Once all relevant data for accruals was entered in the GL account item, you can add to this data with this exit.
    ·EXIT_SAPLV60B_006: Change the control line ACCIT
    You can use exit 006 to add information to the control line.
    ·EXIT_SAPLV60B_007: Change the installment plan
    You can use exit 007 to add information to the installment plan
    parameters in the GL account item.
    ·EXIT_SAPLV60B_008: Change the transfer structure ACCCR, ACCIT and ACCHD
    After the accounting document is filled in with data, you can use exit 008 to change the document once again.
    ·EXIT_SAPLV60B_010: Item table for customer lines
    You can use exit 10 to influence the contents of customer lines before they are created.
    ·EXIT_SAPLV60B_0011: Change the parameter for cash account determination or reconciliation account determination
    You can use this exit to change inbound parameters in order to influence account determination.
    I hope any one of these will solve your problem
    Thanks,
    Murali.

  • I need help figuring out how to creat a button listener for my panel

    import java.awt.*;
       import java.awt.event.*;
       import javax.swing.*;
       import java.util.Scanner;
        public class ExpressionCalculatorPanel extends JPanel
       // Variables to be used
          private JLabel inputLabel, resultLabel;
          private JTextField ExpressionCalculator;
          private JButton computeButton;
       //  Constructor: Sets up the main GUI components.
           public ExpressionCalculatorPanel()
             inputLabel = new JLabel ("Enter a value of x");
             resultLabel = new JLabel ("Final result = ---");
             ExpressionCalculator = new JTextField (5);
             ExpressionCalculator.addActionListener(new ButtonListener());
               // Set buttons and listeners
             computeButton = new JButton("Compute Final Result");
             computeButton.addActionListener(new ButtonListener());
               // Add to panels
             add (computeButton);
             add (inputLabel);
             add (resultLabel);
             setPreferredSize (new Dimension(300, 75));
             setBackground (Color.white);
       //  Represents an action listener for the temperature input field.
           private class ButtonListener implements ActionListener
          //  Performs the conversion when the enter key is pressed in
          //  the text field.
              public void actionPerformed (ActionEvent event)
       }

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Scanner;
    public class ExpressionCalculatorPanel extends JPanel
    // Variables to be used
    private JLabel inputLabel, resultLabel;
    private JTextField ExpressionCalculator;
    private JButton computeButton;
    // Constructor: Sets up the main GUI components.
    public ExpressionCalculatorPanel()
    inputLabel = new JLabel ("Enter a value of x");
    resultLabel = new JLabel ("Final result = ---");
    ExpressionCalculator = new JTextField (5);
    ExpressionCalculator.addActionListener(new ButtonListener());
         // Set buttons and listeners
    computeButton = new JButton("Compute Final Result");
    computeButton.addActionListener(new ButtonListener());
         // Add to panels
    add (computeButton);
    add (inputLabel);
    add (resultLabel);
    setPreferredSize (new Dimension(300, 75));
    setBackground (Color.white);
    // Represents an action listener for the temperature input field.
    private class ButtonListener implements ActionListener
    // Performs the conversion when the enter key is pressed in
    // the text field.
    public void actionPerformed (ActionEvent event)
    }

  • How to enter many receiving lines for one PO Line

    Hi,
    we are working in oracle applications 11i
    From Oracle Inventory Responsibility->Transactions->Receiving: Enter Purchase Order Number: Receipts Window:
    we have a line with item quantity of 100 (for example). I need to receive that item on many lines (depending on our descriptive flexfield inputs).
    how do you suggest I enter those receiving lines for the PO LINE? I can see that I cannot I enter lines in that window so I am not sure If I can use dataload.
    I need a solution that can be applied to receiving transactions window too.
    Any ideas please?

    If you enter a partial Qty and save it, then it will be a seperate line on the receipt.
    Ex: Rcpt 120 first time rcv 10, next enter the same info and then use Add to receipt button and enter rcpt number i.e. 120 and enter the next Qty say 30.
    Now if you query view Receving Txns form for rcpt 120 you will see 10,30 on separate lines. If you want suggestions on how much to enter on each line is going to be challenging (may be using the note to reciver can help)

  • Create Component that Listens for Custom Event

    I've read a lot of tutorials and posts in this forum but still seem to be missing something.
    I want to be able to create an arbitrary number of instances of a custom class (based on Button) that each listen to a custom event dispatched in the application.  Eventually the event will carry data (including information that will let each Button determine whether it should react to the event), but for now I just want them to be able to hear the event.
    What's supposed to happen is
    1) Clicking the button labeled "I Make the Button" creates an instance of EventHearingButton using this.addElement.
    2) Clicking the button labeled "I Send the Event" dispatches the SuperCustomEvent custom event, with the additional information "I heard that" stored in the Information string
    3) The created EventHearingButton hears the event and updates its label to the value in the Information string.
    What actually happens is the EventHearingButton is created OK, but nothing happens when the "I Send the Event" button is clicked.
    Main.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                      xmlns:s="library://ns.adobe.com/flex/spark"
                      xmlns:mx="library://ns.adobe.com/flex/halo">
         <fx:Metadata>
              [Event(name="SuperCustomEvent", type="Classes.SuperCustomEvent")]
         </fx:Metadata>
         <fx:Script>
              <![CDATA[
                   import Classes.EventHearingButton;
                   import Classes.SuperCustomEvent;
                   protected function EventDispatcherButton_clickHandler(event:MouseEvent):void
                        var NewEvent:SuperCustomEvent = new SuperCustomEvent("I heard that");
                        this.dispatchEvent(NewEvent);
                   protected function button1_clickHandler(event:MouseEvent):void
                        var NewButton:EventHearingButton = new EventHearingButton();
                        NewButton.x=270;
                        NewButton.y=130;
                        this.addElement(NewButton);
              ]]>
         </fx:Script>
         <s:Button x="270" y="90" label="I Send The Event" id="EventDispatcherButton" click="EventDispatcherButton_clickHandler(event)"/>
         <s:Button x="270" y="50" label="I Make the Button" click="button1_clickHandler(event)"/>
    </s:Application>
    Classes.EventHearingButton.as
    package Classes
         import spark.components.Button;
         import flash.events.Event;
         import Classes.SuperCustomEvent;
         public class EventHearingButton extends Button
              public function EventHearingButton()
                   super();
                   this.label="I haven't heard yet";
                   this.addEventListener(SuperCustomEvent.SUPERCUSTOMEVENT,SuperCustomEventHandler);
              private function SuperCustomEventHandler(event:SuperCustomEvent):void {
                   this.label=event.EventInformation;
    Classes.SuperCustomEvent.as
    package Classes
         import flash.events.Event;
         public class SuperCustomEvent extends Event
              public var EventInformation:String;
              public static const SUPERCUSTOMEVENT:String = "SuperCustomEvent";
              public function SuperCustomEvent(Information:String)
                   super(SuperCustomEvent.SUPERCUSTOMEVENT, true);
                   this.EventInformation=Information;
              override public function clone():Event{
                   return new SuperCustomEvent(EventInformation);

    "nikos101" <[email protected]> wrote in
    message
    news:ga59t5$8nh$[email protected]..
    >I tried something like what AMy described in a custom
    component
    >
    > dispatchEvent(new Event("Cancelled_Form"));
    >
    > I then added the following Listener in my application
    file;
    >
    > this.addEventListener("Cancelled_Form",cancelledForm);
    >
    > but it is never heard. Does anyone know what I have done
    wrong?
    Try attaching the event listener to your component rather
    than the
    application.
    HTH;
    Amy

  • How to create an update listener using event notification in MDM Java2 API.

    Hi folks,
    I need some help on how to create an update listener for Customer updates in MDM using notification API. Could some one point me to where I should start. We are still using SP5.
    Thanks
    -Sai

    Hi All,
    I need to create update listener with notifications and it is giving this error.
    Nov 14, 2008 12:26:21 PM com.sap.mdm.internal.net.ConnectionImpl finalize
    INFO: Disconnect was not called. Cleaning up connection in finalize.
    Nov 14, 2008 12:26:21 PM com.sap.mdm.internal.net.ConnectionImpl finalize
    INFO: Disconnect was not called. Cleaning up connection in finalize.
    Nov 14, 2008 12:26:21 PM com.sap.mdm.internal.net.ConnectionImpl finalize
    INFO: Disconnect was not called. Cleaning up connection in finalize.
    I am still using SP05 and noticed that some mentioned that MDM4J.jar has to be used. Can someone throw some pointers how to do this with MDM4J.jar. Can I  include MDM4J.jar in the same project along with mdm-admin.jar, mdm-core.jar, mdm-common.jar, mdm-protocol.jar or I shoudl have only MDM4j.jar to create this listener. Any help is appreciated.
    Thanks
    -sai

  • How to create a container class for 2 object?

    I use JDK to create 2 objects, one is Customer and one is Book. I need to enqueue these 2 objects, but they canot share the same queue class. Some one told me that I can create a container class for these 2 objects but I don't know how to create it. Can some one tell me how to create the container class?

    I use JDK to create 2 objects, one is Customer and one
    is Book. I need to enqueue these 2 objects, but they
    canot share the same queue class. Some one told me
    that I can create a container class for these 2
    objects but I don't know how to create it. Can some
    one tell me how to create the container class?
    class CustomerBook{
    Book m_book;
    Customer m_customer;
    pulbic CustomerBook (Customer customer, Book book){
    m_book = book;
    m_customer = customer;
    }If you want to create a class that represents one customer and many books, do this:
    class CustomerBooks{
    Vector m_books;
    Customer m_customer;
    pulbic CustomerBook (Customer customer){
    m_books = new Vector();
    m_customer = customer;
    public void addBook (Book book){
    m_books.addElement (book);
    public void displayBooks (){
    //I assume the Book class has a toString method or something similar
    for (int i = 0;i < m_books.size();i++){
      System.out.println ("book: "+((Book)m_books.elementAt(i)).toString());

  • How to create Activex object for my Visual C++ object

    Hi,
    I am working on development on Acrobat 9.0 SDK. I am facing problem is that I can compiled Visual C++ source code to an api. I can test functions on this api on Acrobat 9.0 windows, but I could not test it on IE web browser, because I don't know how to create Activex object from my Visual C++ source code or its api.
    I read Acrobat 9 SDK document and found under C:\Acrobat 9 SDK\Version 1\PluginSupport\Tools\Visual Studio App Wizard has two files: Acro9PIWizInstaller.msi and setup.exe. I am not very sure those file are the key to help me to create Activex objects for my api.  Are they the one I need to create Activex object? If not, could you please advise me how to create Activex object for my api or C++ codes.
    Thanks a lot for any of your comments or advices.
    Thai

    Hi lrosenth,
    Thanks a lot for your information.
    My question is, on Javascript how do I call a function from .api. Below is my very simple test.
    I got a function on BasicPlugin.cpp under C:\Acrobat 9 SDK\Version 1\PluginSupport\Samples\BasicPlugin. See below.
    I added BasicPlugin.api on C:\Program Files\Adobe\Acrobat 9.0\Acrobat\plug_ins
         ACCB1 int ACCB2 MyPluginCommand() {
              int num = 5;
              return num;
    On my HTML file, I create an <Object> below:
        <OBJECT id="acrobatapp"
                classid="clsid:85DE1C45-2C66-101B-B02E-04021C009402">
        </OBJECT>
        <OBJECT id="acrobatpdf"
                classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"   >
            <Param name="SRC" value="http://www.adobe.com/devnet/acrobat/pdfs/acrobat_digital_signature_appearances_v9.pdf">
       </OBJECT>
    On my Javascript. I call function MyPluginCommand() as below, but it is not working. How do I call function MyPluginCommand() on Javascript?
         var acrobatapp= document.getElementById("acrobatapp");
         var num= acrobatapp.MyPluginCommand();
         alert(num);
    Thanks for your support,
    Thai

  • Salmple at How to Create Dynamical Object for RTTC

    Hi all, I need a sample at How to Create Dynamical Object for RTTC.
      you can help me?.

    Hello Martinez,
    I have attached a sample for structure types. With the Where-Used-List on the Create() Method of the various RTTC classes one may find more samples. If you meant with object on OO Type then it is to mention that this is not possible yet.
    Regards
      Klaus
    PROGRAM sample.
    DATA: sdescr1 TYPE REF TO cl_abap_structdescr,
          sdescr2 TYPE REF TO cl_abap_structdescr,
          tdescr1 TYPE REF TO cl_abap_tabledescr,
          tdescr2 TYPE REF TO cl_abap_tabledescr,
          tref1   TYPE REF TO data,
          tref2   TYPE REF TO data,
          comp    TYPE abap_component_tab,
          wa      TYPE t100,
          xbuf    TYPE xstring.
    FIELD-SYMBOLS: <tab1> TYPE table,
                   <tab2> TYPE table.
    sdescr1 ?= cl_abap_typedescr=>describe_by_name( 'T100' ).
    comp     = sdescr1->get_components( ).
    sdescr2  = cl_abap_structdescr=>create( comp ).
    tdescr1  = cl_abap_tabledescr=>create( sdescr2 ).
    tdescr2  = cl_abap_tabledescr=>create( sdescr2 ).
    CREATE DATA: tref1 TYPE HANDLE tdescr1,
                 tref2 TYPE HANDLE tdescr2.
    ASSIGN: tref1->* TO <tab1>,
            tref2->* TO <tab2>.
    wa-sprsl = 'E'. wa-arbgb = 'SY'. wa-msgnr = '123'. wa-text = 'first text'.   INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'D'. wa-arbgb = 'SY'. wa-msgnr = '456'. wa-text = 'second text'.  INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'D'. wa-arbgb = 'XY'. wa-msgnr = '001'. wa-text = 'third text'.   INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'D'. wa-arbgb = 'ZZ'. wa-msgnr = '123'. wa-text = 'fourth text'.  INSERT wa INTO TABLE <tab1>.
    wa-sprsl = 'E'. wa-arbgb = 'SY'. wa-msgnr = '123'. wa-text = 'ABAP is a miracle'. INSERT wa INTO TABLE <tab1>.
    EXPORT tab = <tab1> TO DATA BUFFER xbuf.
    IMPORT tab = <tab2> FROM DATA BUFFER xbuf.
    LOOP AT <tab2> INTO wa.
      WRITE: / wa-sprsl, wa-arbgb, wa-msgnr, wa-text.
    ENDLOOP.

  • Re: How to create More two class with one object

    haii,
             i have small information How to create More two class with one object,
    bye
    bye
    babu

    Hello
    I assume you want to create multiple instance of your class.
    Assuming that you class is NOT a singleton then simply repeat the CREATE OBJECT statement as many times as you need.
    TYPES: begin of ty_s_class.
    TYPES: instance   TYPE REF TO zcl_myclass.
    TYPES: end of ty_s_class.
    DATA:
      lt_itab      TYPE STANDARD TABLE OF ty_s_class
                     WITH DEFAULT KEY,
      ls_record  TYPE ty_s_class.
      DO 10 TIMES.
        CLEAR: ls_record-instance.
        CREATE OBJECT ls_record-instance.
        APPEND ls_record TO lt_itab.
      ENDDO.
    Regards
      Uwe

  • How do you create two apple ids for one email address.

    I bought two i pads for my kids. Since we have just one email address, everytime I try to create a new apple id it says I already have one. They need separate ids so their friends can facetime with one and not the other. Can't figure out how to create two apple ids with one email address.

    Donnathemom wrote:
    Well any ideas on how to solve this problem? When my daughter does facetime with someone it says she's Wyatt. She's not real happy about that. 
    Get her an email address, even if she never uses it.  They're free and available almost everywhere.  The only requirement is that the address be a valid one.
    Edit...
    You can even use an "alias" of yours.  That's a fake address that actually sends everything to you.  Check with your current email supplier.

  • How do I create 2 motion tweens for one line of text?  the text needs to "fly-in-right", I can do that,

    how do I create 2 motion tweens for one line of text?  the text needs to "fly-in-right", I can do that, then it needs to "fly-out-bottom" again, I can do that, but not on the same line of text...any ideas...

    my question
    1- there is any way to assign the Fetch process to specific region so the process take all item in these region only.
    2- how can create manual process to fetch row into specific items in page ( i tray these code
    SELECT col1, col2, col3 ....
    INTO :P1_ITEM1, :P1_ITEM, :P1_ITEM...
    FROM table
    WHERE id = :P_id ) but no data retrieve .
    I do not think that it is possible to have more than one Automated Row Fetch process in a given page. See the thread:
    ORA-01403: no data found : Unable to fetch row multiple automated row fetch
    On your second question, the manual process should work provided:
    P_ID has a value when the process executes. You can do it this way:
    i. Make this process as a on-load After/Before header process
    ii. Make sure that P_ID page item has value when the process executes (set it from another page or before the pl/sql process executes)

  • How to create a object for IPageItemControlData?

    how to create a object for IPageItemControlData?

    From the header comment you'll see that IPageItemControlData is an Interface of PageItemWidget. That must've been an InDesign 1.0 or 1.5 feature predating kPageItemBoss, because except for the same comment even in InDesign 2.0 SDK the only further reference is a copy in the comment of its sibbling IFrameControlData which was removed with InDesign CS.
    The IID and kPageItemControlDataImpl are probably only around because deep under the hood there must be some kind of conversion provider waiting to do its job on a very old document.
    I guess the closest in today's functionality will be IHierarchy.
    Dirk

  • I have create many free acounts for apple I have reached the limit of creating free acounts how can I delete that free acounts which I have made?

    I have create many free acounts for apple I have reached the limit of creating free acounts how can I delete that free acounts which I have made?

    iOS devices can only create 3 free iCloud accounts, Get a new iOS device
    why would you need more than 3 iCloud accounts for 1 device o.O

Maybe you are looking for

  • Calculating a record length of a table

    Hi All, In SAP 4.6C Oracle 9g I need to find a record length of a table.For that I am using : Table name is ABC. Tablespace in KBytes of ABC    X Total no records in ABC  Y Single record length in Kbytes (Z) =  Tablespace (X) / Total no of records(Y)

  • Error in extending EmployeeDetailsVO :

    Hi All, I am trying to extend the EmployeeDetailsVO but i am getting and unexpected error like : Each row in the Query Result Columns must be mapped to a unique Query Attribute in the Mapped Entity columns. I tried the workaround specified in the OTN

  • DNS Records Confused

    Hi everyone, I have did the transtion from Exchange 2007 to Exchange 2013. My Exchange 2007 URLS were with mail.mydomain.com and hostname of the exchange 2007 server was  mail. I came up with Exchange 2013 with hostname mail1 mail  : 192.168.1.10 (Ex

  • Flash Players communicating

    I am compiling a small chat application in Flash CS6. I am interested to know how Flash Players communicate with one another. Specifically, how do Flash players send messages back and forth to a specific peer. I know Flash players have to know their

  • Logitech Download Assistant

    how do I delete Win 8.1 file  windows/system32/rundll32.exe ? I don't have any Logitech stuff on my PC...and wish to remove it from my list of startup apps