View Full Version : ActionScript Battle: Electricity
The poll remains open for two weeks, or until one of the contestants gets 30 votes. :)
Rules: http://www.kirupaforum.com/forums/showthread.php?s=&threadid=8786.
Thread: .
Good luck to everyone! :P
Voetsjoeba
09-17-2003, 08:01 AM
I voted for Ilyas. I love the random zaps between the letters.
dessoya
09-17-2003, 08:43 AM
i vote for kode cuz its sexeh :love:
asphaltcowboy
09-17-2003, 08:49 AM
kode get's my vote. nice work everyone :thumb:
Thank you, guys! :love:
And I think we (I?) have a problem here...
If dessoya voted for me, and asphalt voted for me...
Why do I only have one vote!? :P
senocular
09-17-2003, 09:30 AM
someone lied :!: (or didnt actually vote vote)
asphaltcowboy
09-17-2003, 09:38 AM
lol, sorry guys, posted but forgot to actually vote! lmao, I'm such a muppet :P
ROTFLMAO! :P
That was funny! :beam:
Ilyas. Cos he's frog.
J/k - cause I like his work.
dessoya
09-17-2003, 02:14 PM
maybe we should habe a look on the actionscript
this would be better - then we could place our vote on the source not primary on the look :)
~~~~
:thumb::thumb:
Johnny64
09-17-2003, 04:38 PM
Well i think its a good idea ;)
not that you could make senes of my AS :P
Coppertop
09-17-2003, 04:50 PM
I voted for kode. that is some sleek shiznaz.
zylum
09-17-2003, 07:50 PM
i cant see master64's... so i voted fo kode
Makaveli
09-20-2003, 11:23 AM
i voted for master64....i tried touching it but still my hair didn't stick up like it did in the museum...i was a bit dissapointed :|
=)
Originally posted by mlkdesign
Ilyas. Cos he's frog.That's the spirit! :P
And I voted Kode, very sexy work :) My code: //Mouse.hide();
e = 20; // length of the small segments of the letters
// Shape of the letters
letP=[{x:0,y:5*e},{x:0,y:4*e},{x:0,y:3*e},{x:0,y:2*e},{x :0,y:e},
{x:0,y:0},{x:e,y:0},{x:2*e,y:0},{x:3*e,y:0},{x:4*e ,y:e},{x:4*e,y:2*e},
{x:4*e,y:3*e},{x:3*e,y:3*e},{x:2*e,y:3*e},{x:e,y:3 *e},{x:0,y:3*e}
];
letO=[
{x:e,y:0},{x:2*e,y:0},{x:3*e,y:0},{x:4*e,y:e},{x:4 *e,y:2*e},{x:4*e,y:3*e},
{x:4*e,y:4*e},{x:3*e,y:5*e},{x:2*e,y:5*e},{x:e,y:5 *e},{x:0,y:4*e},
{x:0,y:3*e},{x:0,y:3*e},{x:0,y:1*e},{x:e,y:0}
];
letM=[
{x:0,y:5*e},{x:0,y:4*e},{x:0,y:3*e},{x:0,y:2*e},{x :0,y:e},{x:0,y:0},
{x:e,y:e},{x:2*e,y:2*e},{x:3*e,y:e},{x:4*e,y:0},{x :4*e,y:e},{x:4*e,y:2*e},
{x:4*e,y:3*e},{x:4*e,y:4*e},{x:4*e,y:5*e}
];
// the array contains all the vertices of the letters
a = [] ;
// the clip letters contains all the letters...
this.createEmptyMovieClip("letters",-5);
letters.lineStyle(10,0xffffff,30);
// params of the drawLetter function:
// let - letter
// dx - x position
// dy - y position
function drawLetter(let, dx, dy) {
var x=let[0].x+dx;
var y=let[0].y+dy;
a.push({x:x, y:y});
letters.moveTo(x,y);
for (var l=1;l<let.length;l++) {
var x=let[l].x+dx;
var y=let[l].y+dy;
a.push({x:x, y:y});
letters.lineTo(x,y);
}
}
drawLetter(letP,80,150);
drawLetter(letO,230,150);
drawLetter(letM,380,150);
l=a.length;
// params of the drawArc function:
// p1 - starting point
// p2 - ending point
// n - number of arcs
// s - number of intermediary points
MovieClip.prototype.drawArc = function(p1,p2,n,s) {
this.clear();
for (var p=0;p<n;p++){
this.moveTo(p1.x,p1.y);
this.lineStyle(random(3),0xffffff,random(50)+50);
var dx=p2.x-p1.x;
var dy=p2.y-p1.y;
for (var q=1;q<s;q++) {
var px=p1.x+q*dx/s + random(30)-15;
var py=p1.y+q*dy/s + random(30)-15;
this.lineTo(px,py);
}
this.lineTo(p2.x,p2.y);
}
}
// params of the createArc function:
// n - number of arcs
// s - number of intermediary points
function createArc(n, s) {
i++
var arc = this.createEmptyMovieClip("a"+i,i);
// random starting point, ending point selected in the a array
arc.ind1 = random(l-1)+1;
arc.ind2 = random(l-1)+1;
// random direction
arc.dir1 = random(2) ? 1 : -1 ;
arc.dir2 = random(2) ? 1 : -1 ;
arc.onEnterFrame=function() {
// create an arc between the current starting and ending points
this.drawArc(a[this.ind1],a[this.ind2],n,s);
// change those points according to direction
this.ind1+=this.dir1;
this.ind2+=this.dir2;
if (this.ind1<=0 || this.ind1>=l-1) this.dir1*=-1;
if (this.ind2<=0 || this.ind2>=l-1) this.dir2*=-1;
this._alpha--;
if (this._alpha<1) {
delete this.onEnterFrame;
this.removeMovieClip();
}
}
}
interval = setInterval(this,"createArc",random(500)+1000,2,7);I tried to comment it (you need a black background).
Johnny64
09-21-2003, 09:41 AM
Well here is my blocky code :P
this.stop();
MovieClip.prototype.OldCreateEmptyMovieClip = MovieClip.prototype.createEmptyMovieClip;
MovieClip.prototype.createEmptyMovieClip = function(naam, depth, X, Y) {
newMc = this.OldCreateEmptyMovieClip(naam, depth);
newMc._y = Y;
newMc._x = X;
return this.newMc;
};
MovieClip.prototype.makeCircle = function(theColor, theSize, lineColor, thickness) {
this.beginFill(theColor);
this.lineStyle(thickness, lineColor, 100);
for (i=0; i<37; i++) {
this.rotation += 10;
this.Xdistance = Math.sin(this.rotation*Math.PI/180)*theSize;
this.Ydistance = Math.cos(this.rotation*Math.PI/180)*theSize;
this[i == 0 ? "moveTo" : "lineTo"](this.Xdistance, this.Ydistance);
}
this.endFill();
return this;
};
MovieClip.prototype.draw = function(theColor, lineColor, thickness) {
this.lineStyle(thickness, lineColor, 100);
this.beginFill(theColor);
for (g=3; g<arguments.length; g++) {
this[arguments[g].c ? "lineTo" : "moveTo"](arguments[g].x, arguments[g].y);
}
this.endFill();
return this;
};
//-------------------------------------------------------------------------------
createEmptyMovieClip("BG_mc", 0, 0, 0).draw(0x000000, undefined, undefined, {c:1, x:0, y:Stage.height}, {c:1, x:Stage.width, y:Stage.height}, {c:1, x:Stage.width, y:0});
createEmptyMovieClip("holder_mc", 1, Stage.width/2, Stage.height/2+5).draw(0x999999, undefined, undefined, {c:1, x:50, y:0}, {c:1, x:50, y:0}, {c:1, x:40, y:20}, {c:1, x:10, y:40}, {c:1, x:20, y:160}, {c:1, x:50, y:170}, {c:1, x:70, y:190}, {c:1, x:0, y:190}, {c:1, x:0, y:0}).draw(0xcccccc, undefined, undefined, {c:1, x:-50, y:0}, {c:1, x:-50, y:0}, {c:1, x:-40, y:20}, {c:1, x:-10, y:40}, {c:1, x:-20, y:160}, {c:1, x:-50, y:170}, {c:1, x:-70, y:190}, {c:1, x:0, y:190}, {c:1, x:0, y:0});
createEmptyMovieClip("glassRings_mc", 2, Stage.width/2, Stage.height/2+65).draw(undefined, 0x66ccff, 10, {c:0, x:-35, y:0}, {c:1, x:35, y:0}, {c:0, x:-45, y:20}, {c:1, x:45, y:20}, {c:0, x:-35, y:40}, {c:1, x:35, y:40}, {c:0, x:-45, y:60}, {c:1, x:45, y:60}, {c:0, x:-35, y:80}, {c:1, x:35, y:80}).draw(undefined, 0xffffff, 5, {c:0, x:-35, y:-2}, {c:1, x:25, y:-2}, {c:0, x:-45, y:18}, {c:1, x:35, y:18}, {c:0, x:-35, y:38}, {c:1, x:25, y:38}, {c:0, x:-45, y:58}, {c:1, x:35, y:58}, {c:0, x:-35, y:78}, {c:1, x:25, y:78});
createEmptyMovieClip("ballBG_mc", 3, Stage.width/2, Stage.height/2-50).makeCircle(0x000000, 80);
createEmptyMovieClip("mask_mc", 4, Stage.width/2, Stage.height/2-50).makeCircle(0x000000, 80);
createEmptyMovieClip("electric_mc", 5, Stage.width/2, Stage.height/2-50);
createEmptyMovieClip("smallBallGlow_mc", 6, Stage.width/2, Stage.height/2-50).makeCircle(0x0099ff, 17)._alpha = 50;
createEmptyMovieClip("smallBall_mc", 7, Stage.width/2, Stage.height/2-50).makeCircle(0xcccccc, 15);
createEmptyMovieClip("smallBallShine_mc", 8, Stage.width/2-6, Stage.height/2-56).makeCircle(0xeeeeee, 5);
createEmptyMovieClip("bigBall_mc", 9, Stage.width/2, Stage.height/2-50).makeCircle(0x66ccff, 80, 0x0066ff, 10);
createEmptyMovieClip("bigBallShine_mc", 10, Stage.width/2-40, Stage.height/2-90).makeCircle(0x66ccff, 20);
electric_mc.setMask(mask_mc);
//-------------------------------------------------------------------------------
onEnterFrame = function () {
var i = random(40)+10;
bigBall_mc._alpha = i;
bigBallShine_mc._alpha = i;
glassRings_mc._alpha = random(40)+50;
};
for (q=0; q<15; q++) {
newBolt_mc = electric_mc.OldCreateEmptyMovieClip("bolt"+q+"_mc", q);
newBolt_mc.rotation = random(360);
newBolt_mc.dir = random(2);
newBolt_mc.onEnterFrame = function() {
this.dir ? this.rotation += 5 : this.rotation -= 5;
this.clear();
this.moveTo(0, 0);
for (p=1; p<10; p++) {
this.X = random(20)+(Math.sin(this.rotation*Math.PI/180)*Math.sqrt(p)*27)-10;
this.Y = random(20)+(Math.cos(this.rotation*Math.PI/180)*Math.sqrt(p)*27)-10;
random(25) ? this.lineStyle(0, 0x0099ff, 100) : this.lineStyle(0, 0xffffff, 100);
this.lineTo(this.X, this.Y);
}
random(100) ? undefined : this.dir=!this.dir;
};
}
:}
Coppertop
09-21-2003, 11:53 AM
impressive.
dessoya
09-21-2003, 12:20 PM
wow :x
~:thumb:
Thank you all!! :love: :love:
And I'll post my code tomorrow, I forgot my FLA at the office. :P
zylum
09-21-2003, 11:48 PM
wow, master64's is pretty cool (for some reason it doesn't show up on the net for me but now i see it in flash) my code is probably the ugliest (shouldn't have used so many gradients) but hey, what can i do?
Mouse.hide();
/*** create background ***/
_root.createEmptyMovieClip("bg", ++d);
bg.lineStyle(0, 0x000000, 0);
bg.beginFill(0x000000, 100);
bg.lineTo(Stage.width, 0);
bg.lineTo(Stage.width, Stage.height);
bg.lineTo(0, Stage.height);
bg.lineTo(0, 0);
bg.endFill();
/*** create base ***/
thickness = 10;
bcolors = [0xcccccc, 0x000000];
balphas = [100, 100];
bratios = [0, 255];
bmatrix = {matrixType:"box", x:Stage.width/2-20, y:y/4, w:30, h:y/2, r:0};
_root.createEmptyMovieClip("base", ++d);
base.lineStyle(1, 0x333333, 0);
base.beginGradientFill("linear", bcolors, balphas, bratios, bmatrix);
base.moveTo(Stage.width/2-thickness, Stage.height);
base.lineTo(Stage.width/2+thickness, Stage.height);
base.lineTo(Stage.width/2+thickness, Stage.height/2);
base.lineTo(Stage.width/2-thickness, Stage.height/2);
base.lineTo(Stage.width/2-thickness, Stage.height);
base.endFill();
/*** create "sphere" ***/
x = Stage.width/2;
y = Stage.height/2;
R = 50;
a = R*0.4086;
b = R*0.7071;
colors = [0xFFFFFF, 0x000000];
alphas = [100, 100];
ratios = [0, 255];
gradX = gradY=57;
matrix = {matrixType:"box", x:x-gradX, y:y-gradY, w:100, h:100, r:0};
_root.createEmptyMovieClip("circle", ++d);
circle.lineStyle(1, 0x000000, 0);
circle.beginGradientFill("radial", colors, alphas, ratios, matrix);
circle.moveTo(x-R, y);
circle.curveTo(x-R, y-a, x-b, y-b);
circle.curveTo(x-a, y-R, x, y-R);
circle.curveTo(x+a, y-R, x+b, y-b);
circle.curveTo(x+R, y-a, x+R, y);
circle.curveTo(x+R, y+a, x+b, y+b);
circle.curveTo(x+a, y+R, x, y+R);
circle.curveTo(x-a, y+R, x-b, y+b);
circle.curveTo(x-R, y+a, x-R, y);
circle.endFill();
/*** create magnet ***/
mx = 0;
my = 0;
mR = 15;
ma = mR*0.4086;
mb = mR*0.7071;
_root.createEmptyMovieClip("mag", 1000);
mag.lineStyle(14, 0xff0000, 100);
mag.moveTo(mx+10, my+mR);
mag.lineTo(mx, my+mR);
mag.curveTo(mx-ma, my+mR, mx-mb, my+mb);
mag.curveTo(mx-mR, my+ma, mx-mR, my);
mag.curveTo(mx-mR, my-ma, mx-mb, my-mb);
mag.curveTo(mx-ma, my-mR, mx, my-mR);
mag.lineTo(mx+10, my-mR);
mag.createEmptyMovieClip("white", 1001);
mag.white.lineStyle(1, 0xaaaaaa, 0);
mag.white.beginFill(0xaaaaaa, 100);
mag.white.moveTo(mx+10, my-mR+7);
mag.white.lineTo(mx+20, my-mR+7);
mag.white.lineTo(mx+20, my-mR-7);
mag.white.lineTo(mx+10, my-mR-7);
mag.white.lineTo(mx+10, my-mR+7);
mag.white.endFill();
mag.white.beginFill(0xaaaaaa, 100);
mag.white.moveTo(mx+10, my+mR+7);
mag.white.lineTo(mx+20, my+mR+7);
mag.white.lineTo(mx+20, my+mR-7);
mag.white.lineTo(mx+10, my+mR-7);
mag.white.lineTo(mx+10, my+mR+7);
mag.white.endFill();
/*** ELECTRICITY ***/
MovieClip.prototype.moveLght = function(iterations, intensity, thresh) {
this.onEnterFrame = function() {
dist = Math.sqrt((mag._x-this._x)*(mag._x-this._x)+(mag._y-this._y)*(mag._y-this._y))/(iterations+1);
mag.ang = Math.atan2(y-mag._y, x-mag._x);
mag._rotation = mag.ang*180/Math.PI;
mag._x = _xmouse;
mag._y = _ymouse;
if (dist<thresh) {
intens = dist>10 ? intensity/(dist/10) : intensity;
intens = (intens*intens)/20;
alpha = intens//+10;
this.clear();
this.lineStyle(1, 0xffff00, alpha);
this.moveTo(0, 0);
for (i=1; i<=iterations; i++) {
this.lineTo(i*dist, (Math.random()*intens)-intens/2);
}
this.lineTo(i*dist, 0);
ang = Math.atan2(mag._y-this._y, mag._x-this._x);
this._rotation = ang*180/Math.PI;
} else {
this.clear();
this.lineStyle(1, 0xffff00, alpha);
}
};
};
for (num=1; num<=5; num++) {
name = "light"+num;
_root.createEmptyMovieClip(name, ++d);
_root[name]._x = x;
_root[name]._y = y;
_root[name].moveLght(5, num*10, 45);
}
Jasninder
09-22-2003, 10:13 AM
Nice effort all of you, I voted for pom... i like it the best.
Ok. Here's my code:
var origin = {x:Stage.width/2, y:Stage.height/2};
var radius = {r:120, b:20, s:20};
var speed = Math.PI/45;
var speedmax = Math.PI/45;
var lines = 2;
var strength = 4;
var total = 7;
this.createEmptyMovieClip("pos", total);
pos.moveTo(radius.b, 0);
pos.beginGradientFill("radial", [0xCCCCCC, 0x999999], [100, 100], [0, 255], {matrixType:"box", x:-radius.b-radius.b/2, y:-radius.b-radius.b/2, w:radius.b*2, h:radius.b*2, r:0});
for (var radians = 0; radians<Math.PI*2; radians += Math.PI/180) {
pos.lineTo(Math.cos(radians)*radius.b, Math.sin(radians)*radius.b);
}
pos.endFill();
pos._x = origin.x;
pos._y = origin.y;
for (var depth = 0; depth<total; depth++) {
var neg = this.createEmptyMovieClip("neg"+depth, depth);
neg.createEmptyMovieClip("line", 0);
neg.createEmptyMovieClip("ball", 1);
neg.ball.moveTo(radius.s, 0);
neg.ball.beginGradientFill("radial", [0xCCCCCC, 0x999999], [100, 100], [0, 255], {matrixType:"box", x:-radius.s-radius.s/2, y:-radius.s-radius.s/2, w:radius.s*2, h:radius.s*2, r:0});
for (var radians = 0; radians<Math.PI*2; radians += Math.PI/180) {
neg.ball.lineTo(Math.cos(radians)*radius.s, Math.sin(radians)*radius.s);
}
neg.ball.endFill();
neg._x = origin.x;
neg._y = origin.y;
neg.radians = Math.PI*2*depth/total;
neg.onEnterFrame = function() {
this.radians += speed;
var cos = Math.cos(this.radians);
var sin = Math.sin(this.radians);
this.ball._x = cos*radius.r;
this.ball._y = sin*radius.r/2;
this.ball._width = radius.s+sin*radius.s/2;
this.ball._height = radius.s+sin*radius.s/2;
this.swapDepths(sin*total+total);
var xstart = cos*radius.b;
var ystart = sin*radius.b/2;
var xend = cos*radius.r;
var yend = sin*radius.r/2;
var xdiff = xend-xstart;
var ydiff = yend-ystart;
this.line.clear();
for (var index = 0; index<lines; index++) {
this.line.lineStyle(1, 0x000000, sin*20+(80-index*20));
this.line.moveTo(xstart, ystart);
for (var seg = 1; seg<strength; seg++) {
var x = -strength/2+Math.random()*strength+xdiff*seg/strength+xstart;
var y = -strength/2+Math.random()*strength+ydiff*seg/strength+ystart;
this.line.lineTo(x, y);
}
this.line.lineTo(xend, yend);
}
};
}
this.onMouseMove = function() {
var diff = this._xmouse-origin.x;
speed = speedmax*diff/origin.x;
};
And I voted for yours, Ilyas. :love:
thoriphes
09-22-2003, 03:45 PM
ah...nice kode, there code...er...kode....
I see you used that elusive beginGradientFill function, good job :thumb:
Thank you, thor. =)
And zylum also used that elusive beginGradientFill method. :P
zylum
09-22-2003, 08:12 PM
yeah, that beginGradientFill took a while to get the hang of :)
Johnny64
09-23-2003, 03:07 AM
begiGradientFill ?
:(
i still have to look in to that function :P
nice code kode:thumb:
awligon
09-23-2003, 03:12 AM
Originally posted by asphaltcowboy
lol, sorry guys, posted but forgot to actually vote! lmao, I'm such a muppet :P
omg, I could follow this kid around and just laugh all day. I fall out of my chair about once a day reading this kind of nonsense.
REEFˇ
09-28-2003, 08:40 PM
That **** would've been off the hook if Master64 made the cursor a hand, and had a little hair on the side somewhere. When the hand comes close to the electric ball, the hair gets straighter. That **** would've been hot. He would've definelty get like 200 votes from me (if I could).
Johnny64
09-29-2003, 11:44 AM
Originally posted by Sharif
That **** would've been off the hook if Master64 made the cursor a hand, and had a little hair on the side somewhere. When the hand comes close to the electric ball, the hair gets straighter. That **** would've been hot. He would've definelty get like 200 votes from me (if I could).
Well next time better :P
Originally posted by Master64
Well next time better :P Yeah, you could try it in the next battle: a hairy fish that comes close to your electric thing, and whose hair get straighter :nerd: That's a challenge!
Johnny64
09-29-2003, 02:10 PM
It's an idea :thumb:
LOL! I just realized that the poll is over!!
... I guess I won this battle. :P
Coppertop
10-01-2003, 10:45 PM
Nice work kode!
And remember, I voted for you!
Yep, I remember. Thank you. :)
What do you want for christmas? :P
Coppertop
10-01-2003, 11:29 PM
:evil:
let me think
... Think fast, I might forget you voted for me. :P
JK ;)
Thanks, Ilyas.
I can't help thinking you should have won this one, though. Your entry was pretty cool. =)
Johnny64
10-02-2003, 07:17 AM
Congrats ;)
Kode
vulcanpimmmmp
10-11-2003, 09:09 AM
oooooh - I'm too late
I was going to make something for this challenge but couldn't think up anything original
still
tt=2
for (var i = 0; i<52; i++) {
_root.createEmptyMovieClip("grad"+i, i+1);
colour = 12 << 16 | Math.sin(r += .013)*170+85 << 8 | 178;
_root["grad"+i].lineStyle(15, colour, 80);
_root["grad"+i].moveTo(0, 0);
_root["grad"+i].lineTo(1, 1);
_root["grad"+i].onEnterFrame = function() {
tt = (random(30) >1) ? tt: random(3)+1;
this._x = 200+150*(Math.sin(i+((t) += .1525)+xm))/2;
this._y = 200+30*(Math.cos(i+(t+((tt-t)*0.01))+(ym += (0.005*((_ymouse-_xmouse)-ym)))/100))/2;
this._alpha = Math.abs(80*(Math.cos(t*0.001745)));
};
}
Hey! That's very, very cool!! :P
... Too bad you didn't make it in time. :-\
vulcanpimmmmp
10-11-2003, 09:27 AM
ta kode, oh well theres always another time
:nerd:
:link: <whats this
Yeah, I guess so. :P
Welcome to kirupa forum, by the way. =)
PS. That's Link!
Hey Vulcanpimp, nice to see you here. Nice piece by the way, especially for only *counts* 12 lines of code :beam:
vulcanpimmmmp
10-13-2003, 07:59 AM
Great contest btw,
I guess I would have voted for POMs but they were all v good.
abraxas
07-11-2004, 10:29 PM
why does it comes up errors when i try the code? should i have the code on the frame or on a mc??
plz answer!!
abraxas
07-15-2004, 02:12 PM
On a frame.
dont work (i got mx 2004 pro)
Try to compile as AS 1.0 :)
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.