Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / July 2008



Tip: Looking for answers? Try searching our database.

"Dynamic" Default Parameter

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
leatherjeep - 07 Jul 2008 15:03 GMT
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.
David Stiller - 07 Jul 2008 15:33 GMT
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."
leatherjeep - 07 Jul 2008 16:18 GMT
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
David Stiller - 07 Jul 2008 16:58 GMT
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."
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.