STORY   LOOP   FURRY   PORN   GAMES
• C •   SERVICES [?] [R] RND   POPULAR
Archived flashes:
228125
/disc/ · /res/     /show/ · /fap/ · /gg/ · /swf/P0001 · P2561 · P5121

<div style="position:absolute;top:-99px;left:-99px;"><img src="http://swfchan.com:57475/38767088?noj=FRM38767088-13DC" width="1" height="1"></div>

Swarming Tutorial.swf

This is the info page for
Flash #37350

(Click the ID number above for more basic data on this flash file.)


Text
Swarming Tutorial

Welcome to the "Swarming Tutorial" this tutorial will teach you
how to create a cursor type action thats fun to play with.
Seing as most people would skip straight to the script without
learning anything, i've created a test before you can get th
the full script. That doesn't mean you can't get the script
from the tutorial part, just in the tutorial you are only given
parts of the script at a time.
Enjoy!

tutorial

Test

The first thing i'm going to explain
for this script is that you need to make
an MC, make it about as small as you
can, and name it "Bug." This will not
appear on the stage, it's solid script using
that MC.

Now what you're going to do is add
fly = function(){ to the first line of
the script in a blank keyframe. This sets
up the script so it will make the "fly"
preform the fuctions of "Swarming."

Next add this in (I'll explain in the
next frame):

this.animate = function() {
// Capture mouse positions and distance from mouse
this.targetX = _root._xmouse;
this.targetY = _root._ymouse;
this.distX = this.targetX-this.meX+this.flockX;
this.distY = this.targetY-this.meY+this.flockY;
//

All that this small action does is makes
the "fly's" follow the mouse while making
sure that two arn't in the same place at
once. But wait, theres more to this script
so lets keep going, press next to continue.

if ((this.targetX == this.oldTargetX) && Math.random()>0.9) {
// add small scale random darting if mouse is still
this.flockX = (Math.random()*100)-50;
this.flockY = (Math.random()*100)-50;
} else if ((this.targetX<>this.oldTargetX) && Math.random()>0.8) {
// add large scale random darting if mouse is moving
this.flockX = (Math.random()*400)-200;
this.flockY = (Math.random()*400)-200;
}

That last part sets up more of the swarming
behavior. It makes the flys direction, speed,
and location random, and at the same time
different than the others. Lets continue.

// Apply inertia equation
this.meX = Math.round(this.meX+(this.distX)/20);
this.meY = Math.round(this.meY+(this.distY)/20);
// perform animation
this._x = this.meX;
this._y = this.meY;

The inertia equation forces the fly to come
within a certain distance of the mouse when
the mouse isn't moving, you can change this
to whatever you want, it's currently set at 20
feel free to play around with that code. Lets
continue.

Next add this in (this code explains
itself, so add it and lets continue.):

// remember the current mouse pos so we can tell if
// it has moved next time around
this.oldTargetX = this.targetX;
};

Next add this in (I'll explain
in the next frame):

this.initialize = function() {
this.targetX = 0;
this.targetY = 0;
this.distX = 0;
this.distY = 0;
this.meX = this._x;
this.meY = this._y;
this.oldTargetX = 0;
this.flockX = (Math.random()*200)-100;
this.flockY = (Math.random()*200)-100;
};

This is a simple function, not much to explain
about it, so just add it in and we'll move
on quickly and get this over with faster.

// set up onEnterFrame script to animate _parent...
this.initialize();
this.onEnterFrame = this.animate;
};
//
//
var i:Number = 0;
var bugClip:MovieClip;
for (i=0; i<30; i++) {
bugClip = this.attachMovie("bug", "bug"+i, i);
fly.apply(bugClip);
}

The last of this script sets up so
the actions we already put in work
when the movie starts, easy enough to
know how this works. Lets move on and
I'll give you some tips on making this
script effective.

Tips on setting up this awesome display of
swarming bugs:
1) Make the drawing of the big extremely small
2) make a dark background (like the one in
this tutorial)
3) make sure that you enter the whole script
in a blank keyframe.

Once the whole script is done
it should look something like it does
in the next frame, thankyou for watching
this tutorial, I hope you learned something
=D
PARAGON_pvp

What is the MC called?

A)
C)

B)
D)

Bug

Fly

Bug_MC

Mosquito

1)

The start of the code starts out like...

