In AS2 it does (and has been discussed here in the past), in AS3 it doesn't.
- Original Message -
From: Jesse Graupmann [EMAIL PROTECTED]
To: 'Flash Coders List' flashcoders@chattyfig.figleaf.com
Sent: Wednesday, March 12, 2008 5:38 AM
Subject: RE: [Flashcoders] clean scripting
To: Flash Coders List
Subject: Re: [Flashcoders] clean scripting
In AS2 it does (and has been discussed here in the past), in AS3 it doesn't.
- Original Message -
From: Jesse Graupmann [EMAIL PROTECTED]
To: 'Flash Coders List' flashcoders@chattyfig.figleaf.com
Sent: Wednesday, March 12
So yea...WTF? I can't believe after my years of AS2 coding that it would
have taken me this long to notice.
I think I muttered those exact words. Bizzare behavior. Though I don't think
I have ever run into it. Someone taught me long ago not to initialize class
variables in their definitions.
Here's my understanding of the reason behind this:
AS2 is basically just syntactic sugar over AS1, and gets compiled down
to the same thing.
When defining a class you're actually defining things on the
prototype, so doing this:
--
class MyClass {
public var myArray:Array;
public
, March 12, 2008 9:02 PM
Subject: Re: [Flashcoders] clean scripting
Here's my understanding of the reason behind this:
AS2 is basically just syntactic sugar over AS1, and gets compiled down
to the same thing.
When defining a class you're actually defining things on the
prototype, so doing
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
(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
Not sure if this is correct for AS3, but I was under the impression that
there was an actual performance penalty to doing things the first way
(object creation and assignment in the class definition rather than in the
methods or the constructor).
Still, I like doing things the 2nd way, if only
Either way to me is a non-issue.
However, it is an issue if I want to implement lazy instantiation. That
is, instantiating objects only right before you need them.
Thus, in your first example, the bulk of instantiation occurs up-front.
Lazy instantiation
they're both eager, though, aren't they?
the only difference is that everything is instantiated in the first
method of the class rather than in the class head
a
On 11 Mar 2008, at 18:10, Mark Lapasa wrote:
Either way to me is a non-issue.
However, it is an issue if I want to implement
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
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
Allthough the following no longer seems to apply in AS3, it might be good to
know.
In AS2, if you have the following class:
class MyClass {
private var myArray:Array = new Array();
public function addItem(item:Object) {
myArray.push(item);
}
public function get data():Array {
return
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
I'm going to chime in here.
Lazy Instantiation is an irrelevant argument when you're instantiating
in the constructor. What you perceive as cleaner is merely philosophical.
var container:Sprite = new Sprite();
vs
var container:Sprite;
public function ClassName()
{
container = new
);
}
public function get data():Array
{
return MyClass.myArray;
}
}
regards,
Jesse
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Muzak
Sent: Tuesday, March 11, 2008 4:51 PM
To: Flash Coders List
Subject: Re: [Flashcoders] clean scripting
Of Muzak
Sent: Tuesday, March 11, 2008 4:51 PM
To: Flash Coders List
Subject: Re: [Flashcoders] clean scripting
Allthough the following no longer seems to apply in AS3, it might be good to
know.
In AS2, if you have the following class:
class MyClass {
private var myArray:Array = new Array
PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks
Sent: Tuesday, March 11, 2008 6:49 PM
To: Flash Coders List
Subject: Re: [Flashcoders] clean scripting
I'm going to chime in here.
Lazy Instantiation is an irrelevant argument when you're instantiating
in the constructor. What you
- Original Message -
From: Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED]
To: flashcoders flashcoders@chattyfig.figleaf.com
Sent: Tuesday, March 11, 2008 5:41 PM
Subject: [Flashcoders] clean scripting
hi
just a semantic question really
when writing your classes, would you only
19 matches
Mail list logo