Trouble finding a place for my event handler

I'm a newbie on my first work programme. I'm trying to teach myself JavaFX by creating a program simple Tic-Tac-Toe. I created an AnchorPane to hold the TIC-TAC-TOE grid which consists of 4 Cree-crossing lines that have been created in the JavaFX scene generator. There are 2 horizontal and 2 vertical lines. In the Java program, I loaded my FXML file and my TIC-TAC-TOE grid looks great. I created 9 ImageView that match 9 of TIC-TAC-TOE squares. I load those with x.jpg or o.jpg images. Those that work very well and I can see them on my network manually.

I can't find out how to make them appear if I click in one of the squares. I created a rectangle and is the same color as the grid and without border and place in the center square. I put a fx:id = "MMR" (medium-medium rectangle) and an onMouseClicked = "#handleRMM" in the FXML file.

I created an event handler, and I know it's because I put System.out.println ("Clicked!"); and I can see it on the NetBeans console. But the rest of the event to display the X does not appear.

I can't get to work in the main part public class handler extends Application of the program. But the AnchorPane, my ImageViews and everything is defined in part public void start (primaryStage stage) of the program. For this purpose, I can not access the ImageViews to the event handler. I will list my code, and I hope someone can tell me what I'm doing wrong. Thanks in advance.

David
package tictactoe;
 
 
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
 
/**
 *
 * @author David
 */
public class Main extends Application {
 
    
    /**
     * @param args the command line arguments
     */
    public void main(String[] args) {
        Application.launch(Main.class, (java.lang.String[])null);
    }
 
    @Override
    public void start(Stage primaryStage) {
        
        
        try {
                        
           
            AnchorPane page = (AnchorPane) FXMLLoader.load(Main.class.getResource("TicTacToe.fxml"));
            Scene scene = new Scene(page);
            
            primaryStage.setScene(scene);
            scene.getStylesheets().add("tictactoe/tictactoe.css");
            primaryStage.setTitle("TicTacToe");
            ImageView mm =new ImageView();//Middle Middle
            final ImageView lt =new ImageView();//Left Top
            final ImageView lm =new ImageView();//Left Middle
            final ImageView lb =new ImageView();//Left Bottom
            final ImageView tm =new ImageView();//Top Middle
            final ImageView bm =new ImageView();//Bottom Middle
            final ImageView rt =new ImageView();//Right Top
            final ImageView rm =new ImageView();//Right Middle
            ImageView rb =new ImageView();//Right Bottom
            //mm.setImage(new Image("tictactoe/images/x.jpg"));
           
            //page.getChildren().add(mm);
            
            mm.relocate(246,145); mm.setFitWidth(100); mm.setFitHeight(100);
            lt.relocate(107,35);
            lm.relocate(107,145);
            lb.relocate(107,260);
            tm.relocate(246,35);
            bm.relocate(246,260);
            rt.relocate(375,35);
            rm.relocate(375,145);
            rb.relocate(375,260);
            
            page.getChildren().add(mm);
            //page.getChildren().remove(mm);
            page.getChildren().add(lt);
            page.getChildren().add(lm);
            page.getChildren().add(lb);
            page.getChildren().add(tm);
            page.getChildren().add(bm);
            page.getChildren().add(rt);
            page.getChildren().add(rm);
            page.getChildren().add(rb);
        
            primaryStage.show();  
            
        
        }
           
                             
     
        
        catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
                    }
            
    
    }

     
    public void handleRMM() {
        
       ImageView mm =new ImageView();
        mm.relocate(246,145); mm.setFitWidth(100); mm.setFitHeight(100);
        mm.setImage(new Image("tictactoe/images/x.jpg"));
        
        System.out.println("Clicked!");
    }
    
}
and my FXML file:
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?scenebuilder-stylesheet tictactoe.css?>

