PDA

View Full Version : eye candy Flowers


McGiver
09-05-2003, 03:31 PM
hmm, there aren't really many JfKCs at the moment, so here is a new one!
Standard rules + max linecount: let's say 35 lines (because the drawing methods take many lines)

I think flowers is a big theme, so everybody might be abled to imagine something.

Theme is whatever you can associate with flowers!
moving blossoms, growing flowers,... whatever

McGiver
09-05-2003, 05:09 PM
Ok, here is my one

//set fps to 24 and background to orange
function createflowerblast(i) {
_root.createEmptyMovieClip("flower"+i, i+100);
_root["flower"+i]._x = _xmouse;
_root["flower"+i]._y = _ymouse;
_root["flower"+i].leafs = Math.round(Math.sqrt(Math.random()*80))+3;
_root["flower"+i].leafpoints = Math.round((Math.random()*2+1))*2;
_root["flower"+i][leafpoint+(0)] = -Math.sqrt(Math.random()*100)*3;
for (k=1; k<=_root["flower"+i].leafpoints; k++) {
_root["flower"+i][leafpoint+k] = _root["flower"+i][leafpoint+(k-1)]-Math.sqrt(Math.random()*100)*3+5;
_root["flower"+i].leafsize += _root["flower"+i][leafpoint+k];}
_root["flower"+i].leafcolor = [parseInt(("0x"+(Math.round(Math.random()*239+16)).toString(16)+"ff"+(Math.round(Math.random()*239+16)).toString(16))) , parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16)))];
for (j=0; j<_root["flower"+i].leafs; j++) {
_root["flower"+i].createEmptyMovieClip("leaf"+j, j+10);
_root["flower"+i]["leaf"+j].lineStyle(1, 0x990000, 50);
_root["flower"+i]["leaf"+j].beginGradientFill("radial", _root["flower"+i].leafcolor, [100, 100], [0, 255], {matrixType:"box", x:(-_root["flower"+i].leafsize)/2-10, y:(-_root["flower"+i].leafsize)/2-10, w:_root["flower"+i].leafsize+20, h:_root["flower"+i].leafsize+20, r:(0/180)*Math.PI});
for (k=1; k<=(_root["flower"+i].leafpoints); k += 2) {
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*-15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafpoints-(k+1))*-15, _root["flower"+i][leafpoint+(k+1)]);}
for (k=(_root["flower"+i].leafpoints)-1; k>1; k -= 2) {
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafpoints-(k-1))*15, _root["flower"+i][leafpoint+(k-1)]);}
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*15, _root["flower"+i][leafpoint+k], 0, 0);
_root["flower"+i]["leaf"+j].endFill();
_root["flower"+i]["leaf"+j]._rotation = j*(360/_root["flower"+i].leafs);}}
function doflowerblast(grow, i) {
_root["flower"+i]._xscale = _root["flower"+i]._yscale=grow;}
_root.flowerarr = [];
_root.onEnterFrame = function() {
for (n=i-5; n<=i; n++) {
_root["flower"+n].grow += 200000;
doflowerblast(Math.sqrt(Math.sqrt(_root["flower"+n].grow)),n);}};
_root.onMouseMove = function() {
i++;
createflowerblast(i);};

dzy2566
09-05-2003, 05:46 PM
Well, it's embarassing to submit this after seing McGiver's, but here you go. I went with the basic SIM approach. I know it's boring, but I also only spent about a half hour on it. It was better than what I get paid to do, so :)

The flower grows on sunny days. If it doesn't get rain for more than 4 days, it dies. There is a 40% chance of rain everyday.

daysWoRain = 0;
numDay = 1;
_root.createEmptyMovieClip("flower",1);
_root.lineStyle(5,0x006600,100);
_root.moveTo(0,400);
_root.lineTo(550,400);
flower.lineStyle(1,0x000000,100);
flower.moveTo(5,0);
flower.lineTo(5,-100);
flower.curveTo(80,-120,65,-165);
flower.curveTo(0,-125,-65,-165);
flower.curveTo(-120,-145,-5,-100);
flower.lineTo(-5,0);
flower._x = 275;
flower._y = 400;
interval = setInterval(updateFlower,3000);
function updateFlower(path){
num = Math.random()*10;
numDay++;
if(num >6){
daysWoRain = 0;
typeOfDay = "Rainy :(";
}else{
if(daysWoRain <= 4){
typeOfDay = "Sunny :)"
_root.flower._xscale *= 1.05;
_root.flower._yscale *= 1.1;
daysWoRain++;
}else { killFlower(_root.flower);}}
trace("Day "+numDay+": "+typeOfDay+" Days w/o rain:"+daysWoRain);
};
function killFlower(path){
path.removeMovieClip();
trace("Your flower has died");
clearInterval(interval);}
I'll be back at a computer by sunday, hopefully people will play with this. If not, I'll try and make it more exciting, when I'm at home not wasting my boss's money.

