Solved

Trouble with Event Dispatching between Parent and Child Classes

Posted on 2008-06-18
3
432 Views
Last Modified: 2013-11-11
I am developing an application to load pictures from an XML backend to display to the user. I would like to use JavaScript to resize the viewable div the flash app occupies. I have the code to do this. However, since the dimensions of the content are not set until everything is loaded, the resizing must be done after all of the loading is finished. Currently, I have a ContentClip class, which will be loaded into a parent SWF for viewing. This ContentClip class contains an instance of a Picture class, which is responsible for downloading, sizing and adding the picture. I am trying to fire an event upon the completion of the picture loading process, which will notify the ContentClip. After some accounting, this ContentClip will determine when everything has loaded, and notify the parent SWF to resize the div. Currently, the event fires in the Picture class, and is recognized in the class. However, the event listener in the ContentClip is not triggered. This is strange, since very similar code works elsewhere in the application without hitches. Attached are the relevant class files. Thank you for any assistance you may be able to provide!
ContentClip.as.txt
Picture.as.txt
0
Comment
Question by:ckoning
3 Comments
 
LVL 4

Accepted Solution

by:
emphaticDigital earned 500 total points
ID: 21822960
Hello,

In order for a class to receive notification of another classes events, two things must happen. One, the event itself must 'bubble' or share the event dispatch with its ancestors and Two, the class that wants to receive notification must be an 'ancestor' of the dispatching class.

Most of the time this happens with display objects that have a parent child relationship. Bubbling is automatic for objects in the same display heirarchy.

For this to work, I think you have to create a custom event class, including overridding the 'clone' and 'toString' methods of the base class. I'm at work now, but will try to work it out tonight. Check back.

Hope this helps a little.
0
 
LVL 4

Author Closing Comment

by:ckoning
ID: 31468238
Thank you! I have since studied up on AS3's inheritance and event models. This tip put me on a good track.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

832 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