Solved

Trouble with Event Dispatching between Parent and Child Classes

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
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.

705 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

20 Experts available now in Live!

Get 1:1 Help Now