Actually, I've seen that the values are often set quicker when
initilaised in the contructor rather than against class members , but I
think it looks tidier the way you've done it... imo

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Allandt
Bik-Elliott (Receptacle)
Sent: 11 March 2008 17:41
To: flashcoders
Subject: [Flashcoders] clean scripting

hi

just a semantic question really

when writing your classes, would you only declare variables in the class
and assign variables later or would you assign values straight away if
you had them?

so for instance, would you...:

package com.receptacle.timeline
{
        //package imports
        import flash.display.Sprite;
        
        internal class Class extends Sprite
        {
                // class variable declarations
                private var cp:CommonProperties = new
CommonProperties();
                private var commonY:uint = cp. commonY;
                private var commonCopy:String = cp.commonCopy;
                private static var title:String = "Title";
                private static var subtitle:String = "Subtitle";
                
                public function Class()
                {
                        myFunc1();
                }

                private function myFunc1()
                {
                        trace ("function ran");
                        trace ("commonY is "+commonY);
                        trace ("commonCopy is "+commonCopy);
                        trace ("title is "+title);
                        trace ("subtitle is "+subtitle);
                }
        }
}

which works fine but is a little messy at the class level

or would you...:

package com.receptacle.timeline
{
        //package imports
        import flash.display.Sprite;
        
        internal class Class extends Sprite
        {
                // class variable declarations
                private var cp:CommonProperties;
                private var commonY:uint;
                private var commonCopy:String
                private static var title:String
                private static var subtitle:String ;
                
                public function Class()
                {
                        setVars();
                        myFunc1();
                }

                private function setVars()
                {
                        cp =  new CommonProperties();
                        commonY = cp. commonY;
                        commonCopy = cp.commonCopy;
                        title = "Title";
                        subtitle = "Subtitle";
                }

                private function myFunc1()
                {
                        trace ("function ran");
                        trace ("commonY is "+commonY);
                        trace ("commonCopy is "+commonCopy);
                        trace ("title is "+title);
                        trace ("subtitle is "+subtitle);
                }
        }
}

which seems cleaner but is more round the houses.

thanks in advance
a


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

______________________________________________________________________
This e-mail has been scanned for viruses by the Virtual Universe e-mail
security system - powered by MessageLabs.
http://www.virtual-universe.net

______________________________________________________________________

The contents of this email (which include its attachments) are confidential and 
may be subject to legal privilege and protected by copyright. If you are not 
the intended recipient any use, copying or disclosure of this e-mail to any 
third party is strictly forbidden by the sender and we reserve all rights and 
remedies against any person or entity making any such unauthorised use. If you 
have received this email in error, please contact the sender immediately by 
telephone or return the email to the sender and then delete this email and any 
copies of it on your system. Virtual Universe Limited may monitor the contents 
of emails sent and received via its network for viruses and to ensure the 
lawful and authorised use of its systems. Virtual Universe Limited will not be 
held responsible for any damage caused by viruses which may be transmitted upon 
receipt of this email or the opening of any attachment thereto. Any views or 
opinions presented in this email are solely those of th!
 e author and do not necessarily represent those of Virtual Universe Limited.

Virtual Universe Limited is a company established under the laws of England and 
Wales with registered number 03064568 and has its registered office at 1 Regent 
Street, London, SW1Y 4NW and principal place of business at 28-39 The Quadrant, 
135 Salusbury Road, London NW6 6RJ, United Kingdom. It is registered for VAT in 
the United Kingdom with number GB877113217.


______________________________________________________________________
This e-mail has been scanned for viruses by the Virtual Universe e-mail 
security system - powered by MessageLabs. http://www.virtual-universe.net

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to