-
[RESOLVED] Sparkle mouse follow?
Hi, I've been trying to figure out a way to get this effect: http://www.flashkit.com/movies/Effec...5696/index.php into my project for awhile, but all the examples I find are for older versions of flash, or poorly constructed to the point where I ahve no idea how they made it work in the first place. I just need a fading trail that will leave a slightly spreading trail as that file does, though I'd like for it to only activate when the mouse moves. Anyone know how to do this?
-
Anyone? Please? It's so frustrating to be able to see an effect you want but not be able to make it work yourself.
-
Databarnak
in frame 1
Code:
n = 0;
Mouse.hide();
in frame 2
Code:
num = Math.random(1) * 15;
++n;
if (n > 20)
{
n = 0;
} // end if
duplicateMovieClip("sparkling", "sparkling" + n, n);
setProperty("sparkling" + n, _x, _xmouse);
setProperty("sparkling" + n, _y, _ymouse);
setProperty("sparkling" + n, _xscale, num);
setProperty("sparkling" + n, _yscale, num);
in frame 3
make a mc with the particle in it
frame 1
Code:
spark._alpha = 10;
verschily = -10 + Math.random(1) * 20;
verschilx = -10 + Math.random(1) * 20;
frame 2
Code:
spark._alpha = spark._alpha - 3;
++i;
if (i = 30 && Math.random(1) * 10 > 8)
{
verschilly = -4 + Math.random(1) * 8;
verschillx = -4 + Math.random(1) * 8;
i = 0;
} // end if
spark._x = spark._x + verschilx + verschillx;
spark._y = spark._y + verschily + verschilly;
frame 3
Put the mc on root and call it sparkling
in the mc called sparkling (the particle)
blank frame in 1
put a mc with your particle in frame 2 and call it spark
put the the mc spark in frame 3 but make it bigger
hit Ctrl-Enter ........
I ask you all to concentrate really hard on the freedom of all being. Its hard not to be very angry it is impossible We have to focus this confusion frustration helplessness feeling into a creative outlet Anger can spawn such amazing creativity through Street art Free art to teach each other know each other a language our evolution Go ahead and break some dumb rules
-
Thank you, it's almost perfect! But two questions.
1. Can I make it not activate until the mouse moves?
2. I need it to trail a mouse follow that I have, which has easing. If I try to apply that same easing code on the movie clip it acts up.
Here's the FLA... http://zeldacurio.com/newconstellation.fla
-
Senior Member
no offence to atRax, but thats some fugly way of doing it, and its in AS1,
here is my alternative:
make the clip which you want to be a speckle, and export it for actionscript and give it an identifier "sparkle", then just add this code to the frame:
Code:
Mouse.hide();
var d_r:Number = Math.PI/180;
function sparkle():Void {
var clip:MovieClip = _root.attachMovie("sparkle", "s"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:_xmouse, _y:_ymouse});
clip._xscale = clip._yscale=Math.random()*100 | 0;
var s:Number = Math.random()*6 | 0;
var a:Number = Math.random()*360 | 0;
clip.onEnterFrame = function() {
if (this._alpha <= 0) {
delete this.onEnterFrame;
} else {
this._alpha -= 10
this._x += (Math.cos(a*d_r)*s);
this._y += (Math.sin(a*d_r)*s);
}
};
}
onMouseMove = function () {
for (var z = 0; z<10; z++) {
sparkle();
}
};
put the frame rate to about 30, and thats it.
to change the max random speed of the particles change the value in red,
HTH,
zlatan
Last edited by dudeqwerty; 07-22-2006 at 02:05 PM.
Reason: improved efficiency of code
New sig soon
-
Thank you so much!!!
The big question is, is there any way I could get it to ease-follow? I use this code for the mask and movie clip I ahve trailing the mouse, and this will be all finsihed if I can make that trail follow as well... this is the follow code I use:
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
-
Senior Member
same again, but with this script:
Code:
var follower:MovieClip = _root.createEmptyMovieClip("follower", _root.getNextHighestDepth());
var speed:Number = 5;
Mouse.hide();
var d_r:Number = Math.PI/180;
function sparkle():Void {
var clip:MovieClip = follower.attachMovie("sparkle", "s"+follower.getNextHighestDepth(), follower.getNextHighestDepth());
clip._xscale = clip._yscale=Math.random()*100 | 0;
var s:Number = Math.random()*14 | 0;
var a:Number = Math.random()*360 | 0;
clip.onEnterFrame = function() {
if (this._alpha<=0) {
delete this.onEnterFrame;
this.removeMovieClip();
} else {
this._alpha -= 10;
this._x += (Math.cos(a*d_r)*s);
this._y += (Math.sin(a*d_r)*s);
}
};
}
follower.onEnterFrame = function() {
this._x += (_xmouse-this._x)/speed;
this._y += (_ymouse-this._y)/speed;
};
onMouseMove = function () {
for (var z = 0; z<10; z++) {
sparkle();
}
};
HTH,
zlatan
-
I can't put in words how happy you've made me! Just one last thing, if you don't mind. Can I apply gravity to the sparks so they'll fall more downwards?
-
Senior Member
like this:
Code:
var follower:MovieClip = _root.createEmptyMovieClip("follower", _root.getNextHighestDepth());
var speed:Number = 5;
var g:Number = .981;
Mouse.hide();
var d_r:Number = Math.PI/180;
function sparkle():Void {
var s:Number = Math.random()*14 | 0;
var a:Number = Math.random()*360 | 0;
var clip:MovieClip = follower.attachMovie("sparkle", "s"+follower.getNextHighestDepth(), follower.getNextHighestDepth(), {_x:Math.cos(a*d_r)*s, _y:Math.sin(a*d_r)*s});
clip._xscale = clip._yscale=Math.random()*100 | 0;
var vel:Number = 0;
clip.onEnterFrame = function() {
if (this._alpha<=0 || this._y>Stage.width-this._parent._y) {
delete this.onEnterFrame;
this.removeMovieClip();
} else {
this._alpha -= 10;
this._x += (Math.cos(a*d_r)*s);
this._y += vel += g;
}
};
}
follower.onEnterFrame = function() {
this._x += (_xmouse-this._x)/speed;
this._y += (_ymouse-this._y)/speed;
};
onMouseMove = function () {
for (var z = 0; z<10; z++) {
sparkle();
}
};
or like this
-
It's perfect, thank you!!!
-
Databarnak
Originally Posted by dudeqwerty
no offence to atRax, but thats some fugly way of doing it, and its in AS1,
yeah I know.. decompiled the code and publish it after that.. took me 2 min.
nest time Ill take time to make it AS2
regards
mark
I ask you all to concentrate really hard on the freedom of all being. Its hard not to be very angry it is impossible We have to focus this confusion frustration helplessness feeling into a creative outlet Anger can spawn such amazing creativity through Street art Free art to teach each other know each other a language our evolution Go ahead and break some dumb rules
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|