McGiver
09-05-2003, 06:07 PM
hmm, it should not be embarassing. I just spend more time on it (about 2 hours)

Note: the flower is always dying, so i think the code was ment to be
num = Math.random()*100

vulcanpimp
09-06-2003, 07:34 AM
nice scripts. has anyone seen a site called something like u-control.com

it was around about two years ago , and showed scripts to make flowers grow. They not only looked good but grew realistically as well.

McGiver
09-06-2003, 12:59 PM
two variations:

more color:
//background=white/orange; fps =24
function createflowerblast(i) {
_root.createEmptyMovieClip("flower"+i, i+100);
_root["flower"+i]._x = _xmouse;
_root["flower"+i]._y = _ymouse;
_root["flower"+i].leafs = Math.round(Math.sqrt(Math.random()*80))+3;
_root["flower"+i].leafpoints = Math.round((Math.random()*2+1))*2;
_root["flower"+i][leafpoint+(0)] = -Math.sqrt(Math.random()*100)*3;
for (k=1; k<=_root["flower"+i].leafpoints; k++) {
_root["flower"+i][leafpoint+k] = _root["flower"+i][leafpoint+(k-1)]-Math.sqrt(Math.random()*100)*3+5;
_root["flower"+i].leafsize += _root["flower"+i][leafpoint+k];}
_root["flower"+i].leafcolor = [parseInt(("0x"+(Math.round(Math.random()*239+16)).toString(16)+"ff"+(Math.round(Math.random()*239+16)).toString(16))) , parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16))), parseInt(("0x"+(Math.round(Math.random()*155+100)).toString(16)+ (Math.round(Math.random()*155+100)).toString(16)+( Math.round(Math.random()*155+100)).toString(16)))];
for (j=0; j<_root["flower"+i].leafs; j++) {
_root["flower"+i].createEmptyMovieClip("leaf"+j, j+10);
_root["flower"+i]["leaf"+j].lineStyle(1, 0x990000, 50);
_root["flower"+i]["leaf"+j].beginGradientFill("radial", _root["flower"+i].leafcolor, [100, 100,100, 100,100, 100], [0,60,100,140,180, 255], {matrixType:"box", x:(-_root["flower"+i].leafsize)/2-10, y:(-_root["flower"+i].leafsize)/2-10, w:_root["flower"+i].leafsize+20, h:_root["flower"+i].leafsize+20, r:(0/180)*Math.PI});
for (k=1; k<=(_root["flower"+i].leafpoints); k += 2) {
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*-15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafpoints-(k+1))*-15, _root["flower"+i][leafpoint+(k+1)]);}
for (k=(_root["flower"+i].leafpoints)-1; k>1; k -= 2) {
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafpoints-(k-1))*15, _root["flower"+i][leafpoint+(k-1)]);}
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*15, _root["flower"+i][leafpoint+k], 0, 0);
_root["flower"+i]["leaf"+j].endFill();
_root["flower"+i]["leaf"+j]._rotation = j*(360/_root["flower"+i].leafs);}}
function doflowerblast(grow, i) {
_root["flower"+i]._xscale = _root["flower"+i]._yscale=grow;}
_root.flowerarr = [];
_root.onEnterFrame = function() {
for (n=i-5; n<=i; n++) {
_root["flower"+n].grow += 200000;
doflowerblast(Math.sqrt(Math.sqrt(_root["flower"+n].grow)),n);}};
_root.onMouseMove = function() {
i++;
createflowerblast(i);};

