Ya, I do something similar, its quite handy.

all my flashVars have a "_prm" suffix. I use a singleton class which scans
the root and looks for all values with that suffix. So its as OOP'd as
possible. I've found this quite usefull.  Here is the code:

//----------------------------------------------

class com.kurst.utils.flashVars {
        
        static private var __flashVars:flashVars
        
        static function getVar(name:String):String{
                
                return getInstance().variables[name];
                
        }
        
        static function getVars( ):Object{
                
                return getInstance().variables;
                
        }
        
        static public function getInstance(Void):flashVars {
                
                if( __flashVars == undefined ){
                        
                        __flashVars = new flashVars();
                        __flashVars.findVars();
                        
                }
                
                return __flashVars;
                
        }
        
        private var variables:Object
        
        function flashVars(){
                
                variables = {};
                
        }
        
        public function findVars ():Void{

                for ( var i in _level0 ) {

                        if ( ( i.substring(i.length - 4 ,i.length) ) ==
"_prm" ) {
                                __flashVars.variables[ i.substring(0
,i.length - 4) ] = _level0[i]; 
                        }
                        
                }
                
        }
        
}

//----------------------------------------------
- karim


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Zárate
Sent: 06 June 2006 10:25
To: Flashcoders
Subject: [Flashcoders] FlashVars + OOP, Best Practices?

Hi all,

We all know FlashVars and how useful they are. My question is if is there a
"Best practices" document/post/info somewhere. I'm pretty sure I don't want
to access them with _root.flashvarName. As I am working with MTASC I always
look for them in the MovieClip passed as a parameter to the
main(m:MovieClip) method.

Then, I always prefix them with "fv_". I do that to easily recognise them in
the code.

And last but not least I'm now thinking in forcing me to access them trough
a singleton FlashVarsClass, just to encapsulate them in case Adobe change
the way we should FlashVars. Do we know if this is going to change in Player
9? I've searched Adobe labs, but there's no too much info on this subject.

Any ideas/thoughts/comments would be appreciated.

Cheers : )

ps: Probably this seems overdesign for too many people... insults welcome to
:P

--
Zárate
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training http://www.figleaf.com
http://training.figleaf.com


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.8.1/355 - Release Date: 02/06/2006


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to