View Full Version : Star KaleidoScope Thing - and maybe others
virusescu
01-12-2006, 04:32 PM
Welll mates, me here to enter za contest :pir:
Haveing some fun with this first flash KaleidoScope thingy.
The xmouse positions influences the number of corners of the star.
Hope you like it
Stage.scaleMode = "noScale";
this.createEmptyMovieClip("shape", 10);
import flash.filters.*;
import flash.display.*;
t = 1;
function onEnterFrame() {
img.dispose();
var img = new flash.display.BitmapData(400, 400, true, 16777215);
img.draw(this);
this.attachBitmap(img, 3, 0, true);
this.filters = [new flash.filters.BlurFilter(3, 3, 2)];
p = Math.min(Math.abs(_xmouse-200),200)/200;
drawShape(this.shape, 200, 200, 200, 50, 3+Math.min(Math.floor(p*7),7), t++);
}
function drawShape(mc, cx, cy, rmax, rmin, corners, rotation) {
mc.clear();
mc.lineStyle(3, newRgb(t), 100, 0, 0, 0, 0, 0);
mc.moveTo(cx+rmax*Math.abs(Math.sin(t/20))*Math.cos(Math.sin(t/10)), cy+rmax*Math.sin(Math.sin(t/10))*Math.abs(Math.sin(t/20)));
for (var x = 0;x<=6.283185;x+=6.283185/corners){
mc.lineTo(cx+rmax*Math.abs(Math.sin(t/20))*Math.cos(x+Math.sin(t/10)), cy+rmax*Math.sin(x+Math.sin(t/10))*Math.abs(Math.sin(t/20)));
mc.lineTo(cx+rmin*Math.abs(Math.sin(t/50))*Math.cos(x+6.283185/corners/2), cy+rmin*Math.sin(x+6.283185/corners/2)*Math.abs(Math.sin(t/50)));
}
mc.filters = [new flash.filters.GlowFilter(newRgb(t+300), 100, 5, 5, 100)];
}
function newRgb(t) {
return (Math.floor(256*Math.abs(Math.sin(t/30)) << 16)+Math.floor(256*Math.abs(Math.sin(t/25)) << 8)+Math.floor(256*Math.abs(Math.sin(t/20))));
}
this.createEmptyMovieClip("shape", 10);
t = Math.floor(Math.random()*100000);
virusescu
01-12-2006, 04:36 PM
This fills the memory constantly from what I see. I'm still fooling around with BitmapData class. It seems I don't clear the resources corectly. Long time exposure to this effect is not recommended as this will take over your RAM :).
NiñoScript
01-12-2006, 04:36 PM
that looks really good, reminds me of an old computer running the itunes visualizator :P
Seb Hughes
01-12-2006, 05:02 PM
That is very nice.
virusescu
01-12-2006, 06:31 PM
Thank you guys.
Here comes version 2.
I've ran out of powers for now, I'm too tired to repair that memory issue.
The mouse position influneces the color of the line
If you click on the screen the number of corners changes.
Stage.scaleMode = "noScale";
this.createEmptyMovieClip("shape", 10);
import flash.filters.*;
import flash.display.*;
var img:BitmapData = new flash.display.BitmapData(500, 500,false,0);
this.attachBitmap(img, 3, null,true);
function onEnterFrame() {
img.draw(this);
this.filters = [new flash.filters.BlurFilter(3, 3, 2)];
drawShape(this.shape, 250, 250, 50+Math.abs(120*Math.sin(t/26)), 20+Math.abs(170*Math.sin(t/20)), 3+_root.addcorners, t++);
}
function drawShape(mc, cx, cy, rmax, rmin, corners, rotation) {
mc.clear();
mc.lineStyle(4, newRgb(t), 100, 0, 0, 0, 0, 0);
mc.moveTo(cx+rmax*Math.cos(Math.sin(t/10)), cy+rmax*Math.sin(Math.sin(t/10)));
for (var x = 0; x<=6.283185; x += 6.28318/corners) {
mc.lineTo(cx+rmax*Math.cos(x+Math.sin(t/10)), cy+rmax*Math.sin(x+Math.sin(t/10)));
mc.lineTo(cx+rmin*Math.cos(x+6.283185/corners/2), cy+rmin*Math.sin(x+6.283185/corners/2));
}
mc.filters = [new flash.filters.GlowFilter(0, 100, 3, 3, 100)];
}
function newRgb(t) {
return (255 << 16)+(Math.floor(Math.abs(Math.min(_xmouse, 400))/400*255) << 8)+Math.floor(Math.abs(Math.min(_ymouse, 400))/400*255);
}
this.createEmptyMovieClip("shape", 10);
t = Math.floor(Math.random()*100000);
_root.addcorners = Math.floor(Math.random()*9);
this.onMouseDown = function() {
_root.addcorners = _root.addcorners<10 ? _root.addcorners+1 : 0;
};
Yey. Solved. Reinstantiating the BitmpaData class on each frame leaves the bitpmap in memory. Once a bitmap is attached to a movieClip you can draw anything on it (I just found out :P) without reinstantiating the BitmapData object.. that's cool :mountie:
freeskier89
01-12-2006, 07:19 PM
Hey, I really like it! :D Its amazing what only a little code can do. But, has kirupa come to a desicion about the use of new flash 8 classes (BitmapData,glow...)?
I don't think you're allowed to import, so that people with Flash <=7 are not at the obvious disadvatage.
Sorry, but nice entry.
virusescu
01-12-2006, 07:33 PM
Heh.. I'll live with it if it's decided against. It was fun :). For now it stated that any (Doesn't matter the Flash Version) built in classes can be imported.
Deril
01-12-2006, 07:46 PM
Looks good.. lags on.. (A1600+).
looks very spectacular...
virusescu
01-13-2006, 03:28 AM
An update to keep on the guidelines.
No imports, wich disables me the bitmapData class.
Nothing spectacular here, all got even lagyer, need to think of something else now:book:
Stage.scaleMode = "noScale";
this.createEmptyMovieClip("shape", 10);
function onEnterFrame() {
this.filters = [new flash.filters.BlurFilter(5, 5, 2)];
this.shape.clear();
drawShape(this.shape, 250, 250, 50+Math.abs(120*Math.sin(t/24)), 20+Math.abs(170*Math.sin(t/20)), 3+_root.addcorners, t);
drawShape(this.shape, 250, 250, 60+Math.abs(100*Math.sin(t/8)), 50+Math.abs(100*Math.sin(t/10)), 3+_root.addcorners, t++);
}
function drawShape(mc, cx, cy, rmax, rmin, corners, rotation) {
mc.lineStyle(10, newRgb(t), 100, 0, 0, 0, 0, 0);
mc.moveTo(cx+rmax*Math.cos(Math.sin(t/10)), cy+rmax*Math.sin(Math.sin(t/10)));
for (var x = 0; x<=6.283185; x += 6.28318/corners) {
mc.lineTo(cx+rmax*Math.cos(x+Math.sin(t/10)), cy+rmax*Math.sin(x+Math.sin(t/10)));
mc.lineTo(cx+rmin*Math.cos(x+6.283185/corners/2), cy+rmin*Math.sin(x+6.283185/corners/2));
}
mc.filters = [new flash.filters.GlowFilter(0xFF0000, 100, 10, 10, 2)];
}
function newRgb(t) {
return (255 << 16)+(Math.floor(Math.abs(Math.min(_xmouse, 400))/400*255) << 8)+Math.floor(Math.abs(Math.min(_ymouse, 400))/400*255);
}
this.createEmptyMovieClip("shape", 10);
t = Math.floor(Math.random()*100000);
_root.addcorners = Math.floor(Math.random()*3);
this.onMouseDown = function() {
_root.addcorners = _root.addcorners<3 ? _root.addcorners+1 : 0;
};
That's really cool. Great work :)
But again, I think that using `flash.filters.BlurFilter` counts as importing. Don't go by my word, though.
virusescu
01-13-2006, 07:48 AM
I've found some major flaw in the shape Drawing for loop. Instead of going only up to 6.283185 it was going to 360. So it was making almost 60 times more calculations.
I haven't uploaded the recomiled swfs versions yet. For now I've just edited the code. It should work much better.
hybrid101
01-13-2006, 09:04 AM
it lags too much on my conputer. try to find a way to make it less cpu intensive. nice effect by the way!
virusescu
01-13-2006, 10:20 AM
I know there was a lag. I've just updated the swf versions an uploaded on the forum.
Even if I modified the code a couple of hours ago, the swf's weren't uploaded until now so the swfs were still the buggy version. This is still processor intensive, but I hope not that much to kill your CPU :).
nathan99
01-15-2006, 07:43 AM
yeah im pretty sure that is not valid. no imports/filters as far as i know because of the whole MX, MX2004advantage
edit :: nvm
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.