ciao a tutti.
qualcuno sa come creare un effetto di vernice che cola su flash?
mi servirebbero più getti di vari colori, non mi interessa che i colori si mischino tra loro.
ho trovato questo actionscript che fa degli schizzi di pennello al movimento del mouse, a me serve per una intro che faccia tutto da se, che coli e se ne vada.
questo non fa a caso mio perche si attiva al movimento del mouse ma graficamente mi piace
http://www.manetas.com/pollock/pollock.swf
questo è un pò bruttino e non fa al caso mio. come potrei rifarlo?
grazie
codice:
import flash.display.BitmapData;
import flash.geom.Point;/*list of colors to use*/
var colors:Array = [0xE5E5D9, 0xF5DAAF, 0x252122, 0xFEA610];/*the current color to draw with*/
var colorIndex:Number = 0;/*the bitmap to hold the drawing*/
var bm:BitmapData = new BitmapData(500, 500, false, 0x000000);/*the old position of the mouse pointer*/
var oldPoint:Point = new Point(_xmouse, _ymouse);/*draw every time the mouse moves*/
_root.onMouseMove = function() {
var newPoint:Point = new Point(_xmouse, _ymouse);
var dist:Number = Point.distance(oldPoint, newPoint);/*only draw if the mouse pointer has moved far enough*/
if (dist>.1) {/*draw a larger point if the mouse has not moved very far */
var radius = 18-Math.min(16, dist);/*draw splotch under mouse pointer*/
drawSpot(_xmouse,_ymouse,radius);/*get the velocity of the mouse */
var dx = new Point(_xmouse, oldPoint.y).subtract(oldPoint).x;
var dy = new Point(oldPoint.x, _ymouse).subtract(oldPoint).y;/*move the point away from the mouse pointer based on the velocity of the mouse*/
/*draw splatter*/
for (var i = 0; i<20; i++) {
drawSpot(_xmouse+(dx*4)*Math.random(),_ymouse+(dy*4)*Math.random(),radius*Math.random());
}
_root.attachBitmap(bm,1);
oldPoint = newPoint;
updateAfterEvent();
}
};/*change the color when the mouse is pressed*/
_root.onMouseDown = function() {
colorIndex = ++colorIndex<colors.length ? colorIndex : 0;
};/*Draw a spot by looping through the radius in the x and y and drawing */
/*points that fall within the radius of the circle.*/
function drawSpot(x:Number, y:Number, radius:Number, color:Number) {
for (var i = -radius/2; i<radius/2; i++) {
for (var j = -radius/2; j<radius/2; j++) {/*check if the point is within the circle*/
if (Math.sqrt(i*i+j*j)<radius/2) {
bm.setPixel(x+i,y+j,colors[colorIndex]);
}
}
}
}