I really love this one:
//background=white; fps =24
function createflowerblast(i) {
_root.createEmptyMovieClip("flower"+i, i+100);
_root["flower"+i]._x = _xmouse;
_root["flower"+i]._y = _ymouse;
_root["flower"+i].leafs = Math.round(Math.sqrt(Math.random()*80))+3;
_root["flower"+i].leafpoints = Math.round((Math.random()*2+1))*2;
_root["flower"+i][leafpoint+(0)] = -Math.sqrt(Math.random()*100)*3;
for (k=1; k<=_root["flower"+i].leafpoints; k++) {
_root["flower"+i][leafpoint+k] = _root["flower"+i][leafpoint+(k-1)]-Math.sqrt(Math.random()*100)*3+5;
_root["flower"+i].leafsize += _root["flower"+i][leafpoint+k];}
for (j=0; j<_root["flower"+i].leafs; j++) {
_root["flower"+i].createEmptyMovieClip("leaf"+j, j+10);
_root["flower"+i]["leaf"+j].lineStyle(1, 0x990000, 50);
_root["flower"+i]["leaf"+j].beginFill(0xffffff,50)
for (k=1; k<=(_root["flower"+i].leafpoints); k += 2) {
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*-15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafpoints-(k+1))*-15, _root["flower"+i][leafpoint+(k+1)]);}
for (k=(_root["flower"+i].leafpoints)-1; k>1; k -= 2) {
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*15, _root["flower"+i][leafpoint+k], Math.sqrt(_root["flower"+i].leafpoints-(k-1))*15, _root["flower"+i][leafpoint+(k-1)]);}
_root["flower"+i]["leaf"+j].curveTo(Math.sqrt(_root["flower"+i].leafpoints-k)*15, _root["flower"+i][leafpoint+k], 0, 0);
_root["flower"+i]["leaf"+j].endFill()
_root["flower"+i]["leaf"+j]._rotation = j*(360/_root["flower"+i].leafs);}}
function doflowerblast(grow, i) {
_root["flower"+i]._xscale = _root["flower"+i]._yscale=grow;}
_root.flowerarr = [];
_root.onEnterFrame = function() {
for (n=i-5; n<=i; n++) {
_root["flower"+n].grow += 20000000000000;
doflowerblast(Math.sqrt(Math.sqrt(Math.sqrt(_root["flower"+n].grow))),n);}};
_root.onMouseMove = function() {
i++;
createflowerblast(i);};

McGiver
09-06-2003, 01:28 PM
hmm, tell me if I'm wrong, but is it possible that the interess of most people here is far away from Just for kicks challanges?!
Come on guys (and girls) summer is over! time to get back to the good old PC!
This is no competition! just feel free to post what you created, or create something! Don't care to be better or worse than anyone else! Try to be different, and show us what you imagined to a theme! :)

@ dzy2566 I like your living plant!

dzy2566
09-08-2003, 09:23 AM
Thanks Mc., I'm going to hit it again tonight and see what else I can do with it. I was away camping this weekend so I didn't have tiem to play with it, but it was a blast. Though my fingers are killing me from palying the guitar so much. I'm not sure I can type anymore. Ha. Anyway, I appreciate the encouragement and I'm going to submit another one soon.

vulcanpimp
09-08-2003, 11:48 AM
this is my attempt.

its a few lines over but, quite frankly it doesn't bother me.

you can download it here.
http://www.geocities.com/hairybobby2000/fxflower.html

or the codes here

this.createEmptyMovieClip("flame", 2);
with (_root.flame) {
matrix = {a:200, b:0, c:0, d:110, e:100, f:0, g:0, h:00, i:1};
beginGradientFill("linear", [0x343ee0, 0x00eeFF], [100, 90], [0, 0xFF], matrix);
for (i=0; i<5; i++) {
curveTo(170*Math.cos((i-140)*72*0.0175), 170*Math.sin((i-140)*72*0.0175), 170*Math.cos((i)*72*0.0175), 170*Math.sin((i)*72*0.0175));
curveTo(170*Math.cos((i+170)*72*0.0175), 170*Math.sin((i+170)*72*0.0175), 0, 0);
}
endFill();
}
_root.createEmptyMovieClip("stem", 1);
flame._xscale = 0;
flame._yscale = 0;
ht = random(33)+140;
wd = random(50)-25;
yyy3 = 155;
yyy33 = yyy3/20;
xxx3 = random(50)-25;
xxx33 = xxx3/20;
yyy2 = yyy3/2;
xxx2 = -xxx3/2;
yyy22 = yyy2/20;
xxx22 = xxx2/20;
stem._x = 200;
stem._y = 144;
stem.onEnterFrame = function() {
stem.Clear();
stem.lineStyle(flame._xscale/15, 0x2f3342, 100);
xxx22 = xxx22+((xxx2-xxx22)*.02);
yyy22 = yyy22+((yyy2-yyy22)*.02);
xxx33 = xxx33+((xxx3-xxx33)*.02);
yyy33 = yyy33+((yyy3-yyy33)*.02);
stem.moveTo(0, 0);
stem.curveTo(xxx22,-yyy22,xxx33,-yyy33);
flame._x = xxx33+stem._x;
flame._y = -yyy33+stem._y;
flame._rotation = xxx33*5;
flame._xscale = flame._xscale+((100-flame._xscale)*0.015);
flame._yscale = flame._yscale+((100-flame._yscale)*0.015);
};

