thanks for your input everyone
i've gone for the second option because i can template it out better
and it looks waaaaay neater (plus i can still keep all of my
declarations in one place, the setVars() method)
thanks again
here's a copy of my template if you'd like it
//code:
package com.receptacle.timeline
{
//package imports
internal class Class
{
// class variable declarations
// constructor
public function Constructor()
{
setVars();
}
// set class variables
private function setVars()
{
}
}
}
//code
best
a
On 11 Mar 2008, at 22:20, Cory Petosky wrote:
To clarify, this difference only matters in the case of static class
members. Anything non-static gets initialized at constructor-time
regardless -- the difference is syntax only.
On 3/11/08, Cor <[EMAIL PROTECTED]> wrote:
I go for the second option.
Instanciate at the point you need it, and clear if no longer needed.
It also keep memory use limited.
HTH
C
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Allandt
Bik-Elliott (Receptacle)
Verzonden: dinsdag 11 maart 2008 18:41
Aan: flashcoders
Onderwerp: [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
--
No virus found in this incoming message.
Checked by AVG.
Version: 7.5.518 / Virus Database: 269.21.7/1325 - Release Date:
11-3-2008
13:41
No virus found in this incoming message.
Checked by AVG.
Version: 7.5.518 / Virus Database: 269.21.7/1325 - Release Date:
11-3-2008
13:41
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.518 / Virus Database: 269.21.7/1325 - Release Date:
11-3-2008
13:41
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
--
Cory Petosky : Lead Developer : PUNY
1618 Central Ave NE Suite 130
Minneapolis, MN 55413
Office: 612.216.3924
Mobile: 240.422.9652
Fax: 612.605.9216
http://www.punyentertainment.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders