Solved

AS3 class communication

Posted on 2010-11-10
2
484 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
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
File conversion question 5 54
Ready Made PHP Scripts 5 51
Autoit restart command not working 6 42
How can I do this in Pyhton? 12 68
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now