McGiver
09-08-2003, 12:14 PM
yeah, this looks cool!

vulcanpimp
09-08-2003, 12:30 PM
thanks mcgiver,

btw, i think the reason noones interested at the moment is that theres a nasty worm(sounds like a good idea for a challenge) knocking around the internet. I've found it difficult to log on for days now

dzy2566
09-08-2003, 01:40 PM
Just a note, not that anyone cares. I fixed the problem that kills the flower every time. I had a var in there forcing it to not rain, to make sure that it would die, then I forgot to change it back. Thanks for the note though, McGiver.

dzy2566
09-09-2003, 12:36 AM
Here's another one. I'd like to add some more interesting color to it, but that's for another time.
//make the background color #FFFF99
Mouse.hide();
numNewPetals=0;
_root.createEmptyMovieClip("flowerHolder",1);
flowerHolder.createEmptyMovieClip("petal",2);
_root.onMouseMove = function(){
xPerc = (_root._xmouse/550)*25+10;
yPerc = (_root._ymouse/400)*75+35;
width = xPerc*2;
rotat = width;
numPetals = Math.floor(360/width);
flowerHolder.petal.clear();
flowerHolder.petal.lineStyle(1,0x000000,100);
flowerHolder.petal.beginFill(0xff9999,100);
flowerHolder.petal.curveTo(xPerc,(yPerc/2),0,yPerc);
flowerHolder.petal.curveTo(-xPerc,(yPerc/2),0,0);
flowerHolder.petal.endFill();
for(i=0;i<numNewPetals;i++){flowerHolder["petal"+i].removeMovieClip();}
numNewPetals=0;
for(i=0;i<numPetals;i++){
flowerHolder.petal.duplicateMovieClip("petal"+i,i+500);
flowerHolder["petal"+i]._rotation = rotat;
rotat += width;
numNewPetals++;
}
_root.flowerHolder._x = _xmouse;
_root.flowerHolder._y = _ymouse;
_root.clear();
_root.moveTo(275,375);
_root.lineStyle(4,0x006600,100);
_root.curveTo(275,150,_xmouse,_ymouse);
updateAfterEvent();
}

dzy2566
09-09-2003, 10:53 AM
Slight variation:
//make the background color #FFFF99
Mouse.hide();
numNewPetals=0;
_root.createEmptyMovieClip("flowerHolder",1);
flowerHolder.createEmptyMovieClip("petal",2);
_root.onMouseMove = function(){
xPerc = (_root._xmouse/550)*25+50;
yPerc = (_root._ymouse/400)*75+65;
width = xPerc*.5;
rotat = width;
numPetals = Math.floor(360/width);
flowerHolder.petal.clear();
flowerHolder.petal.lineStyle(1,0x000000,100);
flowerHolder.petal.beginFill(0xff9999,40);
flowerHolder.petal.curveTo(xPerc,(yPerc/2),0,yPerc);
flowerHolder.petal.curveTo(-xPerc,(yPerc/2),0,0);
flowerHolder.petal.endFill();
for(i=0;i<numNewPetals;i++){flowerHolder["petal"+i].removeMovieClip();}
numNewPetals=0;
for(i=0;i<numPetals;i++){
flowerHolder.petal.duplicateMovieClip("petal"+i,i+500);
flowerHolder["petal"+i]._rotation = rotat;
rotat += width;
numNewPetals++;
}
_root.flowerHolder._x = _xmouse;
_root.flowerHolder._y = _ymouse;
_root.clear();
_root.moveTo(275,375);
_root.lineStyle(4,0x006600,100);
_root.curveTo(275,150,_xmouse,_ymouse);
updateAfterEvent();
}

