Go Back   kirupaForum > Flash > ActionScript 1.0/2.0

Reply
 
Thread Tools Display Modes
Old 11-24-2009, 03:27 PM   #1
kamcknig
Registered User
class members not available fast enough!

Hello everyone!

I have a class, ClassA which is a MovieClip. Inside of that I have about 20 other MovieClips that are associated with ClassB.

In my main timeline I have something like this, instantiating ClassA and then calling a setup function in it.

Code:
var obA:ClassA = ClassA(attachMovie("ClassA", "classA", getNextHighestDepth()));
obA.setup();
Then in ClassA I have this, the ClassB type variables are declared at the top because they are on the stage inside of ClassA.
Code:
public class ClassA extends MovieClip {
  public var obB1:ClassB;
  public var obB2:ClassB;
  ...
  public var obB20:ClassB;

  public function ClassA() {
  }

  public function setup():Void {
    obB1.owner = 0;
    obB2.owner = 1;
    obB3.owner = 2;
    ...
    obB20.owner = 19;
  }
}
This is all very boiled down compared to what I have. But the problem is that the constructors of all the ClassB instances inside of ClassA are being called AFTER the setup() function is being called, and therefore I can't access any properties inside of those ClassB variables!!

The only solution I've come up with is to instantiate ClassA and then use a timeout to call the setup function in the class after a delay so that everything gets initialized before I try to access them!! And I don't like that solution at all!

Does anyone know of a better way to accomplish this??

Thanks!
Kyle
kamcknig is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-24-2009, 04:34 PM   #2
TheCanadian
Noo doot aboot it, eh?
 
TheCanadian's Avatar
Location Take a guess . . .

Posts 6,808
Try obA.onLoad = function():Void {this.setup();}

__________________
Proud Montanadian
We tolerate living and breathing.

Name Brand Watches
TheCanadian is offline   Reply With Quote
Old 11-25-2009, 12:20 PM   #3
kamcknig
Registered User
Thanks!

That worked
kamcknig is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:45 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com