Solved

AS3 class communication

Posted on 2010-11-10
2
489 Views
Last Modified: 2012-08-13
I have a button created in one class. When that button is clicked, I believe I need to add a dispatchEvent so that I can listen for that in another class. Is that correct, or is there a simpler, more elegant way of reacting to that in the first class?
0
Comment
Question by:msukow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 total points
ID: 34103708
That's correct. The way of communicating between objects is through the event model. Dispatching custom events in one and using event listeners to gather the information.

"Elegant code" is pretty much in the eye of the beholder, there really isn't a common definition, some say it's the juxtaposition of simplicity and functionality, some others disagree and state that "elegant" code is all about readability, since you can do a lot in one line, but if nobody can decipher it but you, then it isn't "elegant".

All that just to say that maybe a different approach will look better to you, perhaps searching in the Display List if both classes are there would seem to be a better suit in some cases... but I'd always go with the event model, it adds a lot of readability to your code, especially if you're using custom classes and not just a string literal, it's simple and works fine, but in the end, it's your call!

Good Luck.
-V
0
 

Author Closing Comment

by:msukow
ID: 34103780
Thanks for the confirmation
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question