Solved

Trouble with Event Dispatching between Parent and Child Classes

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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.

689 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