vulcanpimp
09-10-2003, 10:46 AM
I had a rego at mine. and it kind o went right in a wrong kinda way. you can download it here (the second version)

http://www.geocities.com/hairybobby2000/fxflower.html

or mess about with your mouse here


this.createEmptyMovieClip("flame", 2);
with (_root.flame) {
matrix = {a:200, b:0, c:0, d:110, e:100, f:0, g:0, h:00, i:1};
beginGradientFill("linear", [0x343ee0, 0x00eeFF], [100, 100], [0, 0xFF], matrix);
for (i=0; i<260; i++) {
curveTo(60*Math.cos((i-10)*72*0.0175), 60*Math.sin((i-10)*72*0.0175), 100*Math.cos((i)*72*0.0175), 100*Math.sin((i)*72*0.0175));
curveTo(60*Math.cos((i+10)*72*0.0175), 60*Math.sin((i+10)*72*0.0175), 0, 0);
}
endFill();
}
_root.createEmptyMovieClip("stem", 1);
flame._xscale = 0;
flame._yscale = 0;
ht = random(33)+140;
wd = random(50)-25;
yyy3 = 155;
yyy33 = yyy3/20;
xxx3 = random(50)-25;
xxx33 = xxx3/20;
yyy2 = yyy3/2;
xxx2 = -xxx3/2;
yyy22 = yyy2/20;
xxx22 = xxx2/20;
stem._x = 200;
stem._y = 144;
stem.onEnterFrame = function() {
stem.Clear();
stem.lineStyle(flame._xscale/15, 0x2f3342, 100);
xxx22 = xxx22+((xxx2-xxx22)*.02);
yyy22 = yyy22+((yyy2-yyy22)*.02);
xxx33 = xxx33+((xxx3-xxx33)*.02);
yyy33 = yyy33+((yyy3-yyy33)*.02);
stem.moveTo(0, 0);
stem.curveTo(xxx22,-yyy22,xxx33,-yyy33);
flame._x = xxx33+stem._x;
flame._y = -yyy33+stem._y;
flame._rotation = xxx33*5;
flame._xscale = flame._xscale+((100-flame._xscale)*0.015);
flame._yscale = flame._yscale+((100-flame._yscale)*0.015);
};


with a thin petal you get a nice effect if the xscale is changeing.

I saw the same thing with dzy2566's try

pom
09-21-2003, 03:20 PM
Originally posted by vulcanpimp
nice scripts. has anyone seen a site called something like u-control.com

it was around about two years ago , and showed scripts to make flowers grow. They not only looked good but grew realistically as well. That would be www.uncontrol.com the site of Manny Tan, and the project was called Flora, I think. That was bad ass AS...

pom
09-21-2003, 03:21 PM
By the way, something I did some time ago:fS={w:12,f:3};
flowerArray=[{x:0,y:-fS.w},{x:fS.f,y:-fS.f},{x:fS.w,y:0},{x:fS.f,y:fS.f},{x:0,y:fS.w},{x :-fS.f,y:fS.f},{x:-fS.w,y:0},{x:-fS.f,y:-fS.f},{x:0,y:-fS.w}];
function drawLeaf(targ,x,y,i){
var mc=targ.createEmptyMovieClip("leaf"+i,i);
if (Math.random() < .7){
mc.beginFill(0x00ff00,100);
mc.curveTo(-10,-10,0,-random(20)-20);
mc.curveTo(10,-10,0,0);
(new Color(mc)).setTransform({ga:70+random(30),ba:0,ra: 0});
}
else {
mc.beginFill(0xFB44B7,100);
mc.moveTo(flowerArray[0].x,flowerArray[0].y);
for (var p in flowerArray) mc.lineTo(flowerArray[p].x,flowerArray[p].y);
(new Color(mc)).setTransform({gb:(a=-50+random(50)),bb:a,rb:a});
}
mc._x=x;
mc._y=y;
mc._rotation=random(360);
}
function growBranch(i){
var mc=this.createEmptyMovieClip("branch"+i,i);
mc.lineStyle(1,0x00ff00,100);
mc.moveTo((x=random(400)),200);
for (var i=0;i < (nb=30+random(100));i++) {
mc.lineTo(a=(x+(nb-i)*0.007*(random(21)-10)),300-5*i);
if (random(5)%2){
drawLeaf(mc,a,300-5*i,++p);
}
}
}
for (var j=0; j < 30; j++) growBranch(j);
this.onMouseDown = function () {
for (var j=0; j < 30; j++) growBranch(j);
}I'll try to do something new for this challenge :)

