STORY LOOP FURRY PORN GAMES C SERVICES [?] [R] RND POPULAR | Archived flashes: 229672 |
/disc/ · /res/ — /show/ · /fap/ · /gg/ · /swf/ | P0001 · P2596 · P5191 |
This is the info page for Flash #37350 |
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 1totalBytes = Math.round(getBytesTotal() / 1024); loadedBytes = Math.round(getBytesLoaded() / 1024); percentDone = Math.round((loadedBytes / totalBytes) * 100); if (_root._framesloaded >= _root._totalframes) { gotoAndPlay ("start"); }Frame 2gotoAndPlay (1);Frame 56stop();Frame 57stop();Frame 58stop();Frame 59stop();Frame 60stop();Frame 61stop();Frame 62stop();Frame 63stop();Frame 64stop();Frame 65stop();Frame 66stop();Frame 67stop();Frame 68stop();Frame 69stop();Frame 70stop();Frame 71stop();Frame 72stop(); 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 73stop();Frame 74stop();Frame 75stop();Frame 76stop();Symbol 11 MovieClip Frame 40stop();Symbol 12 MovieClip Frame 65stop();Symbol 14 Buttonon (press) { stopAllSounds(); }Symbol 18 Buttonon (release) { gotoAndStop (57); }Symbol 20 Buttonon (press) { gotoAndPlay (73); }Symbol 23 Buttonon (press, release) { getURL ("http://www.galactigames.com/ref.php?id=82", "_blank"); }Symbol 32 Buttonon (press) { nextFrame(); }Symbol 33 Buttonon (press) { prevFrame(); }Symbol 51 Buttonon (press) { gotoAndStop (56); removeMovieClip("fly"); }Symbol 60 Buttonon (press) { gotoAndPlay (1); }Symbol 61 Buttonon (press) { nextFrame(); }Symbol 77 Buttonon (press) { gotoAndStop (56); }
Library Items
Symbol 1 Graphic | Used by:2 | |
Symbol 2 MovieClip | Uses:1 | Used by:3 |
Symbol 3 MovieClip [bug] | Uses:2 | |
Symbol 4 Graphic | Used by:9 | |
Symbol 5 Font | Used by:6 10 17 19 | |
Symbol 6 Text | Uses:5 | Used by:9 12 Timeline |
Symbol 7 Graphic | Used by:9 | |
Symbol 8 Graphic | Used by:9 | |
Symbol 9 MovieClip | Uses:4 6 7 8 | Used by:Timeline |
Symbol 10 Text | Uses:5 | Used by:11 |
Symbol 11 MovieClip | Uses:10 | Used by:Timeline |
Symbol 12 MovieClip | Uses:6 | Used by:Timeline |
Symbol 13 Graphic | Used by:14 | |
Symbol 14 Button | Uses:13 | Used by:Timeline |
Symbol 15 Sound | Used by:Timeline | |
Symbol 16 Graphic | Used by:18 20 | |
Symbol 17 Text | Uses:5 | Used by:18 |
Symbol 18 Button | Uses:16 17 | Used by:Timeline |
Symbol 19 Text | Uses:5 | Used by:20 |
Symbol 20 Button | Uses:16 19 | Used by:Timeline |
Symbol 21 Graphic | Used by:Timeline | |
Symbol 22 Graphic | Used by:23 | |
Symbol 23 Button | Uses:22 | Used by:Timeline |
Symbol 24 Font | Used 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 Text | Uses:24 | Used by:Timeline |
Symbol 26 Graphic | Used by:27 | |
Symbol 27 MovieClip | Uses:26 | Used by:Timeline |
Symbol 28 Graphic | Used by:29 32 33 51 77 | |
Symbol 29 MovieClip | Uses:28 | Used by:32 33 51 77 |
Symbol 30 Graphic | Used by:31 32 33 51 77 | |
Symbol 31 MovieClip | Uses:30 | Used by:32 33 51 77 |
Symbol 32 Button | Uses:29 31 28 30 | Used by:Timeline |
Symbol 33 Button | Uses:29 31 28 30 | Used by:Timeline |
Symbol 34 Text | Uses:24 | Used by:Timeline |
Symbol 35 Text | Uses:24 | Used by:Timeline |
Symbol 36 EditableText | Uses:24 | Used by:Timeline |
Symbol 37 Text | Uses:24 | Used by:Timeline |
Symbol 38 EditableText | Uses:24 | Used by:Timeline |
Symbol 39 Text | Uses:24 | Used by:Timeline |
Symbol 40 EditableText | Uses:24 | Used by:Timeline |
Symbol 41 Text | Uses:24 | Used by:Timeline |
Symbol 42 Text | Uses:24 | Used by:Timeline |
Symbol 43 EditableText | Uses:24 | Used by:Timeline |
Symbol 44 Text | Uses:24 | Used by:Timeline |
Symbol 45 EditableText | Uses:24 | Used by:Timeline |
Symbol 46 Text | Uses:24 | Used by:Timeline |
Symbol 47 EditableText | Uses:24 | Used by:Timeline |
Symbol 48 Text | Uses:24 | Used by:Timeline |
Symbol 49 Text | Uses:24 | Used by:Timeline |
Symbol 50 Text | Uses:24 | Used by:Timeline |
Symbol 51 Button | Uses:29 31 28 30 | Used by:Timeline |
Symbol 52 Text | Uses:24 | Used by:Timeline |
Symbol 53 Text | Uses:24 | Used by:Timeline |
Symbol 54 Text | Uses:24 | Used by:Timeline |
Symbol 55 Text | Uses:24 | Used by:Timeline |
Symbol 56 Text | Uses:24 | Used by:Timeline |
Symbol 57 Text | Uses:24 | Used by:Timeline |
Symbol 58 Text | Uses:24 | Used by:Timeline |
Symbol 59 Graphic | Used by:60 61 | |
Symbol 60 Button | Uses:59 | Used by:Timeline |
Symbol 61 Button | Uses:59 | Used by:Timeline |
Symbol 62 Text | Uses:24 | Used by:Timeline |
Symbol 63 Text | Uses:24 | Used by:Timeline |
Symbol 64 Text | Uses:24 | Used by:Timeline |
Symbol 65 Text | Uses:24 | Used by:Timeline |
Symbol 66 Text | Uses:24 | Used by:Timeline |
Symbol 67 Text | Uses:24 | Used by:Timeline |
Symbol 68 Text | Uses:24 | Used by:Timeline |
Symbol 69 Text | Uses:24 | Used by:Timeline |
Symbol 70 Text | Uses:24 | Used by:Timeline |
Symbol 71 Text | Uses:24 | Used by:Timeline |
Symbol 72 Text | Uses:24 | Used by:Timeline |
Symbol 73 Text | Uses:24 | Used by:Timeline |
Symbol 74 Text | Uses:24 | Used by:Timeline |
Symbol 75 Text | Uses:24 | Used by:Timeline |
Symbol 76 EditableText | Uses:24 | Used by:Timeline |
Symbol 77 Button | Uses:29 31 28 30 | Used by:Timeline |
Special Tags
FileAttributes (69) | Timeline Frame 1 | Access local files only, Metadata not present, AS1/AS2. |
ExportAssets (56) | Timeline Frame 1 | Symbol 3 as "bug" |
Labels
"start" | Frame 3 |
|