PDA

View Full Version : Reusable block of code


farafiro
08-26-2003, 08:41 AM
ok, the idea is more like JLM wrote on the ADD Line Change Line challange:
Originally posted by JLM
suggestion: life, the aim is to create lifeforms that interact on the screen. Mating should be included some how and some how fitness should be defined by 'beauty'. Any one can add or modify a function method or class, but each should try to contain an idea, ie function Movement. the world should aim to be underwater and 3D. no function method or class should be more than 25 lines and where possible it should cram on one line. If there is no post in 1 week a new competition starts. well thats my idea anyway. sure there are some better ideas out there.

JLM

My Idea:
Make any reusable block like prototype, functions,........ that can be used too easy to create something usefull
let's start with only one ruel "25 line", I think it should be more, but let's try it
another thing, what do u think to make it time limit challaenge, for example it lasts for one month from now

farafiro
08-26-2003, 09:03 AM
ok, I will start
Aim, is to make a menu/button system that u can built any part of the menu with only one line

//////////////////// Menu, Button System v1001 ////////////////
/////////////////// auther : Farafiro <Alfred> ////////////////////
////////////////////////////////////////////////////////////////////////
// Variables :
// mcNam : The name of the created MC/Button
// mcDpth : The depth of the created MC/Button
// txtNam : The name of the created textfield in the MC/Button
// mcX, mcY : The coordinates of the created MC/Button
// mcCol : The color of the created MC/Button
// btWidth, btHeight : The dimentions of the created MC/Button
////////////////////////////////////////////////////////////////////////
MovieClip.prototype.createMenu = function(mcNam, mcDpth, txtNam, mcX, mcY, mcCol, btWidth, btHeight) {
mc = this;
mc.txtNam = txtNam;
mc.mcNam = mcNam;
mc.mcDpth = mcDpth;
mc.mcX = mcX;
mc.mcY = mcY;
pointsArray = [[0, 0], [btWidth, 0], [btWidth, btHeight], [0, btHeight]];
bt = mc.createEmptyMovieClip(mc.mcNam, mc.mcDpth);
bt._x = mc.mcX;
bt._y = mc.mcY;
bt.beginFill(mcCol);
for (i in pointsArray) {
bt.lineTo(pointsArray[i][0], pointsArray[i][1]);
}
mc.bt.createTextField("txt", 10, _x+2, _y+2, mc.bt._width-5, mc.bt._height-5);
mc.bt.txt.border = true;
mc.bt.txt.text = mc.txtNam;
};
////////////////////////////// Usage /////////////////////////////////
_root.createMenu("a", 1, "First", 50, 100, 0xFF6600, 100, 36);
_root.createMenu("b", 2, "Second", 150, 100, 0x336699, 100, 36);
_root.createMenu("c", 3, "Third", 250, 100, 0xFF99FF, 100, 36);
_root.createMenu("d", 4, "Fourth", 350, 100, 0xFF6699, 100, 36);
////////////////////////////// Testing /////////////////////////
a.onRollOver = b.onRollOver=c.onRollOver=d.onRollOver=function () {
trace(this.txt.text);
};

farafiro
08-29-2003, 10:07 AM
over 50 visitors and no additions
I guess no one interested

pom
08-29-2003, 10:13 AM
I'm afraid it's not precise enough... :( Make any reusable block that can be used to create something usefullThat's too vague, Fara :)

farafiro
08-31-2003, 05:01 AM
so, what do u suggest??

pom
08-31-2003, 05:57 PM
Well, for instance, "Reusable Actionscript navigation systems" would be a bit more precise :)

farafiro
09-01-2003, 03:25 AM
so would u start?? give hints??

pom
09-01-2003, 07:47 AM
Well, YOU started :) I'll try to add something tonight...

black
09-22-2003, 01:57 AM
Originally posted by farafiro
so, what do u suggest??

from your content of post on top reusable functions wil be a sensible, i think.