setTransform, Prototypes, Random - Please help!

Hey everyone,

I am trying to write a compact, processor friendly prototype to randomly change objects on the stage from one colour to another.

I have managed this effect using alpha tweens on all the instances (with AS). This works but is really inefficient and processer intensive.

have a look at one on the examples:

random dots

This what i think i need to design:

A prototype that uses the setTransform parameter to switch the two colour (in a tweened way).

An array in the script that references all instances of the dots (i.e. “dot1”, “dot2” etc).

A random script incorporated that will randomly change the dots’ colour every time a button is pressed.

I have been looking all over the place and while i found some really good stuff (especially from pixelwit), i ahven’t found anything that really lets me do this.

I am a competent scripter but this is out of my league!

So if anyone has any scripts, ideas etc on how do to do this, please let me know.

I have really big plans for this “tool” and i will happily promote anybody that can help me design a really processor friendly script for this effect. I want to create some digital art pieces for the launch of my new community website (moreroom.net) and i will showcase anyone who can help!

So get your thinking caps on and get back to me,

Thanks,

Kd

BTW i am using flash MX

though subject… took me an hour but i came up with this… is it what you’re looking for?

AGHH!

I’m confused!

I had a quick look over the fla you posted, and i think a lot of it is inline with what i’m looking for.

However i only want the colour to change from one specific colour to another specific colour.

I want to push flash’s limits by having say 10,000 dots on the screen and basically having a button that when pressed, lights up some of the dots and forms random patterns (like the example i posted but much more elaborate).

Thank you soo much for your help and time, i will try and play with your script and see what i can come up with.

If you think of anything else, let me know.

thanks again for the effort,

Kd

so you want random dots to change from color a to color b or visa versa, or do you want a group of dots turn from one color to another and the ret of the dots repeat the pattern?

oh i’m sorry,

the swf i posted is a bit confusing. I just tiled a small selection to show the morphing effect. In the real art pieces every single dot will be individual therefore not forming a pattern (like in the example i posted).

So imagine you have 1000 dots forming a grid, the dots will either be black or white and when you press the button, every sinlge dot will be treated individually.

Therefore button clicked>each dot will individually transform either black OR stay white OR transform from black to white.

Do you see what i mean? the Work is all about the structre of patterns that are supposedly random (kind of like a variation of fractal patterns or the way we make out shapes in the clouds).

Any help you could provide would be wicked!

cheers,

Kd

and you want a random amount of dots to swich colors or a specific amount?

random amount is what i’m looking for

would be interesting to see how i could change a specific number as well, but not a main concern.

Cheers;

kd

ok, i think i’ve got it… it works pretty well with 25 by 25 dots, but higher will slow it down. you may want to ask someone really good with AS to check it out for you and optimize it. it doesn’t use setTransform though because that would be a lot slower so i changed the alpha of the dots… check it out…

hey man that’s pretty cool!

i really like the way you used duplicate.movieclip. makes it real easy to apply to different shapes!

The reason i didn’t use duplicate though is because it canes the processor. Also i thought that maybe setTransform would be less processor hungry as i know that any alpha changes very quickly limit the processor speed.

I need to find a way to increase the total number of instances on the stage to begin to realise my vision for this piece.

Also one permutation for this piece is to have lets say 1000 words on the stage with the same changes, but i can’t do this with duplicating the mc.

That being said, your code is really well written - hats off to you!
This thing is in development and will continue to grow until i exceed the limits of flash.

If you come up with any more AS ideas, or just wanna be involved in the project, get in touch via my email address.

I will let you know how its getting on if you are interested.

i gotta find an AS guru to get this thing up to the stage i’m aiming for.

I think that you can do a lot more with this sorta thing using javascript (read something along those lines in bit-101).

Maybe its time i started harassing Keith Peters.

Anyway thanks for all your work, once more-room is launched there will definately be a place in it for you (if you want it).

thanks again

Kd

sorry to dig this thread out of its grave but, i’ve finally figured out how to do this thing without any alpha changes. i used setRGB. the thing is that for some reason this method seems to run a lot slower!?! it looks really optimized to me but what do i know about optimization… maybe someone can help? here’s the as:
[AS]column = 40;
row = 40;
MovieClip.prototype.WtoB = function() {
this.myColor = 0xFFFFFF;
this.onEnterFrame = function() {
this.myColor -= this.myColor>0x000000 ? 0x111111 : 0;
this.myColoredObject = new Color(this);
this.myColoredObject.setRGB(this.myColor);
};
};
MovieClip.prototype.BtoW = function() {
myColor = 0x000000;
this.onEnterFrame = function() {
this.myColor += this.myColor<0xFFFFFF ? 0x111111 : 0;
this.myColoredObject = new Color(this);
this.myColoredObject.setRGB(this.myColor);
};
};
for (c=1; c<column; ++c) {
for (r=1; r<row; ++r) {
++i;
ball = “ball”+i;
_root.attachMovie(“ballID”, ball, i);
_root[ball]._x = c*_root[ball]._width;
_root[ball]._y = r*_root[ball]._height;
_root[ball].myColor = 0x000000;
_root[ball].myColoredObject = new Color(_root[ball]);
_root[ball].myColoredObject.setRGB(_root[ball].myColor);
}
}
_root.onMouseDown = function() {
numFade = Math.ceil(Math.random()100);
for (n=1; n<=numFade; ++n) {
ballIndex = Math.ceil(Math.random()
(column*row));
ball = “ball”+ballIndex;
_root[ball].myColor<0x222222 ? _root[ball].BtoW() : _root[ball].myColor>0xDDDDDD ? _root[ball].WtoB() : null;
}
};[/AS]

what’s slowing down the movie so much. it seem to slow down more each time you click. is it because once the function is assigned to the MC it stays with it? i dunno…

ps, if you’re gonna test it then make a movie with a circle/square with the linkage name ‘ballID’ and put the script in the first frame of the main timeline… thnks in advance

-zylum

hey zylum,

it’s so cool that i got you thinking about this!

i’m gonna work on it in July or August.

But i’ll play with your new code when i get a chance.

happy coding :slight_smile:

kd

1000 dots will never be smooth, I’m afraid…

there is no never!

no way i’m giving up on this.

i’ll do it in javascript if need be (although i don’t know it at all)!

i’ll surprise you pom. hehe

As you please… :sure:

but why was it better with alpha fade(dots fla in one of the previous posts)? i thought that alpha fading would slow the animation much more than setRGB. plus only a maximum of 100 dots fade. also, it only starts getting slow after more cilcks. there must be something with the script…