Help regarding event flow/event listening best practices

Hi, I'm making a flash memory card game to learn more about
to actionscript.
I have:
- a main class that loads on start. This class instantiates
a:
- CardLoader class that imports graphical assets and uses
these to create all my cards:
- Card class that represents individual card. Can dispatch
CardEvent when clicked:
- CardEvent contains info on the Card that dispatched it,
such as the cards ID number and the ID of it's matching card.
What I want to do is to have another object to act as a game
logic handler.
Example:
- Card 1 was clicked, dispatches CardEvent that ends up with
the LogicHandler.
- Card 2 was clicked and also dispatches event.
LogicHandler compares these two cards and does the
appropriate thing depending on they being a match or not.
Now, the big questions is, how do I get this event to the
LogicHandler?
My custom CardEvent has it's bubbles property set to true.
So, I can manage to get such an event all the way back to my main
class, in this order: CardEvent > Card > CardLoader >
Main.
The problem arises when I want to have my LogicHandler class
created by Main. When my CardEvent bubbles back, it does not go
through this LogicHandler since it is not part of the event flow on
it's way back.
Questions: How do I, following the best possible programming
practises, send the event the way I want it to go?
I can only think of one solution myself, being that inside my
Main method I set up an eventlistener that listens for this event
and passes it on downwards, in this case to the LogicHandler. Sure,
it's only a few lines of code in the main method, but what if you
have 50 different events in a larger project that needs the same
treatment?
Your main method will be a mess by then!
How would you do it?

Ok let me see if I get this straight:
In my example, I would have to pass a reference of the
LogicHandler to my Card class.
In my Card class, I have something like:
logicHandler.addDispatcher(this);
this being the Card of course.
Inside LogicHandler class I have the addDispatcher method
that calls the addEventListener method.
So far so good?
The addDispatcher method adds an eventlistener to the Card
object, from what I can tell. But it does it inside the
LogicHandler, thus the method that is called by the
addEventListener can be inside the LogicHandler?
To put it in other words, what's confusing me is that the
Listener object adds an EventListener to the dispatching object.
Logically for me the listener should add a listener to itself?
The way I first did it in my Card class was:
testevent = new CardEvent(CardEvent.CLICK);
dispatchEvent(testevent);
And then set up the EventListener in the object that I wanted
to receive the event.
I'm sorry I don't understand this, despite your obviously
good explanations (I think I understand a lot more now, just not
the best approach). I will look into the callback functions, sounds
a lot interesting as well

