PDA

View Full Version : freeskier89→ 2. Interactive Tree


freeskier89
01-21-2006, 09:51 PM
Here is my second entry. It is 25 lines. Please let me know your thoughts!
Stage.scaleMode = "noScale";
createEmptyMovieClip("container",16);
colors=[0xE7EDEA,0xD5DFDB,0xC2D1CB];
init = function (container,n) {
container.createEmptyMovieClip("tree"+n,n);
};
Tree=function(x,y,depth){
this.dimensions = {l:40,w:10,d:depth};
this.tree=container.createEmptyMovieClip("tree"+depth, depth);
this.stack = [{x:x,y:y,a:0}];
this.Location={x:x,y:y};
for (var i =0 ;i<3;i++) init(this.tree,i+1);
for (var n=0; n<5; n++) {
for (i=0; i<Math.pow(2,n); i++) {
var branch = this.stack.shift();
var newposition = {y:branch.y-this.dimensions.l*Math.sin((branch.a+90)*Math.PI/180),x:branch.x-this.dimensions.l*Math.cos((branch.a+90)*Math.PI/180)};
for(var i2=0;i2<3;i2++){
this.tree["tree"+(i2+1)].lineStyle(this.dimensions.w+(-i2*9+20), colors[i2], 100);
this.tree["tree"+(i2+1)].moveTo(branch.x, branch.y);
this.tree["tree"+(i2+1)].lineTo(newposition.x, newposition.y);
var dup = this.tree["tree"+(i2+1)].duplicateMovieClip("reflection"+(i2+1),i2+4);
dup._y+=17+this.Location.y*(4/3);
dup._yscale=-30;
dup._alpha=20;
}
this.stack.push({x:newposition.x,y:newposition.y,a :branch.a-(_xmouse-this.Location.x)/2.5},{x:newposition.x,y:newposition.y,a:branch.a-(_ymouse-y)/2.5});
}
this.dimensions.w -= 2;
this.dimensions.l -= 6;
}
}
onMouseMove = function () {
new Tree(275,250,0)
}
-freeskier89

TheCanadian
01-21-2006, 10:22 PM
Very cool :thumb:

gvozden
01-21-2006, 11:08 PM
this is most awesome stuff I've ever seen scripted in Flash
no metter lines

you can dance...

can I use it in my VJing?

freeskier89
01-21-2006, 11:19 PM
this is most awesome stuff I've ever seen scripted in Flash
no metter lines

you can dance...

can I use it in my VJing? Thanks! Yes, you may use it for your VJing. Just bumped the fps up to 30 so it looks much more fluid now.

virusescu
01-22-2006, 04:42 AM
Flash Hacks ? (-: ?

freeskier89
01-22-2006, 11:42 AM
Flash Hacks ? (-: ? What?

Jeff Wheeler
01-22-2006, 11:45 AM
Awesome :thumb:

Krilnon
01-22-2006, 12:40 PM
I think virusescu was talking about this book: http://www.oreilly.com/catalog/flashhks/

I think he meant to imply that this is where you had gotten some sort of inspiration from. I've never read the book, but I've heard of it and his capitalization made me think that he was probably not talking about any actual hacking.

Your entry is very impressive, by the way. :beam:

NiñoScript
01-22-2006, 12:41 PM
Cool! i love this one :D

u should connect the shadow to the tree though :)

freeskier89
01-22-2006, 12:56 PM
ah... I understand now. To tell you the truth I had never even heard of the book before, but I have seen similar effects done in flash. Thanks for all of the positive comments you guys! :hugegrin:

Seb Hughes
01-22-2006, 12:56 PM
OMFG that pwns.

squan
01-22-2006, 01:03 PM
:crying: so ... beautiful ...

Sinister Shadow
01-22-2006, 02:59 PM
Ooh la la... :ko:

virusescu
01-23-2006, 02:37 AM
I was just curious where did you got inspired from. The book Flash Hacks (as krilon spotted) contains a very similiar "Hack" - Generating a fractal tree or something. I was not implying that you cheated because I've seen your AS skills and even if I was implying this :P (wich I'm not), I don't remember the code used in the book.

The entry looks very good. I'm gealous

Gelatine Cow
01-23-2006, 07:05 AM
Awe. Some.

and then some more. :stare:

GNXDan
01-23-2006, 12:24 PM
This is too good, i think you should be disqualified :P
No seriously this is my fav of them all, were do i vote !? ... and then i saw the shadow under the tree... faint :stare:

freeskier89
01-23-2006, 06:25 PM
Thank you all for all of the very positive comments! GNXDan, thank you very much, and welcome to Kirupa forums! :hugegrin: Unfortunatly, you'll have to wait until Febuary 1st to vote I believe.

-freeskier89 :)

hybrid101
01-23-2006, 11:06 PM
lol man, that is so cool! love it!

JoshuaJonah
01-24-2006, 03:12 PM
the flash hacks book has a tree, but not this type of tree... it's just a random generated one from a set of rules, this is predetermined with crazy mouse effects

