Solved

Trouble with Event Dispatching between Parent and Child Classes

Posted on 2008-06-18
3
434 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

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

Suggested Solutions

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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 goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
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.

696 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