5 Replies Latest reply on Nov 7, 2010 10:03 PM by jdrago999

    TFL flashvars bug

    air_flash

      Hi everyone!
      During the project migration to Flash CS5 I discovered an unexpected problem. If the scene  contains at least one component of the TFL, then the all flashvars variables are "undefined". Delete  a component from the scene, compile - all works fine. Adds - again  undefined.

      FlashPlayer 10,0,45,2

      Sorry from  my English

        • 1. Re: TFL flashvars bug
          happyBtn

          Found the same issue.

          • 2. Re: TFL flashvars bug
            Alan Stearns Adobe Employee

            I can reproduce the issue. I've started the wheels turning to figure out what's going on.

            • 3. Re: TFL flashvars bug
              Alan Stearns Adobe Employee

              OK - it looks like this is an issue with the Flash Pro CS5 preloader code. I'm told there will be a technote published for this problem.

               

              Here's a workaround I got from the engineer who looked into this:

               

              Typically you could access the flashvars parameters in AS3 by doing something like this:

               

              var params:Object = loaderInfo.parameters;

               

              But to work around the issue we are having with the TLF RSL preloading, you need a little bit of extra code:

               

              var params:Object = loaderInfo.parameters;

              if (parent != null && parent.parent != null) {

                              params = parent.parent.loaderInfo.parameters;

              }

               

              For the work around to work correctly THIS CODE NEEDS TO BE ON FRAME ONE. It cannot be in a user defined constructor (too early) and it cannot be in frame two (too late). We need to be clear about that.

               

              While there is not a schedule for releasing a fix to this issue, we definitely would want users to first grab the flashvars the normal way and then check parent != null && parent.parent != null, because I hope that in the future we will be able to fix this issue, and we do not want users creating content that would be incorrectly applying a work around when one is no longer necessary. So definitely those checks are important.

               

              Alan

              • 4. Re: TFL flashvars bug
                AdrianParr Level 1

                Just for the record, if you are having a problem accessing your  FlashVars (and you are using a TLFTextField in Flash CS5) and you are  using external classes (i.e. you have a document class and not timeline  code) you need to listen for the ADDED_TO_STAGE event before trying to  access them.

                 

                For example ...

                 

                package
                {
                    import flash.display.Sprite;
                    import flash.events.Event;
                    import flash.display.LoaderInfo;

                 

                    public class Main extends Sprite
                    {
                      
                        public function Main():void
                        {
                            if (stage) init();
                            else addEventListener(Event.ADDED_TO_STAGE, init);
                        }
                       
                        private function init(evt:Event = null):void
                        {
                            removeEventListener(Event.ADDED_TO_STAGE, init);
                            var params:Object = loaderInfo.parameters;
                            if (parent != null && parent.parent != null) {
                                params = parent.parent.loaderInfo.parameters;
                            }
                            // You can now loop through the params to access your FlashVars
                        }
                       
                    }
                }

                • 5. Re: TFL flashvars bug
                  jdrago999

                  Going up 2 levels was too far for my case.

                   

                  This worked for me:

                   

                   

                  /**
                  * CS5 completely broke flashVars.
                  * See http://forums.adobe.com/thread/644057 for details.
                  * Basically, ADOBE == STUPID.  Thanks guys!
                  */
                  private function getFlashVar( varName:String ) :String {
                    var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
                    if( parent != null )
                    {
                      paramObj = parent.loaderInfo.parameters;
                    }// end if()
                  
                    try {
                      for( var el:String in paramObj )
                        if( el == varName )
                          return paramObj[el].toString();
                    }
                    catch(e) {
                      return "";
                    };
                    return "";
                  }
                  

                   

                   

                  Just another example of the folks at Adobe screwing up a good thing.