bug = function(){

onFlyEvent(){

fly = function(){

on("Fly"){

2)

This is in the last few lines of the script...

removeMovieClip

attachMovieClip

endActions

functionEnd

3)

copy and paste this script
to activate the "Swarming fuction"

fly = function () {
this.animate = function() {
// Capture mouse positions and distance from mouse
this.targetX = _root._xmouse;
this.targetY = _root._ymouse;
this.distX = this.targetX-this.meX+this.flockX;
this.distY = this.targetY-this.meY+this.flockY;
//
if ((this.targetX == this.oldTargetX) && Math.random()>0.9) {
// add small scale random darting if mouse is still
this.flockX = (Math.random()*100)-50;
this.flockY = (Math.random()*100)-50;
} else if ((this.targetX<>this.oldTargetX) && Math.random()>0.8) {
// add large scale random darting if mouse is moving
this.flockX = (Math.random()*400)-200;
this.flockY = (Math.random()*400)-200;
}
// Apply inertia equation
this.meX = Math.round(this.meX+(this.distX)/20);
this.meY = Math.round(this.meY+(this.distY)/20);
// perform animation
this._x = this.meX;
this._y = this.meY;
// remember the current mouse pos so we can tell if
// it has moved next time around
this.oldTargetX = this.targetX;
};
this.initialize = function() {
this.targetX = 0;
this.targetY = 0;
this.distX = 0;
this.distY = 0;
this.meX = this._x;
this.meY = this._y;
this.oldTargetX = 0;
this.flockX = (Math.random()*200)-100;
this.flockY = (Math.random()*200)-100;
};
// set up onEnterFrame script to animate _parent...
this.initialize();
this.onEnterFrame = this.animate;
};
//
//
var i:Number = 0;
var bugClip:MovieClip;
for (i=0; i<30; i++) {
bugClip = this.attachMovie("bug", "bug"+i, i);
fly.apply(bugClip);
}

ActionScript [AS1/AS2]

Frame 1
totalBytes = Math.round(getBytesTotal() / 1024); loadedBytes = Math.round(getBytesLoaded() / 1024); percentDone = Math.round((loadedBytes / totalBytes) * 100); if (_root._framesloaded >= _root._totalframes) { gotoAndPlay ("start"); }
Frame 2
gotoAndPlay (1);
Frame 56
stop();
Frame 57
stop();
Frame 58
stop();
Frame 59
stop();
Frame 60
stop();
Frame 61
stop();
Frame 62
stop();
Frame 63
stop();
Frame 64
stop();
Frame 65
stop();
Frame 66
stop();
Frame 67
stop();
Frame 68
stop();
Frame 69
stop();
Frame 70
stop();
Frame 71
stop();
Frame 72
stop(); fly = function () { this.animate = function () { this.targetX = _root._xmouse; this.targetY = _root._ymouse; this.distX = (this.targetX - this.meX) + this.flockX; this.distY = (this.targetY - this.meY) + this.flockY; if ((this.targetX == this.oldTargetX) && (Math.random() > 0.9)) { this.flockX = (Math.random() * 100) - 50; this.flockY = (Math.random() * 100) - 50; } else if ((this.targetX != this.oldTargetX) && (Math.random() > 0.8)) { this.flockX = (Math.random() * 400) - 200; this.flockY = (Math.random() * 400) - 200; } this.meX = Math.round(this.meX + (this.distX / 20)); this.meY = Math.round(this.meY + (this.distY / 20)); this._x = this.meX; this._y = this.meY; this.oldTargetX = this.targetX; }; this.initialize = function () { this.targetX = 0; this.targetY = 0; this.distX = 0; this.distY = 0; this.meX = this._x; this.meY = this._y; this.oldTargetX = 0; this.flockX = (Math.random() * 200) - 100; this.flockY = (Math.random() * 200) - 100; }; this.initialize(); this.onEnterFrame = this.animate; }; var i = 0; var bugClip; i = 0; while (i < 30) { bugClip = this.attachMovie("bug", "bug" + i, i); fly.apply(bugClip); i++; }
Frame 73
stop();
Frame 74
stop();
Frame 75
stop();
Frame 76
stop();
Symbol 11 MovieClip Frame 40
stop();
Symbol 12 MovieClip Frame 65
stop();
Symbol 14 Button
on (press) { stopAllSounds(); }
Symbol 18 Button
on (release) { gotoAndStop (57); }
Symbol 20 Button
on (press) { gotoAndPlay (73); }
Symbol 23 Button
on (press, release) { getURL ("http://www.galactigames.com/ref.php?id=82", "_blank"); }
Symbol 32 Button
on (press) { nextFrame(); }
Symbol 33 Button
on (press) { prevFrame(); }
Symbol 51 Button
on (press) { gotoAndStop (56); removeMovieClip("fly"); }
Symbol 60 Button
on (press) { gotoAndPlay (1); }
Symbol 61 Button
on (press) { nextFrame(); }
Symbol 77 Button
on (press) { gotoAndStop (56); }

Library Items

Symbol 1 GraphicUsed by:2
Symbol 2 MovieClipUses:1Used by:3
Symbol 3 MovieClip [bug]Uses:2
Symbol 4 GraphicUsed by:9
Symbol 5 FontUsed by:6 10 17 19
Symbol 6 TextUses:5Used by:9 12  Timeline
Symbol 7 GraphicUsed by:9
Symbol 8 GraphicUsed by:9
Symbol 9 MovieClipUses:4 6 7 8Used by:Timeline
Symbol 10 TextUses:5Used by:11
Symbol 11 MovieClipUses:10Used by:Timeline
Symbol 12 MovieClipUses:6Used by:Timeline
Symbol 13 GraphicUsed by:14
Symbol 14 ButtonUses:13Used by:Timeline
Symbol 15 SoundUsed by:Timeline
Symbol 16 GraphicUsed by:18 20
Symbol 17 TextUses:5Used by:18
Symbol 18 ButtonUses:16 17Used by:Timeline
Symbol 19 TextUses:5Used by:20
Symbol 20 ButtonUses:16 19Used by:Timeline
Symbol 21 GraphicUsed by:Timeline
Symbol 22 GraphicUsed by:23
Symbol 23 ButtonUses:22Used by:Timeline
Symbol 24 FontUsed by:25 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 52 53 54 55 56 57 58 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
Symbol 25 TextUses:24Used by:Timeline
Symbol 26 GraphicUsed by:27
Symbol 27 MovieClipUses:26Used by:Timeline
Symbol 28 GraphicUsed by:29 32 33 51 77
Symbol 29 MovieClipUses:28Used by:32 33 51 77
Symbol 30 GraphicUsed by:31 32 33 51 77
Symbol 31 MovieClipUses:30Used by:32 33 51 77
Symbol 32 ButtonUses:29 31 28 30Used by:Timeline
Symbol 33 ButtonUses:29 31 28 30Used by:Timeline
Symbol 34 TextUses:24Used by:Timeline
Symbol 35 TextUses:24Used by:Timeline
Symbol 36 EditableTextUses:24Used by:Timeline
Symbol 37 TextUses:24Used by:Timeline
Symbol 38 EditableTextUses:24Used by:Timeline
Symbol 39 TextUses:24Used by:Timeline
Symbol 40 EditableTextUses:24Used by:Timeline
Symbol 41 TextUses:24Used by:Timeline
Symbol 42 TextUses:24Used by:Timeline
Symbol 43 EditableTextUses:24Used by:Timeline
Symbol 44 TextUses:24Used by:Timeline
Symbol 45 EditableTextUses:24Used by:Timeline
Symbol 46 TextUses:24Used by:Timeline
Symbol 47 EditableTextUses:24Used by:Timeline
Symbol 48 TextUses:24Used by:Timeline
Symbol 49 TextUses:24Used by:Timeline
Symbol 50 TextUses:24Used by:Timeline
Symbol 51 ButtonUses:29 31 28 30Used by:Timeline
Symbol 52 TextUses:24Used by:Timeline
Symbol 53 TextUses:24Used by:Timeline
Symbol 54 TextUses:24Used by:Timeline
Symbol 55 TextUses:24Used by:Timeline
Symbol 56 TextUses:24Used by:Timeline
Symbol 57 TextUses:24Used by:Timeline
Symbol 58 TextUses:24Used by:Timeline
Symbol 59 GraphicUsed by:60 61
Symbol 60 ButtonUses:59Used by:Timeline
Symbol 61 ButtonUses:59Used by:Timeline
Symbol 62 TextUses:24Used by:Timeline
Symbol 63 TextUses:24Used by:Timeline
Symbol 64 TextUses:24Used by:Timeline
Symbol 65 TextUses:24Used by:Timeline
Symbol 66 TextUses:24Used by:Timeline
Symbol 67 TextUses:24Used by:Timeline
Symbol 68 TextUses:24Used by:Timeline
Symbol 69 TextUses:24Used by:Timeline
Symbol 70 TextUses:24Used by:Timeline
Symbol 71 TextUses:24Used by:Timeline
Symbol 72 TextUses:24Used by:Timeline
Symbol 73 TextUses:24Used by:Timeline
Symbol 74 TextUses:24Used by:Timeline
Symbol 75 TextUses:24Used by:Timeline
Symbol 76 EditableTextUses:24Used by:Timeline
Symbol 77 ButtonUses:29 31 28 30Used by:Timeline

Special Tags

FileAttributes (69)Timeline Frame 1Access local files only, Metadata not present, AS1/AS2.
ExportAssets (56)Timeline Frame 1Symbol 3 as "bug"

Labels

"start"Frame 3




http://swfchan.com/8/37350/info.shtml
Created: 14/5 -2019 09:19:39 Last modified: 14/5 -2019 09:19:39 Server time: 13/05 -2024 04:46:03