<AnchorPane id="AnchorPane" fx:id="anchor" prefHeight="400.0" prefWidth="600.0" style="" xmlns:fx="http://javafx.com/fxml" fx:controller="tictactoe.Main">
  <children>
    <Line endX="100.0" endY="1.0" layoutX="15.0" layoutY="125.0" startX="450.0" startY="1.0" />
    <Line endX="100.0" endY="0.0" layoutX="15.0" layoutY="250.0" startX="450.0" startY="0.0" />
    <Line endX="-100.0" endY="-125.0" layoutX="301.0" layoutY="158.0" startX="-102.0" startY="180.0" />
    <Line endX="-100.0" endY="-125.0" layoutX="465.0" layoutY="163.0" startX="-100.0" startY="180.0" />
    <Rectangle id="rlt" fx:id="rmm" arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="122.50001525878906" layoutX="202.0" layoutY="127.0" onMouseClicked="#handleRMM" stroke="WHITE" strokeType="INSIDE" width="163.4998779296875" />
  </children>
</AnchorPane>

Just my $0.02 worth.

Any interactive game is a starting point quite complex. The logic of a game is quite complex (even if it's a really simple game). TIC-TAC-TOE, you'll not only to deal with the mouse click but you need a way to tell if it's a valid move (i.e. If the place is not already busy). Is not difficult in itself, but you need to know where to keep the underlying data to this logic, and really data (State of play) must be independent of the display of the game: in short, at a certain level, you will need to understand the model-view-controller architecture.

Now you are at the stage where you're still trying to understand the syntax of the language, and you have little chance to learn than just trying codes and post on the forums. Of course, you can look at other resources too and there are more resources for learning Java I can possibly list, but perhaps Oracle's Java tutorial [url http://docs.oracle.com/javase/tutorial/java/index.html] would be a good starting point. Understand the first three chapters or so meets immediate syntax issues you encounter.

If you have other references, Kathy Sierra "head first Java" and "Thinking in Java" Bruce Eckel are the ones who always get good customers.

Tags: Java

Similar Questions

  • Trouble finding an application for Windows RT. video editing

    Original title: video editing applications

    Hey,.

    I just got my surface and currently going through the windows store trying to find all the applications I find useful. But I seem to have a bit of trouble finding an application that would let you to splice videos video editing etc etc. If someone knows a good app then could you let me know.

    Thank you.

    Try searching CineLab. It looks like a competent, although Basic, editor in Chief.

  • having trouble finding a driver for mass storage of work for a fresh install of win7

    I have a HP Compaq 8510W and I am using windows 7 64 bit from last month, but he will not find a working driver it says that that I've found you'll get me anywhere is unsigned and will not work, don't know how to use one from HP.com Try burning with to do anything for her and she will not work please help the computer was bought on Ebay without an operating system and I'm just for this works

    Found a fix I had in native mode disable SATA in Bios and I had clean up the drive from the bios took 5 hours to do, but it took to install it with out needing a driver

  • Having trouble finding some drivers for my HP Pavilion g7 - 2317 CL (Windows 7 64-bit)

    Looks like I'm not the only person who doesn't like Windows 8.  I rebooted Windows 7 64-bit edition, but can't seem to find the latest drivers: BUS CONTROLLER SM, PCI DEVICE, AND (2 X) USB CONTROLLERS (these are the USB 3.0 ports, my other 2.0 port works fine).  I think the chipset driver should solve all these problems.

    Does anyone have any links or can point me to a similar product on the HP website that I can download these drivers from?

    Thank you, in advance, for your time!

    Hello:

    Please see my response to your other post on the link below.

    http://h30434.www3.HP.com/T5/notebook-operating-systems-and-software/HP-Pavilion-G7-2022US-SM-bus-controller-driver/m-p/3230143#M162760

  • I really don't like this windows 8. I struggle to find something and it shows me where anything on the pc. How to find the place for no pop ups?

    I can't find anything on this thing. I have pd a lot of money for nothing.  I have to buy Microsoft wordperfect and so on.  I can not even find where to stop the pop ups.  I want to print an email and I need to print the entire page.  I liked my xp, it's simple and easy to use.  I really need help with this thing

    Wednesday, May 22, 2013 11:15:55 + 0000, rosienelson wrote:

    I can't find anything on this thing. I have pd a lot of money for nothing.  I have to buy Microsoft wordperfect and so on.

    WordPerfect is not a Microsoft product. It is the processor
    provided by Corel (and in my opinion, WordPerfect is the best word
    available processor).

    Microsoft Word processor is called Word.

    Windows 8, or any other version of Windows has never included
    Word, Excel, PowerPoint, Access, or any other important application
    software. These programs must be purchased, either by themselves, or as
    part of Microsoft Office. Nor has it ever included WordPerfect.

    If your old computer running an earlier version of Windows, came
    with one or more of them, it was because the seller who sold it
    delivered as part of the package he has sold, not because that
    version of Windows came with it. Suppliers of some, but not all, do the
    even with computers of Windows 8 (but if they do, it is very likely that)
    a trial version).

    I can not even find where to stop the pop ups.  I want to print an email and I need to print the entire page.

    How do you print an e-mail message depends on which e-mail program you use
    or if read you e-mail with your browser. It has almost nothing
    to see which version of Windows you are using; you have the choice between the
    several different e-mail program out there (third as programs
    Although Microsoft programs), just as you have always done. We are all
    different people and which e-mail program (or any other type of)
    program) we prefer depends on us, what we love and how we work.

    And a remaining issue: whenever you move to a new version of almost
    any piece of software, an operating system or anything else,
    It takes time and some effort to learn what's new on this subject and
    How to use it effectively. If your view is ' I can't find anything on.
    This thing. "I have pd a lot of money for nothing," you have not clearly
    spent the time and made the effort.

    Ken Blake

  • Looking for an event notification function particularly

    Hello guys,.

    I develop my 1st plugin acrobat with msvc and need little help, because I'm not yet very familiar with the SDK.

    I know how to save event notification callback functions, it works with AVAppRegisterNotification...

    But I can't find the event that occurs when the user selects text in the layer of pd.

    Also, I am currently implementing a function that is called after the user has selected a text short.

    Someone has an idea to which case I mentioned?

    The user can select text in the layer of PD - all user interface elements occur in the

    AV layer, then you are looking in the wrong place for the event. Take a peek inside

    to AVDocDidAddToSelection() - this callback is called when an element

    changed in the selection of the document.

    It is then up to you to discover exactly what happened and that for example the

    the currently selected text is.

    The event returns a pointer to the currently selected items - for a text

    selection, you'd see a pointer to a PDTextSelect object.

    *

    *

    Karl Heinz Kremer

    PDF acrobatics without a net

    [email protected]

    http://www.khkonsulting.com

  • Event handler registration in IOM weblogic cluster envirnoment

    Hi Experts,

    We have OIM11gr2 cluster environment using the logical web cluster solution.

    We recorded with success the event handler and the node to the database file (as described in the document).

    Ask advise should I have to repeat the steps of node 2, given that we are facing the question that is to say for a user event handler does not work and it is not able to generate the user login.

    I guess, then the IOM works from node 2 handler not able to invoke.

    Request your help to identify the root cause associated with registering event handler or a bug of the IOM

    Kind regards

    David

    Hello

    The front brace for the event handler does not work for reliable recon from 11 g

    You must use better UserLogin generation Plugins.

    Booking of username and generation of common name - 11g Release 2 (11.1.2.2.0)

    ~ J

  • Error in the post process event handler

    We should write a process post event handler that updates the field Manager. So, I used the following code to update the Manager field when a user is created:

    Code:

    public EventResult run (long processId, long eventId,
    Orchestration of the orchestration) {}
    System.out.println ("Test for the event handler");
    Try
    {
    Take string = getUserKey (processId, orchestration);
    System.out.println ("USERKEY1" + take);
    UserManager userMgmt = Platform.getService (UserManager.class);
    System.out.println ("USERMANAGEMENT" + userMgmt);
    System.out.println (userMgmt.modify (User (take))) of new;
    userMgmt.modify ("usr_mgr_key", "28", new User (take));
    System.out.println ("USERKEY2" + take);


    } catch (ValidationFailedException e) {}
    System.out.println ("Exception1");
    } catch (AccessDeniedException e) {}
    System.out.println ("Exception2") ;} {} catch (UserModifyException e)
    System.out.println ("Exception3") ;} {} catch (NoSuchUserException e)
    System.out.println ("Exception4") ;} {} catch (SearchKeyNotUniqueException e)
    }
    return new EventResult();
    }


    private String getUserKey (long processID, orchestration of the Orchestration) {}
    Take string;
    String entityType = orchestration.getTarget () .getType ();
    Result of the EventResult;
    result = new EventResult();
    System.out.println ("Feature Type" + entityType);
    System.out.println ("PID" + processID);

    If (! orchestration.getOperation () .equals ("CREATE")) {}
    Take = orchestration.getTarget () .getEntityId ();
    System.out.println ("UserKEY0" + take);
    } else {}
    OrchestrationEngine orchEngine = (OrchestrationEngine.class) Platform.getService;
    Take = (String) orchEngine.getActionResult (processID);
    System.out.println ("Take-1" + take);
    }
    Return take;

    }

    It compiles very well, and when we try to create a user, the user is created successfully. But the expected behaviours of the upadting field Manager with the key to the user '28' are not the case. My highest approach: is it good or is there another method that will make it work?

    The output message I see is:

    Test for the event handler
    TypeUser entity
    Process ID140343
    Take-1613
    USERKEY1613
    USERMANAGEMENToracle.iam.identity.usermgmt.api.UserManagerDelegate@75ecf9ed
    < 27 February 2012 10:56:41 hours GMT > < WARNING > < oracle.iam.callbacks.common > < ARA-2030146 > < [CALLBACKMSG] are present for this eventhandler async to policies? : false >
    oracle.iam.identity.usermgmt.vo.UserManagerResult@14da2ada
    < 27 February 2012 10:56:44 hours GMT > < error > < oracle.iam.identity.usermgmt.impl > < ARA-3051212 > < an error occurred when searching for users -: [usr_mgr_key]. >
    Licence4


    Thank you
    Krish

    I hope that the incorrect coding.
    Use this code.

    UserManager userMgmt = oimClient.getService (UserManager.class);
    Attribute to change
    HashMap atrrMap = new HashMap ();
    atrrMap.put ("usr_manager_key", Long.valueOf("1")); the user will be updated with key Manager 1 (xelsysadm) make sure usr_key 1 (Manager) are in IOM.
              
    get the user you want to change
    User user = userMgmt.getDetails ("usr_key", "41", null);
    User = new User (String.valueOf (user.getId ()), atrrMap);
    Result UserManagerResult = userMgmt.modify ("usr_key", String.valueOf("41"), user);
    UserManagerResult str = userMgmt.modify ("usr_mgr_key", "111", new User ("41"));
    System.out.println ("UserUpdate.Process ()" + result.getStatus ());

    Also do not use the UserManager class, he can go for a loop.
    Use
    EntityManager entityManager = Platform.getService (EntityManager.class);
    entityManager.modifyEntity (orchestrationTarget.getType (), take, mapAttrs);

    I assume you want to use the manager associated with use of the user cases.

    Thank you
    Kuldeep

  • Epson Event Manager cannot find the scanner driver. Epson said that the event handler is a windows thing, and so is the problem.

    I installed an Epson Stylus SX215. I can print, scan and copy if I use another way, but if I want to use the event handler it says that it cannot find the scanner driver may not use the event handler at all (cannot yet open the program).
    In addition, the scan option "attached to electronic mail" does nothing either. Don't know if this is because the event handler program or because he can not see e-mail programs I have.

    Hi bdelrio,

    Thanks for posting. Try running a System File Checker to find errors.

    Click Start.
    In the search box type cmd
    In the menu start right click on cmd.exe and select Run - As-Administrator.
    In the command prompt, type "sfc/scannow".
    Allow this to fill and run. Please let us know if this corrects and error, or if it reports errors, it cannot fix.

    Thank you! Shawn - Support Engineer - MCP, MCDST
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • I am looking for an upgrade at any time key for windows 7 Professional or ultimate edition and cannot find a place to buy a

    I am looking for an upgrade at any time key for windows 7 Professional or ultimate edition and cannot find a place to buy one any where can someone help.

    Original title: Windows 7 Upgrade

    At any time the updates are most of the time is no longer available. However a commercial version of 'Upgrade' (not an OEM) will also do what you want. Only downside is the cost $$$ that Windows 7 is in short supply.

    Amazon: http://www.amazon.com/Microsoft-Windows-7-Ultimate-Upgrade/dp/B002DHLV8S/ref=sr_1_5?ie=UTF8&qid=1390672154&sr=8-5&keywords=Windows+7+upgrade

    All you have to do is enter the product key.

    =============================================================

    Windows 7 Anytime Upgrade: Instructions

    First read this: Windows Anytime Upgrade: frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows7/Windows-Anytime-Upgrade-frequently-asked-questions
    Subdivision: What should I do if I bought a package of Windows Anytime Upgrade key card, but there is no upgrade key inside?
    Answer: If you bought a package of key card upgrade and the upgrade key is not inside, carefully read the instructions on the packaging. You may need to go online to get your upgrade by using the PIN key which is included in the package.

    Note: Windows Anytime Upgrade is available for purchase online in Australia, Belgium, Canada, Germany, France, Italy, Japan, Netherlands, Spain, Sweden, Switzerland, United Kingdom and the United States.

    If you encounter problems recover your key product using your PIN code, please use the resources below.
    www.windows7.com/getkeysupport.

    Note: Retail 'Full' or 'Upgrade' product keys will work when you use the Express Upgrade feature.

    ======================= Upgrading ======================================

    No need to re - install Windows 7, just use the instructions of setting "Anytime" below.
    Note: This assumes that you upgrade from 32 bit to 32-bit Windows 7 OR 64 - bit to 64 bit.

    If you bought a package of key card upgrade and the upgrade key is not inside,
    read carefully the instructions on the package.
    You may need to go online ( https://windows.getmicrosoftkey.com/) to get your upgrade key
    using the PIN, which is included in the package.

    To start the upgrade process:
    Click on start/search and enter the words: Express upgrade
    Then, in the list of the search results, click on "Windows Anytime Upgrade".
    Then follow the prompts on the screen anytime upgrade.
    Basically, all you need to do is enter the Windows 7 upgrade product key.

    Alternative methods:
    (Located at the top right) Start/Control Panel/small icons option / click the "Windows Anytime Upgrade".

    Enter the text below into the run (Windows KEY + R or a command prompt) dialog box:
    %windir%\system32\WindowsAnytimeUpgradeUI.exe

    Upgrade to another edition of Windows 7 by using Windows Anytime Upgrade
    http://Windows.Microsoft.com/en-us/Windows7/upgrade-to-another-edition-of-Windows-7-by-using-Windows-Anytime-Upgrade

    A 'step by step' to go through an upgrade to a lower edition of Windows 7 to a higher edition of Windows 7:
    http://www.howtogeek.com/HOWTO/14943/how-to-upgrade-your-NetBook-to-Windows-7-Home-Premium/

    -Windows Anytime Upgrade in Windows 7 - troubleshooting

    http://www.thewindowsclub.com/Troubleshooting-Windows-Anytime-Upgrade-in-Windows-7

    Also the reinforced system - method #2 tool (download and run the tool: "Checksur.exe")
    http://support.Microsoft.com/kb/947821
    (System resources, such as file of data, even in the data memory and registry data, can develop inconsistencies during the lifecycle of the operating system. The system update tool attempts to resolve these inconsistencies).

    -Anytime Upgrade may not work for all versions of Windows-

    Note: Retail 'Full' or 'Upgrade' product keys will work when you use the Express Upgrade feature.
    Upgrade Express 'can' not work (check with the manufacturer of the computer support team) for users who have the OEM and integrators of systems product keys, this applies also to the VL (Volume License), keys (KMS) users management server should consult with your administrator before attempting to perform an Express upgrade. MSDNAA or key teaching will not work with the Express upgrade.

    -Anytime Upgade options-

    Windows 7 Starter to Windows 7 Home Premium
    Windows 7 Starter to Windows 7 Professional
    Windows 7 Starter to Windows 7 Ultimate
    Windows 7 Edition Home Premium to Windows 7 Professional
    Windows 7 Edition Home Premium to Windows 7 Ultimate
    Windows 7 Professional to Windows 7 Ultimate

    J W Stuart: http://www.pagestart.com

  • Hello, I would like to get a refund for the software purchased from Adobe. I have 14 days to do so, but I can't find the place to cancel the order. Thank you!

    Hello, I would like to get a refund for the software purchased from Adobe. I have 14 days to do so, but I can't find the place to cancel the order.

    Thank you!

    You may please check out the link below for instructions on cancellation.

    Cancel your membership creative cloud

    For more information you can contact the Support from Adobe by clicking on the link below.

    Contact the customer service

    Please make sure that you are connected to the right Adobe ID.

    Hope this will help you.

    Kind regards

    Hervé Khare

  • event handler for disclosureopenicon in tree in flex 4

    Hi all

    Is it possible to write an event handler to disclosureopenicon for tree control in flex?

    If its way possible, h w can write?

    Hi Melissa,

    You can do it by triggering an event of Navigation for the opening and closing of these tree nodes.

    See you soon,.

    Jeevan

  • Cannot find the appropriate event handler

    In the following code, I create 5 paintings where each canvas behaves like a button. Each canvas contains a text field and each canvas is movable. I want to trigger an event when the user drags on the side of the canvas, but on the contrary it is triggered as soon as I roll on the text field. You will see what I mean if you click on the text, and then drag the text to the side. It will trigger a trace.

    It is very important that I have only to raise an event when I drag the canvas, not the text. Is there an event handler that will make thios for me?

    Thank you!

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"creationComplete =" init () "> "
    < mx:Script >
    <! [CDATA]
    Import mx.controls.Button;
    Import mx.controls.Image;
    Import mx.controls.Text;
    private var canvas2:Canvas;
    private var imageText:Text;
    [Bindable] private var thisButtonNumber:Number
    [Bindable] private var dragRectangle:Rectangle = new Rectangle (0, 0, 0, 300)
    private function init (): void {}
    for (var i: int = 0; i < 5; i ++) {}
    Canvas2 = new canvas;
    Canvas2.addEventListener (MouseEvent.MOUSE_DOWN, allowDrag)
    Canvas2. Width = 300;
    Canvas2.y = i * 30;
    imageText = new text;
    imageText.selectable = false;
    imageText.text = "Button" + (i) String;
    imageText.x = 130
    imageText.y = 5;
    Canvas2. AddChild (imageText);
    Canvas1. AddChild (canvas2);
    }
    function allowDrag(e:MouseEvent):void {}
    Canvas1. AddChild (DisplayObject (e.currentTarget));
    e.currentTarget.startDrag (false, dragRectangle);
    e.currentTarget.addEventListener (MouseEvent.MOUSE_MOVE, checkPosition)
    }
    function ROLL_OUTtest(e:MouseEvent):void {}
    trace ("ROLL_OUTtest =" + e.currentTarget)
    e.currentTarget.stopDrag ();
    }
    function checkPosition(e:MouseEvent):void {}
    e.currentTarget.addEventListener (MouseEvent.MOUSE_OUT, ROLL_OUTtest)
    }
    }
    []] >
    < / mx:Script >
    < mx:Canvas id = "canvas1" x = "400" y = "25" backgroundColor = "0xdddddd" buttonMode = "true" useHandCursor = "true" / >
    < / mx:Application >

    Try ROLL_OUT, MOUSE_OUT not

  • Event handler for a HBox

    I'm figuring the width of a HBox once a component has been loaded into it. What event handler will tell me that an object has been added to a HBox?

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"applicationComplete =" init () "> "
    < mx:Script >
    <! [CDATA]
    public void init (): void {}
    for (var i: int = 0; i < 5; i ++) {}
    var panel1:MainPanel = new main;
    Panel1.x = i * 120;
    hbox.addEventListener (SELF, handlePanel1Load)
    hbox.addChild (panel1)
    }

    }
    public void handlePanel1Load(e:Event):void {}
    trace ("Loaded =" + hbox. Width)
    }
    []] >
    < / mx:Script >
    < mx:Canvas id = "hbox" borderColor = "0xffff00" backgroundColor = "0xdddddd" horizontalCenter = red "0" = "0" borderStyle = "solid" / >
    < / mx:Application >

    updateComplete

  • Question of optimization: 1 handler for multiple events or 1 Manager by the event?

    Something I can't decide, simply because I'm not sure what would be most effective.

    Example: I have a few menus, each with a handful of icons click on (say a total of 10 objects that can be clicked on).

    Would it not be better to have 1 stage.addEventListener (MouseEvent.MOUSE_DOWN, clickHandler); with 10 if (e.target.name == "nameX") who is called on each click.

    Or would it be better to have 10 separate objectX.addEventListener (MouseEvent.MOUSE_DOWN, clickHandlerX); for each menu item that can be clicked?

    I suppose my confusion comes from not knowing what a listener does exactly, it uses all the resources I look for an event?

    (added)

    After typing all this, a good comparison would be closer to an event listener is nothing else than a way to call a function and is not otherwise using resources?

    My question is still, but I'm leaning towards several Auditors and managers.

    (add 2)

    Sorry my brain blurs, I'm not good at explaining things.  I think it's a little clearer.

    For 1 menu I 1 this.addEventListener, and in the Manager, he has several if (menu_itemX.name == "nameX").
    It is better to have 1 eventListener in this situation, or would it be better to have several menu_itemX.addEventListener and managers separated for each action?

    (follow-up question)

    I did addEventListener when the menu opens and removeEventListener when the menu closes.  If the event listeners do not use 'no' resources unless their event fires is a bad practice for simple click and mouseover events mouseout/mouseouthandler()?  Should I just leave the event listeners here all the time?

    (sample code)

    If this makes it more clear which of these would work better?

    Version 1:

    this.menu1.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler1);
    this.menu2.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler2);
    this.menu3.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler3);
    this.menu4.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler4);
    this.menu5.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler5);
    
    function clickHandler1(e:Event):void{}
    function clickHandler2(e:Event):void{}
    function clickHandler3(e:Event):void{}
    function clickHandler4(e:Event):void{}
    function clickHandler5(e:Event):void{}
    

    version 2:

    this.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler);
    
    function clickhandler(e:Event):void{
    if(e.target.name == "menu1"){}
    else if(e.target.name == "menu2"){}
    else if(e.target.name == "menu3"){}
    else if(e.target.name == "menu4"){}
    else if(e.target.name == "menu5"){}
    }
    
    

    the leave it alone as long as your menu works as expected while adding them.

    leaving the listener takes memory.  removing it frees this memory.

    but free up memory and adding memory uses system resources, especially when free memory flash gc.  It is unnecessary to repeatedly the gc objects that will be added to memory later.