vulcanpimp
09-23-2003, 09:18 AM
hi Pom,

thanks for the info on Uncontrol.com . I can't decide which is my favorite site - uncontrol or levitatednet.com .

ben_brown30
09-25-2003, 11:16 AM
Hi guys

Hope you don't mind me having a go! I'm a bit new to Flash and this is my first contest but hope this is relavent!

Feel free to alter this as you see fit to make it better or add features, its only about 25 lines I think!

Took me around 2 hours to acheive but that was learning to use the drawing and trying to get the flowers to look rougly right!

var colours = [0xff99ff, 0xFF0000, 0x00ff00, 0x0000FF, 0xFFFF00, 0x00ffff, 0xff00ff, 0xff9933, 0xcc33ff, 0x0033ff]

function createFlower(XPos, YPos, XMove, YMove, Stretch, Size, Colour, Alpha, Petals)
{
var mc = _root.createEmptyMovieClip("flower"+count, count);
mc._x = XPos;
mc._y = YPos;
mc.moveTo(0, 0);
mc.lineStyle(Size / 8, 0x000000, Alpha);
mc.beginFill(Colour, Alpha);
mc.curveTo((Size * XMove), (Size * YMove), (size * Stetch), (Size * Stretch));
mc.curveTo((Size * YMove), (Size * Xmove), 0, 0);
mc.endFill();

count++;

for (i = 0; i < Petals; i++)
{
var mc2 = mc.duplicateMovieClip("petal"+count, count);
mc2._rotation = ((360 / Petals) * i);
count++;
mc2._x = XPos;
mc2._y = YPos;
}
}

for (j = 0; j < 150; j++)
{
createFlower(random(500), random(500), random(20), random(40), random(20), random(10), colours[random(10)], random(100) + 30, random(10));
}

ben_brown30
09-25-2003, 11:18 AM
Sorry forgot to say works best with canvas size 500 x 500 and you can set any background colour but a dark green is good!!

Ben

vulcanpimp
09-27-2003, 06:02 AM
hi ben brown, its a funny thing looking at your code. But in all my time looking at these 25 line challenges (thats about 4 weeks btw) I've never seen an example using duplicatemovieclip.

I don't know if thats good or bad?!

ben_brown30
09-27-2003, 06:10 AM
Not sure whether its a good or bad thing either to be honest, it just lets you do more in my opinion as you can duplicate many clips. I've only been looking at 25 line challenges for the same time as you but I don't really know if they include any rules not to include the duplicateMovieClip function?

Ben

pom
09-27-2003, 07:59 PM
You are -of course- allowed to use duplicateMovieClip :)

And that's very nice, especially, when you've corrected the typo in your code: it should be Stretch in the first curveTo, not Stetch.

pom :)

pom
09-27-2003, 08:10 PM
26 lines, sorry :)// pom -- Flowers -- Credits: Glenn Rhodes
function drawPetal(clip, col){
with (clip.createEmptyMovieClip("petal"+i,i++)) {
colors = [ 0xFFFFFF, col ];
alphas = [ 100, 100 ];
ratios = [ 0x00, 0xc0 ];
matrix = { matrixType:"box", x:0, y:10, w:60, h:60, r: Math.PI/2 };
beginGradientFill( "linear", colors, alphas, ratios, matrix );
moveto(-10,10);
lineTo(10,40);
curveTo(0,80,-20,40);
lineTo(-10,10);
endFill();
return clip["petal"+i];
}
}
function flower(){
var a = this.createEmptyMovieClip("flower"+v,v++);
x = random (200) ;
y = random (200) ;
col = random(0xffffff);
for (i=0; i<150; i++) {
var clip = drawPetal(a, col);
clip._x=x;
clip._y=y;
clip._rotation = Math.random()*360;
clip._xscale = clip._yscale = random(50)+10;
clip.swapDepths(2000-clip._xscale) ;
}
}
for (var j=0; j < 30; j++) flower () ;

