ADDED_TO_STAGE

ADDED_TO_STAGE

Postby ehsmeng » Wed Dec 10, 2008 7:36 pm

Hi,

It's usually a good idea to put initializations behind a ADDED_TO_STAGE interrupt to ensure that stage et al is setup properly before using it. I've had intermittent bugs before adding this to my swf:s - in particular when using them in a widget container à la ClearSpring.

Please consider the following patch:

Code: Select all
--- main.as.org   2008-12-10 20:33:05.453125000 +0100
+++ main.as   2008-12-10 20:41:09.906250000 +0100
@@ -70,7 +70,13 @@
      private var id:String;
      private var chart_parameters:Object;
      
-      public function main() {
+      public function main():void {
+         addEventListener(Event.ADDED_TO_STAGE, main2);
+      }
+      
+      public function main2(evt:Event):void {
+         removeEventListener(Event.ADDED_TO_STAGE, main2);
+         
         chart_parameters = LoaderInfo(this.loaderInfo).parameters;

         var loading:String = ( this.chart_parameters['loading'] ) ? this.chart_parameters['loading'] : 'Loading data...';


Best regards,
Marcus
Attachments
main.as.diff.tar
The code block as a tar:ed txt file as tar seems to be one of few allowed extensions
(10 KiB) Downloaded 10 times
ehsmeng
 
Posts: 4
Joined: Tue Dec 09, 2008 12:52 pm

Re: ADDED_TO_STAGE

Postby monk.e.boy » Thu Dec 11, 2008 10:20 pm

This sounds like a great idea, what bug would it fix? I need to document it :-)
monk.e.boy
Founder & Project Lead
 
Posts: 653
Joined: Thu Sep 04, 2008 10:06 pm


Return to Development

Who is online

Users browsing this forum: No registered users and 1 guest