Maybe you are looking for

  • can not activate facetime and imessage iphone 5

    I got my iphone brand new 5 Friday everything works fine! Really happy with it, as this is my first iphone. I tried to activate facetime and imessage, but it keeps failing. I reset the phone and other troubleshooting activities all to nothing does no

  • Firefox works too slowly. I have reset it. Update of plugins, but it does not help.

    Firefox worm 25.It downloads the pages slowly. I started it without plugins. I've updated all the plugins.Sometimes Firefox Watch window 'Script on this page may be busy... ". «The status line showes "transfer data of...» »

  • Disc cannot mount (Macbook Pro issues)

    I have a Macbook Pro Late 2011. A few years ago I tried to download World of Warcraft (don't ask not why, I know now that it's a terrible idea, it was). And since then my mac runs terribly slow. It will start up and I can log on and even browse the w

  • Brand new w701ds crashes every second open time monitor

    Hello. Just got my new w701ds in mail today and every time I open the second monitor (or boot with open), I get the blue screen of death, and it crashes. Of course, it can't be more disappointed and then buying a product from a particular function, a

  • v210w 32 GB USB stick: not able to do "32 GB hp v210w" bootable

    I use Yum Installer multiboot to create bootable sticks. A few days back I bought a 32 GB v210w USB key. When I make it bootable, it is successful. But when I try to boot my laptop with the USB key, I'm not able to boot from it. Please help me what's