Skip navigation
air_flash
Currently Being Moderated

TFL flashvars bug

May 21, 2010 2:53 PM

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

  • Currently Being Moderated
    Community Member
    May 28, 2010 11:29 AM

    Found the same issue.

    |
    Mark as:
  • Currently Being Moderated
    Adobe Employee
    May 28, 2010 1:34 PM

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

    |
    Mark as:
  • Currently Being Moderated
    Adobe Employee
    Jun 1, 2010 2:22 PM

    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

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Sep 5, 2010 10:38 AM

    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
            }
           
        }
    }

    |
    Mark as:
  • Currently Being Moderated
    Community Member
    Nov 7, 2010 11:03 PM

    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.

    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points