NiñoScript
01-26-2006, 11:01 PM
in the Processing (http://www.processing.org/) examples, there's a tree that looks a lot like this, one. but it only reacts to _ymouse

// Recursive Tree
// Daniel Shiffman <http://www.shiffman.net>

// Renders a simple tree-like structure via recursion
// Branching angle calculated as a function of horizontal mouse location

// Created 2 May 2005

float theta;
void setup() {
size(200,200);
smooth();
}

void draw() {
background(0);
framerate(30);
stroke(255);
// Let's pick an angle 0 to 90 degrees based on the mouse position
float a = (mouseX / (float) width) * 90f;
// Convert it to radians
theta = radians(a);
// Start the tree from the bottom of the screen
translate(width/2,height);
// Draw a line 60 pixels
line(0,0,0,-60);
// Move to the end of that line
translate(0,-60);
// Start the recursive branching!
branch(60);

}

void branch(float h) {
// Each branch will be 2/3rds the size of the previous one
h *= 0.66f;

// All recursive functions must have an exit condition!!!!
// Here, ours is when the length of the branch is 2 pixels or less
if (h > 2) {
pushMatrix(); // Save the current state of transformation (i.e. where are we now)
rotate(theta); // Rotate by theta
line(0,0,0,-h); // Draw the branch
translate(0,-h); // Move to the end of the branch
branch(h); // Ok, now call myself to draw two new branches!!
popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state

// Repeat the same thing, only branch off to the "left" this time!
pushMatrix();
rotate(-theta);
line(0,0,0,-h);
translate(0,-h);
branch(h);
popMatrix();
}
}




:P

freeskier89
01-26-2006, 11:42 PM
in the Processing examples, there's a tree that looks a lot like this, one. Ah pshaw :P. That tree is way more regular (and easier to create). While were at it, here is another interactive fractal tree thats a closer fit. http://www.ultrashock.com/ff.htm?http://www.ultrashock.com/flas/Detailed/167.html

As you can see their motion is different.

I have spent so many hours upon hours upon hours... looking at fractals on the internet. This tree did not copy anyone else's, but without a doubt what I have put into my visual memory, had some sort of subconscious impact on this work. To tell you the truth, the only code I have looked at for in fractals is some of stilldreamer's stuff and Jared Tarbell's lorenz attractor.

By the way, Thanks for the comments everyone! :hugegrin:

Processing looks really sweet :D

NiñoScript
01-27-2006, 09:45 AM
don't worry, i know that you didnt copy.
it's just that when i looked at that example, i just wanted you to see it :P

btw, your looks better and fits into the 25 lines (that example is 26 lines!) :lol:

freeskier89
01-27-2006, 03:06 PM
I know ninoscript :) Thanks for the example, it is way cool and very fast (unlike flash) I just thought I would clear up some things :D Thanks for the support!

boohaha
01-27-2006, 03:22 PM
Fabulous and simple as a good flash should be :pleased:

Are u sure you won't have troubles with timberland co.??? :P :P

SimplyArun
02-06-2006, 02:44 AM
This is simply awesome! :thumb2:

freeskier89
02-06-2006, 02:52 AM
Thank you :D

pedro.paulo
02-07-2006, 11:03 PM
Well. That is great!

I saw some very close effect at Robert Penner:

http://www.robertpenner.com/index2.html

than, at the "experience" the file "Fractal Dancer"...

Both beatifull.

Congratulations! That is a good job!!

freeskier89
02-08-2006, 01:06 AM
Thanks :hugegrin:!

I did mention penner's tree although I posted the link of it at ultrashock above. While were at it, here is another interactive fractal tree thats a closer fit. http://www.ultrashock.com/ff.htm?htt...ailed/167.html

Thanks again for the positive comments :D

aljavar
02-11-2006, 04:50 PM
Hate to say it, but this looked WAY too familiar to me too. Can't believe know one knew of the Ultrashock example if nearly the exacty same thing (just without the Flash 8 filters applied).

Go to Ultrashock.com.
Ultrashock's FLA's > Experimental Actionscript > Fractal Dancer

freeskier89
02-11-2006, 05:33 PM
Hate to say it, but this looked WAY too familiar to me too. Can't believe know one knew of the Ultrashock example if nearly the exacty same thing (just without the Flash 8 filters applied).

Go to Ultrashock.com.
Ultrashock's FLA's > Experimental Actionscript > Fractal Dancer

Read the posts above you and then you will see that the fractal by Robert Penner was mentioned a couple of times :huh:

I coded this all from scratch... Is there anyway I can prove it to you? Oh... and this doesnt use Flash 8 filters. it is simply three movieclips stacked on top of each other with different lineStyles and then they are duplicated and mirrored to give it it's shadow.

Pasquale
02-11-2006, 10:45 PM
Hate to say it, but this looked WAY too familiar to me too. Can't believe know one knew of the Ultrashock example if nearly the exacty same thing (just without the Flash 8 filters applied).

Go to Ultrashock.com.
Ultrashock's FLA's > Experimental Actionscript > Fractal Dancer
read the AS before ya TRY and bag someone! ;)

moncreyweasel
02-17-2006, 09:55 AM
Really great stuff! I was so sad when I noticed i had missed this great contest, and even more so after seeing the amazing entries everyone submitted! I'm going to have to hang around here more often...;)