McGiver
09-27-2003, 08:39 PM
wow, I have been noticed in a as.org newsletter :D
the new scripts here are quite impressive
@dzy:
the last one looks really good
@vulcanpimp:
well I don't know what all this Math does ;) , but the flower looks cool
@ben_brown30:
very impressive for someone new to flash and drawing api
@pom:
wow again! it looks like a painting.

ben_brown30
09-29-2003, 06:02 AM
@pom cheers for correcting my typo, did wonder why it was looking a little deformed before!! I like the realism in your flowers!!

vulcanpimp
09-29-2003, 12:20 PM
McGiver,

I was surprised that the AS challenge got such a mention in the newsletter. If I knew people actually looked at these things I would have attempted to get some nice colors for my flower.

Truth be told, I thought the challenges were students or anyone else with nothing better to do. I just started doing challenges as a way of learning AS. I tell you its much easier doing a challenge than it is trying to decode some demo with some vital piece of AS attached to a 1 pixel wide movie clip. At least you know where you are with challenges.

McGiver
09-29-2003, 01:31 PM
well, that was what the newsletter said:
This newsletter's featured Just For Kicks Challenge is: Eye-Candy: Flowers, started by McGiver.
Just For Kicks Challenges are friendly ActionScript coding competitions. You can find out more about them here and start your own here. We feature one Challenge in each Newsletter distribution.

Jfk challenges are for learning flash

dzy2566
09-29-2003, 01:59 PM
Any chance you could forward that newsletter to me, or link me to a copy? I didn't subscribe until today.

vulcanpimp
09-30-2003, 09:00 AM
oh so I did get the newsletter - when you mentioned all these quotes mcgiver I thought the newsletter was some printed thing sent out by post.

Ben brown : Its not a bad thing at all that you use duplicate movie clip. The only reason I mentioned it was because when I look through these challenges I try to spot a possible template for my own use. And I must have looked though about 100 challenges on various sites and not spotted one with duplicatemovierclip.

McGiver
09-30-2003, 11:38 AM
wow, what an interest for a simple newsletter! I guess it has the chance to become a bestseller!
ok, for those who are interested:
Tamtamtamtam... The newsletter
http://www.digitalhalo.de/asorg/newsletter.htm

dzy2566
09-30-2003, 11:50 AM
Nice. Thanks Mc. That's pretty cool. Glad to have been a part of this challenge :D

pom
10-12-2003, 07:41 AM
Just some flowers:count = 0 ;
count2 = 0 ;
function drawPetal ( targ, x, y, pc_col, pi_long, pi_larg, pi_rot ) {
count2 ++ ;
var cl = targ.createEmptyMovieClip ( "petal"+count2, count2 ) ;
cl.beginFill ( pc_col, pi_long / 3 ) ;
cl.curveTo ( pi_long / 3, pi_larg, pi_long, 0 ) ;
cl.curveTo ( pi_long / 3, -pi_larg, 0, 0 ) ;
cl.endFill () ;
cl._x = x ;
cl._y = y ;
cl._rotation = pi_rot ;
}
function drawFlower ( x, y, pi_petal, pc_col ) {
num = random(5) + 2 ;
for ( var n = 0; n < num ; n++ ) {
count ++ ;
var size = random (50) + 20 ;
var clip = this.createEmptyMovieClip ( "flower" + count, count ) ;
for ( var j = 0; j < pi_petal; j++ ) {
drawPetal ( clip, x, y, pc_col, size + 10*n, size, 360 * (j / pi_petal + n / num) ) ;
}
}
}
this.onEnterFrame = function () {
if (n <= 16) {
drawFlower ( (n * 150) % 600, Math.floor ( n * 150 / 600 ) * 150, 5, Math.random() * 0xffffff ) ;
n ++ ;
}
}24 'real' lines :)

McGiver
10-12-2003, 12:15 PM
cool one pom, but why do you draw 17 flowers ;) ?

pom
10-13-2003, 11:58 AM
Why not? :D It makes a nice bouquet...