Similar Messages

  • Remove Event Listener : Best Practice

    This quesiton isn't really keeping me from progressing on my current project, but I was wondering what the best practice was. If I'm about to remove an item with removeChild(), should I first remove any Event Listeners that were on that object or do those get removed and cleared from memory automatically when the child is removed?
    Thanks,
    Dave

    As Kalisto mentioned, the listeners will only be removed automatically if you use weak reference when you add it:
    myObject.addEventListener(MouseEvent.CLICK, someFunction, false, 0, true);
    The true on the end specifies to use weak ref. If you don't use that (you always should) then you will have to remove it manually or it will hang around forever.
    Also, removeChild simply removes the object from the display list... it's still in memory. Set it to null if you want to truly clear it.

  • Help Regarding Work flow

    Hi,
    Can any body help me how to allign the attributes(like left allignment or right allignment) in notification message of Oracle workflow. This message i am sending to email account of an user.
    Thanks in advance.
    Regards
    paramesh y

    Hi sarath,
    some helpful links.
    http://help.sap.com/saphelp_erp2005/helpdata/en/fb/135962457311d189440000e829fbbd/frameset.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/c5/e4a930453d11d189430000e829fbbd/frameset.htm
    Workflow
    http://www.sap-img.com/workflow/sap-workflow.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/a5/172437130e0d09e10000009b38f839/frameset.htm
    For examples on WorkFlow...check the below link..
    http://help.sap.com/saphelp_47x200/helpdata/en/3d/6a9b3c874da309e10000000a114027/frameset.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PSWFL/PSWFL.pdf
    http://help.sap.com/saphelp_47x200/helpdata/en/4a/dac507002f11d295340000e82dec10/frameset.htm
    http://www.workflowing.com/id18.htm
    http://www.e-workflow.org/
    http://web.mit.edu/sapr3/dev/newdevstand.html
    /people/mike.pokraka/blog/2005/07/17/sap-business-workflow-faq
    Regards
    Anver

  • Best practice for application help for a custom screen?

    Hi,
    The system is Netweaver 7.0 SP 15 with e-recruiting .
    We have some custom SAP GUI transactions and have written Word documents with screen prints and explanations. I would like to make the procedure document accessible from the custom transaction or at least provide custom help text that includes a link to the full documents.
    Can anyone help me out with options and best practices for providing customized application help for custom SAP GUI transactions?
    Thanks,
    Margaret

    Hello Margaret,
    sorry I though you might be still in a design or proof of concept phase where the decision for the technology is still adjustable.
    If the implementation is already done things change of course. The standard in-system documentation is surely not fitting your needs as including screenshots won't work well.
    I would solve the task the following way:
    I'd make a web or pdf document out of the word document and put it on a web ressource - as you run e-recruiting you have probably the possibility for that.
    I would then just put a button into the transaction an open a web container to show the document.
    I am not sure if this solution really qualifies as "best practise" but SAP does the same if you call the Help for application in the help menue. This is implemented in function module SAPGUIHC_OPEN_HELP_CENTER. I'd just copy it, throw out what I do not need and hard code the url to call.
    Perhaps someone could offer a better solution but I think this works a t least without exxagerated costs.
    Kind Regards
    Roman

  • Best Practices - Help required

    I am struggling to understand how Best Practices (warehousing ) could be implemented for SME's (UK) in ECC 6.
    Any advice, pointers to documents which are practical  would be useful.
    Is there a set of steps that one needs to follow in order to map the existing client business process and then superimpose that on the best practice templates chosen?

    Hi Hari,
    The Best source of documentation for the Best Business Practices is help.sap.com. You will find the configuration guides, Business scenarion power point presentations and the BPP's of the scenarios there.
    Procedure:
    browse help.sap.com
    Click on SAP Best Practices
    Click on Baseline packages
    Click on Based on SAP ECC 6.00
    link is as below: http://help.sap.com/content/bestpractices/baseline/bestp_baseline_baseline_V600.htm
    Hope this will help you.
    Thanks and Regards,
    Sambhaji
    Don't forget to mark the message as "Very Helpful", "Helpful" or "Problem Solved".

  • Best practices for ARM - please help!!!

    Hi all,
    Can you please help with any pointers / links to documents describing best practices for "who should be creating" the GRC request in below workflow of ARM in GRC 10.0??
    Create GRC request -> role approver -> risk manager -> security team
    options are : end user / Manager / Functional super users / security team.
    End user and manager not possible- we can not train so many people. Functional team is refusing since its a lot of work. Please help me with pointers to any best practices documents.
    Thanks!!!!

    In this case, I recommend proposing that the department managers create GRC Access Requests.  In order for the managers to comprehend the new process, you should create a separate "Role Catalog" that describes what abilities each role enables.  This Role Catalog needs to be taught to the department Managers, and they need to fully understand what tcodes and abilities are inside of each role.  From your workflow design, it looks like Role Owners should be brought into these workshops.
    You might consider a Role Catalog that the manager could filter on and make selections from.  For example, an AP manager could select "Accounts Payable" roles, and then choose from a smaller list of AP-related roles.  You could map business functions or tasks to specific technical roles.  The design flaw here, of course, is the way your technical roles have been designed.
    The point being, GRC AC 10 is not business-user friendly, so using an intuitive "Role Catalog" really helps the managers understand which technical roles they should be selecting in GRC ARs.  They can use this catalog to spit out a list of technical role names that they can then search for within the GRC Access Request.
    At all costs, avoid having end-users create ARs.  They usually select the wrong access, and the process then becomes very long and drawn out because the role owners or security stages need to mix and match the access after the fact.  You should choose a Requestor who has the highest chance of requesting the correct access.  This is usually the user's Manager, but you need to propose this solution in a way that won't scare off the manager - at the end of the day, they do NOT want to take on more work.
    If you are using SAP HR, then you can attempt HR Triggers for New User Access Requests, which automatically fill out and submit the GRC AR upon a specific HR action (New Hire, or Termination).  I do not recommend going down this path, however.  It is very confusing, time consuming, and difficult to integrate properly.
    Good luck!
    -Ken

  • Best practice in database

    Dan
    I would appreciate help with the following query:
    The best practice in the development and deployment in the use of database is:
    1. Creating a resource external SQL database. If positive, indicates that when the DataSource is created in the WebLogic Server.
    2. Create a remote JDBC.
    Thanks and Best Regards,

    Hi,
    Others will have different ideas that are probably more useful, but I personally like "green field" opportunities like you're describing.
    One thing you have to figure out is what technology you want to develop and maintain your components in. Once built, they can be exposed as web services, Java POJOs, EJBs, .NET assemblies and databases which Oracle BPM can consume. Pick a technology that your team is most comfortable with.
    A best practice preference would be to use a Service Bus as the intermediary layer between Oracle BPM and the components consumed if you own one. If you don't, Oracle BPM will need to consume the components directly.
    I'd use Oracle BPM for what it was intended for. Sometimes I see the architecture "flipped" where the customer wants a third party UI to drive instances through the process via the API. While this will work, it's a lot of extra work to rebuild what Oracle BPM does a good job of OOTB.
    Dan

  • Best practice - classes folders from components

    Hi all,
    I have a question regarding which would be the best practice for the following scenario:
    I have a customer, multiple components have to be developed(including java custom components), how does it make sense better:
    to have one classes folder for all the components(maybe another component specially build just for making that classes folder available to the rest of the components), or each component with its classes folder. Which would fit best from the development point of view, and from the CS point of view(loading resources, priority, order etc.) ?
    What problems could appear?
    Hope I made myself understandable!
    regards,
    Vlad

    In my opinion, I would go the route of having each component with their own classes folder. It's cleaner and you don't have to worry about having dependent features/components (advanced build settings). If you distribute/reuse it (the whole point of custom components), you don't have to worry about remembering to include any dependents either. Plus, who knows how reliable un/installing components with dependent features/components is. Most components I've seen don't have any dependents. Lastly, I'm a believer in knowing exactly which classes a component uses. I hate having to sift through classes that, in the end, aren't even used by the component.
    The only real reason I can see having a separate component that stores all your classes is if they are HUGE and taking up valuable disk space, and if multiple components use those same classes.
    Hope this helps.

  • Best Practices for SAP BPC

    Hi Gurus,
    Please provide some best practice for BPC or older version of BPC (outlook soft) on planning scenarios.
    regards
    kishan

    Hi kishan swagath,
                                   For best practices the below link is exclusive...
    http://help.sap.com/bp_bpcv151/html/index.htm..
    You can find the best scenarios here...
    Hope it is helpful..
    Regards,
    Naresh.K

  • Best Practices Building Blocks for CRM 5.0 & CRM 2007

    Hi Experts,
    Where can I find Best Practices Building Blocks for CRM 5.0 & CRM 2007?
    Thanks in advance,
    Vishwa.

    Hi
    Go to: http://help.sap.com/
    Click on the Best Practices Tab,
    Then Cross-Industry Packages,
    Then Customer Relationship Management
    They should all be under there.
    Regards
    Arden

  • SAP Best Practices Baseline package for Russia V3.607

    Dear colleagues,
    My partner - BearingPoint Russia - has an interest to SAP Best Practices Baseline package for Russia V3.607
    Would you please help to find the contact whom they can ask the questions about content & price to?
    Best regards,
    Dmitry Popov

    Dear Dimitry,
    the Best Practice baseline content is freely available to anyone w/o any charge.
    You find the whole content about it at:
    SAP Best Practices package for Russia V3.607 (English)
    SAP Best Practices package for Russia V3.607 (Russian)
    Kind Regards,
    Jan

  • ODP + Client Version Management Best Practices

    I am working with a client who is using the Oracle Developer Tools for Visual Studio to develop their application. The IT folks deploy a new server with the latest version of the Oracle client (i.e. 11.1.0.7.0) and the developers are using the latest ODT (i.e. 11.1.0.7.20). As such the publisher policy never gets a chance to add any value. Because of the unusual versioning scheme we always end up having to copy the Oracle.DataAccess.dll from the Oracle client into the deployment folder and add an assembly binding redirect. If we do not we get the following exception:
    The provider is not compatible with the version of Oracle client
    As you might expect this is VERY annoying to deal with as it adds complexity to our deployment process. We use TNS names to connect and those files are stored in the client\network\admin folder as well. Can someone please help me clear up what the best practice is to deploy an application developed using ODT/ODP.NET so that we don't have to hack the Oracle.DataAccess.dll every time?
    Thanks,
    Colin

    Thank you for your answer.
    So you are basically proposing to work with the vms in the dev folder and publish the desired version to the test folder. And the test folder is out of version control in this scenario if I understood you correctly (like simple data storage)?
    And how would you suggest promoting reports to the prod system? Simply by promoting the
    desired version from dev folder directly to prod? This would probably lead to inconsistence because we would need to promote from dev system to test and dev to prod instead of promoting a straight line from dev over test to prod. Furthermore it would not solve the problem of the promoting result itself (A new folder called dev will be generated in prod but the report gets promoted to the prod folder if there was no report before).
    Thank you for the link. I came across this page just a few days ago and found also lots
    of other tutorials and papers describing the basic promoting process. The promoting process in general is clear to me but I wondered if it is possible to change some parameters to  prevent folder renaming for example.
    Regards
    Lars

  • TEM Building Block in Best Practices

    Dear Team,
    I am not able find any building block and doc relating to TEM (Training and Event Management) in SAP Best practices
    Please guide me? Where i can find out more abt this.

    Dear Team,
    Please reply for my issue.
    Regs,
    Brahma

  • SAP CRM BEST Practices

    Hi All,
           Please provide some links to download SAP CRM BEST Practices.
    Please provide valuable info.
    Regards,
    Srini.

    Hi Srini,
    you can follow the below path, it leads you to the best practices.
    http://help.sap.com/
    click on SAP Best Practices
    click on Cross-Industry Packages
    left hand side = Customer relationship management
    Right hand side = Select english
    In new page, select Technical Information
    Building Block Library
    You can download the relevant best practices like  for versions  6.0( v1.2007), 5.2(v1.52), 5.0(v2.50) & 4.0(v3.40). Building blocks are nothing but the best practices and these are the only best practices available for SAP CRM.
    regards,
    kalyan

  • Best Practice of using ERM (Role Expert) in Landscape

    Hello,
    Can anyone tell me what is the best practice (choice) of using ERM in the SAP landscape?
    1. Creating a role in DEV system using ERM and using SAP standard transport process to transport role to QAS and PRD systems.
    OR
    2. Creating a role in all systems in ladscape (DEV, QAS and PRD).
    Please share if you have any best practice implementation scenarios.
    Appreciate for the help.
    Thanks
    Harry.

    Harry,
       The best practice is to follow Option 1. You should never directly create a role in Prod system. This is what SAP recommends as well.
    Alpesh

Maybe you are looking for

  • How many instances of EXS24 can you fit into one session?

    Hey all, Well, it seems like I finally have a project where I'm starting to max out my new Intel iMac. Everything was working fine until I added my 22nd VI, and then I started getting all sorts of CPU overload errors. All of my instances are EXS24, a

  • Query to fetch a set of records

    My query is expected to fetch a huge number of records, say 20000, depending on the parameters passed through front end. The front end developer wants that these records should be displayed on different pages with each page displaying 100 records. Bu

  • Back up to external HD (7)

    Hi, I have connected my external hardrive to laptop but although it recognises it, it is not giving me the option to back up to this hardrive...I have windows 8.1 that I am not quite use to yet. Can someone tell me where the options are to back up to

  • Finding photos missing location information

    Can anyone suggest a SmartAlbum rule that will detect photos with no location information?

  • Spool question

    Experts, When I have problem with the spool what is the file systems or transaction that I need to check? Thanks!