3 Replies Latest reply on Jul 7, 2008 8:58 AM by Newsgroup_User

    "Dynamic" Default Parameter

    leatherjeep Level 1
      How would one tell a Flash Component that has a Parameter, that is viewable through the Parameters tab, to use a variable that has been passed through to the swf via the url? For example, my Flash component has a Default Filename parameter that shows up in the Parameters tab, but I want to set that to be the value that is passed in http://url/myflashfile.swf?filename=myfilname

      Many thanks.


        • 1. Re: "Dynamic" Default Parameter
          Level 7
          leatherjeep,

          > How would one tell a Flash Component that has a Parameter,
          > that is viewable through the Parameters tab, to use a variable
          > that has been passed through to the swf via the url?

          It all depends on what version of ActionScript you're using. If you're
          using ActinScript 3.0, the passed-in variables (aka FlashVars) are available
          in the parameters property of the LoaderInfo instance associated with the
          main timeline.

          In other words:

          root.loaderInfo.parameters

          http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30

          Prior to ActionScript 3.0, the pass-in variables are simply scoped to
          the main timeline as if having been declared there in frame 1.

          So ... if your component's parameter is baconAndEggs, and the passed-in
          variable is orangeJuice, it would look like this in AS3:

          myComponent.baconAndEggs = root.loaderInfo.parameters.orangeJuice;

          ... and like this in AS2:

          myComponent.baconAndEggs = orangeJuice;

          Or you could just enter the part after the equals sign into your
          parameter's panel.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: "Dynamic" Default Parameter
            leatherjeep Level 1
            David,

            Thank you for responding. I'm using AS2. I still have some confusion. In your example the passed in variable is OrangeJuice. But what if on the next user it is HashBrowns? I'm looking for a way to drop in the passed in variable, let's call it BreakfastItem, into the components parameter panel. So in my mind I want to be able to put in #breakfastitem# (I used the pounds only because I'm a cold fusion coder) in the components parameters tab, and have the Flash automatically populate the parameter with the actual value that is passed in. Does that make sense?

            Many thanks again,

            Gary



            • 3. Re: "Dynamic" Default Parameter
              Level 7
              Gary,

              > Thank you for responding. I'm using AS2. I still have some
              > confusion. In your example the passed in variable is OrangeJuice.
              > But what if on the next user it is HashBrowns?

              If the actual name of the external variable changes, then of course
              you'll have to update your ActionScript to look for the new variable. Does
              that make sense?

              > I'm looking for a way to drop in the passed in variable, let's call it
              > BreakfastItem, into the components parameter panel. So in my
              > mind I want to be able to put in #breakfastitem# ... in the
              > components parameters tab, and have the Flash automatically
              > populate the parameter with the actual value that is passed
              > in.

              Based on what you're typed, it looks like the name of your variable is
              breakfastitem, whose string value might be "orange juice" or "hash browns"
              (or whatever) ... which means you'll put breakfastitem (without the pound
              signs) into your parameters panel -- and that assumes that the FlashVars
              variable (the incoming variable) is named breakfastitem.

              If, for some reason, the Parameters panel doesn't agree with dynamic
              data, then give your component an instance name (see the Parameters panel or
              Property inspector) use dot notation, as I showed earlier.

              If this still isn't clear, keep asking. :) What you're after is
              certainly doable, and I'm happy to keep rewording my suggestions until thay
              make sense.


              David Stiller
              Contributor, How to Cheat in Flash CS3
              http://tinyurl.com/2cp6na
              "Luck is the residue of good design."