stealthelephant
02-02-2004, 03:38 AM
Originally posted by dzy2566
Slight variation:
//make the background color #FFFF99
Mouse.hide();
numNewPetals=0;
_root.createEmptyMovieClip("flowerHolder",1);
flowerHolder.createEmptyMovieClip("petal",2);
_root.onMouseMove = function(){
xPerc = (_root._xmouse/550)*25+50;
yPerc = (_root._ymouse/400)*75+65;
width = xPerc*.5;
rotat = width;
numPetals = Math.floor(360/width);
flowerHolder.petal.clear();
flowerHolder.petal.lineStyle(1,0x000000,100);
flowerHolder.petal.beginFill(0xff9999,40);
flowerHolder.petal.curveTo(xPerc,(yPerc/2),0,yPerc);
flowerHolder.petal.curveTo(-xPerc,(yPerc/2),0,0);
flowerHolder.petal.endFill();
for(i=0;i<numNewPetals;i++){flowerHolder["petal"+i].removeMovieClip();}
numNewPetals=0;
for(i=0;i<numPetals;i++){
flowerHolder.petal.duplicateMovieClip("petal"+i,i+500);
flowerHolder["petal"+i]._rotation = rotat;
rotat += width;
numNewPetals++;
}
_root.flowerHolder._x = _xmouse;
_root.flowerHolder._y = _ymouse;
_root.clear();
_root.moveTo(275,375);
_root.lineStyle(4,0x006600,100);
_root.curveTo(275,150,_xmouse,_ymouse);
updateAfterEvent();
}

WOW!!

stealthelephant
02-02-2004, 03:52 AM
Originally posted by McGiver
two variations:

more color:
[...
...
...
...
...
_root["flower"+i]["leaf"+j]._rotation = j*(360/_root["flower"+i].leafs);}}
function doflowerblast(grow, i) {
_root["flower"+i]._xscale = _root["flower"+i]._yscale=grow;}
_root.flowerarr = [];
_root.onEnterFrame = function() {
for (n=i-5; n<=i; n++) {
_root["flower"+n].grow += 20000000000000;
doflowerblast(Math.sqrt(Math.sqrt(Math.sqrt(_root["flower"+n].grow))),n);}};
_root.onMouseMove = function() {
i++;
createflowerblast(i);};[/AS]
shucks guys, i'm impressed!
took my a while to realise that vb had turned some of the syntax into smileys!

some of the syntax looks a little strange here, is that cos its in flash 5?

vulcanpimp
07-18-2004, 01:56 PM
the challenge started around last year ... september time... and flash mx had just so to speak come out... so these are all written in either flash 5 or flash 6

McGiver
07-18-2004, 03:45 PM
some of the syntax looks a little strange here, is that cos its in flash 5?
no, that's because I had little knowledge by that time.
I didn't read any books about flash I learned most by experimenting, so the code was just put together in the next best way that worked :p

liquidj
07-20-2004, 12:05 AM
a little delay into it...

//make the background color #FFFF99
numNewPetals = 0;
xt = _xmouse;
yt = _ymouse
_root.createEmptyMovieClip("flowerHolder", 1);
flowerHolder.createEmptyMovieClip("petal", 2);
_root.onEnterFrame = function() {
xt += (_xmouse - xt)/9;
yt += (_ymouse - yt)/9;
xPerc = (xt/550)*25+50;
yPerc = (yt/400)*75+65;
width = xPerc*.5;
rotat = width;
numPetals = Math.floor(360/width);
flowerHolder.petal.clear();
flowerHolder.petal.lineStyle(1, 0x000000, 100);
flowerHolder.petal.beginFill(0xff9999, 40);
flowerHolder.petal.curveTo(xPerc, (yPerc/2), 0, yPerc);
flowerHolder.petal.curveTo(-xPerc, (yPerc/2), 0, 0);
flowerHolder.petal.endFill();
for (i=0; i<numNewPetals; i++) {
flowerHolder["petal"+i].removeMovieClip();
}
numNewPetals = 0;
for (i=0; i<numPetals; i++) {
flowerHolder.petal.duplicateMovieClip("petal"+i, i+500);
flowerHolder["petal"+i]._rotation = rotat;
rotat += width;
numNewPetals++;
}
_root.flowerHolder._x = xt;
_root.flowerHolder._y = yt;
_root.clear();
_root.moveTo(275, 375);
_root.lineStyle(4, 0x006600, 100);
_root.curveTo(275, 150, xt, yt);
updateAfterEvent();
};

praufet
07-20-2004, 05:33 PM
mcgiver's code gives me an error that says a script is causing the computer to run slow, wtf?

McGiver
07-20-2004, 07:31 PM
try setting the publish settings to flash 6 instead of flash 7.

praufet
07-21-2004, 03:43 PM
that's awesome

McGiver
07-21-2004, 06:24 PM
thx :)