all groups > flash actionscript > september 2007 >
You're in the

flash actionscript

group:

Is that a good scripting practice?


Is that a good scripting practice? mlsmet
9/23/2007 12:00:00 AM
flash actionscript:
When I have to work with ActionScript 1, I still use prototypes.
But a friend of mine prefers using another method (see example below).
It looks like classes (sort of). It works fine but is it a good scripting
practice? Better than using prototypes with AS1?

clip1.fadeMe = function(out, speed) {
this.onEnterFrame = function() {
if (out) {
(this._alpha>speed) ? this._alpha -= speed : delete this.onEnterFrame;
} else {
(this._alpha<100) ? this._alpha += speed : delete this.onEnterFrame;
}
};
};
clip1.onRollOver = function() {
this.fadeMe(true, 25);
};
clip1.onRollOut = function() {
this.fadeMe(false, 25);
};

Thanks for your comments.
Serge
Re: Is that a good scripting practice? fanglinyong
9/23/2007 12:00:00 AM
yes ,its better than your code
Re: Is that a good scripting practice? kglad
9/23/2007 2:13:14 PM
Re: Is that a good scripting practice? mlsmet
9/23/2007 9:51:29 PM
Thank you for your comments.
The way I was coding was with prototypes. Like this:

MovieClip.prottype.fadeMe = function(out, speed) {
this.onEnterFrame = function() {
if (out) {
(this._alpha>speed) ? this._alpha -= speed : delete
this.onEnterFrame;
} else {
(this._alpha<100) ? this._alpha += speed : delete
this.onEnterFrame;
}
};
};
clip1.onRollOver = function() {
this.fadeMe(true, 25);
};
clip1.onRollOut = function() {
this.fadeMe(false, 25);
};

There's no much difference between the 2 methods, except that Prototypes are
added for all MovieClip objects while the 'fadeMe' method used by my friend is
implemented locally, only for the MovieClip you use to apply this method.
So, is it definitely better to ovoid Prototype and use the 'local' method?
Thanks
Serge
Re: Is that a good scripting practice? kglad
9/23/2007 10:08:07 PM
Re: Is that a good scripting practice? SpaceGirl
9/25/2007 10:58:40 PM
[quoted text, click to view]

That's never true :) Clean code is easier to understand :D

--

x theSpaceGirl (miranda)

http://www.northleithmill.com

-.-

AddThis Social Bookmark Button