Home Contact RSS

StomperNet’s Stomper Universe | Interactive Flash Site Map

StomperNet now has a site map. Only it’s much bigger than just a site map, we’re calling it Stomper Universe! It contains all the pieces parts that make up StomperNet. It links to different sites, video series, tools, and more by giving a 3D interactive space to inspect the thumbnails and click through to the sites! It will help visitors navigate easily to all areas of StomperNet, whether they are new to them or old favorites.

So go check out the StomperNet Universe now!

Stompernet universe thumbnail

Tags: , , , , , , , , ,

Brownian Movement in Actionscript | Random Motion Tutorial

Overview

Having things drift around or move randomly has always interested me. Having an animation that is never going to be the exact same thing is very exciting. The focus turns from key-ing exact animations to programming a feel and letting the animations take car of themselves! One type of seemingly random motion is Brownian motion. This gives the movement a random walk wandering look, it will just drift around with no real direction.

Steps

Step by step this process is very simple. In every random motion you create the random number, and apply it to the property. If you want constant random action (motion) rather than just random placement, you repeat that over and over.

  1. Make a random number (random velocity)
  2. Apply the random number (apply velocity to property)
  3. Repeat (if needed)

To create a random number in actionscript, use Math.random(), which creates a random number between 0 and 1. Usually you’ll want to scale it to a range you want to use. If you want a number between 50 and 100, you’d do Math.random() * 50 + 50. *50 to scale it to 0-50, and + 50 to bring it up to 50 - 100. Also if we want to get a 100 range around 0 (-50 - 50) we would do Math.random() * 100 - 50. In the code below I’ve abstracted this to Math.random() * this.randomRange - this.randomRange/2.

Example

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)
Here I’ve got dots created and placed randomly, with randomly set scale and alpha. On every frame each dot has a random velocity applied to it’s x and y coordinates.
The yellow dot is the simple example (code below) and the rest are included in the complex example below.

Actionscript

Simple Example:

  1. dotOne.onEnterFrame = function() {
  2. //create a random velocity for x and y direction
  3. vx = Math.random() * 4 - 2;
  4. vy = Math.random() * 4 - 2;
  5. //apply velocity to coordinates
  6. this._x += vx;
  7. this._y += vy;
  8. }

Complex example:

  1. var numDots = 25;
  2. var randomRange = 1;
  3.  
  4. for(var i=1; i<=numDots; i++) {
  5. //create a new dot
  6. duplicateMovieClip(_root.dot, "dot"+i, i);
  7. //save it's ref path for use
  8. theDot = _root["dot"+i];
  9. //give it random coordinates
  10. theDot._y = Math.random() * Stage.height;
  11. theDot._x = Math.random() * Stage.width;
  12. //give each dot a distinct random range
  13. theDot.randomRange = i/numDots;
  14. //give each dot a random size and transparency
  15. theDot._xscale =
  16. theDot._yscale =
  17. theDot._alpha =  i*4;
  18.  
  19. //apply this code on the dot every frame
  20. theDot.onEnterFrame = function() {
  21. //create a random velocity for x and y direction within the specifically created random range for each dot
  22. vx = Math.random() * this.randomRange - this.randomRange/2;
  23. vy = Math.random() * this.randomRange - this.randomRange/2;
  24. //apply velocity to coordinates
  25. this._x += vx;
  26. this._y += vy;
  27. }
  28. }

Download

randomMotion.fla

Tags: , , , , , , , ,

Dynamic Flash Scrolling Link List XML driven Component on FlashDen

Go get the file at FlashDen

Dynamic Scrolling Link List XML driven (No Wrap)

An interactive link list. Vertically scrolling list of links or just text. Could be used for a nav menu or a link list, or even just a scrolling list. Scroll speed calculated dynamically from mouse position to give not only scrolling control, but also speed control. Reads an external XML file containing just titles and url paths and creates this interactive click-able link list! On click the link is highlighted and on release loads the url either in a blank window or not (configurable). On rollover the list item grows with animation and is highlighted (all configurable, size speed etc). Once end of list is reached scrolling stops, another version is available with a wrap-around feature: Dynamic Scrolling Link List XML driven Auto wrapping

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Tags: , , , , , , , , , ,

Interactive Spin Actionscript Tutorial

I have been thinking of different interactions that are possible with objects. If you’ve read this blog at all you’ll know that I’ve played with physics and gravity and throwing balls and bouncing balls and all sorts. But I hadn’t wrapped my head around an interactive spinner. I know it’d be easy to make a slider or something that would apply a spin to an object, but this just isn’t interactive enough for me.

Circle with slider to rotate and button for random spin:
(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

This attempt at spinning is ok. I mean, it spins the object and it even glides to a stop if you press the button for a random spin… But it’s just not intuitive and not fun. But if you want this, here’s how I did it.

Actionscript:

  1. drag = .96;
  2. speed = 0;
  3.  
  4. slider.handle.onPress = function() {
  5. spinning = false;
  6. //drag along the line
  7. this.startDrag(true, slider.line._x-slider.handle._width/2, slider.line._y-slider.handle._height/2, slider.line._width-slider.handle._width/2, slider.line._y-slider.handle._height/2);
  8. }
  9. slider.handle.onRelease = slider.handle.onReleaseOutside = function() {
  10. this.stopDrag();
  11. }
  12. _root.onEnterFrame = function() {
  13. if (spinning) {
  14. //apply the speed to the rotation
  15. knob._rotation += speed;
  16. //recalculate speed
  17. speed = speed*drag;
  18. //if speed gets unnoticeably tiny just set it to 0
  19. if (Math.pow(speed, 2) < .0001) {
  20. speed = 0;
  21. }
  22. }
  23. else {
  24. //set the rotation from the slider position
  25. knob._rotation = slider.line._x + slider.handle._x + slider.handle._width/2;
  26. }
  27.  
  28. //spit out feedback continuously
  29. feedbackr.text = knob._rotation;
  30. feedbackaccr.text = speed;
  31. }
  32. spinner.onRelease = function() {
  33. //find a random speed
  34. speed = (Math.random()* 50) - 25;
  35. spinning = true;
  36. }

I want to grab it and spin it though. I want to apply the same principles from physics, like acceleration and friction as forces to the object, so I can grab to spin and release to watch it glide gracefully to a stop. I’ve been thinking about this and how I’d have to use trigonometry and stuff to do it. One day I finally had the time and tried it out. It took me a minute but I figured out that what I needed was arctangent. So (with pointers from jbum, thanks Jim!) I came up with this:

Interactive grab-able circle to spin and twirl:
(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

This one is much more interactive and intuitive. I really think this is because there are no sliders or buttons, no controls, just an object to interact with. It’s much more like real life!

Steps:

In order to make a grab and spin object
1. You have to know where you grab. The user clicks on the shape (knob) and you must figure out what degree or rotation point they have started at. (atan2)
2. As the knob is clicked and the mouse moves (dragging), calculate new rotation by mouse position
3. When mouse is released figure out the current speed of rotation and apply it to the knob with friction, so it can be thrown and spun in that way. (Of course this is optional, if you just want to spin it when the mouse is down you’re done at step 2)

Actionscript:

  1. damp = .96; //friction
  2. r = 0; //rotation
  3. accr = 0; //speed of rotation
  4.  
  5. knob.onPress = function() {
  6. dragging = true;
  7. //find mouse y coordinate in relation to knob origin
  8. a = _root._ymouse - knob._y;
  9. //find mouse x coordinate in relation to knob origin
  10. b = _root._xmouse - knob._x;
  11. //using arctangent find the spot of rotation (in degrees)
  12. oldr = Math.atan2(a,b)*180/Math.PI;
  13. }
  14.  
  15. knob.onRelease = knob.onReleaseOutside = function() {
  16. dragging = false;
  17. }
  18.  
  19. knob.onEnterFrame = function() {
  20. if (dragging) {
  21. //find mouse y coordinate in relation to knob origin
  22. a = _root._ymouse-knob._y;
  23. //find mouse x coordinate in relation to knob origin
  24. b = _root._xmouse-knob._x;
  25. //using arctangent find the spot of rotation (in degrees)
  26. r = Math.atan2(a,b)*180/Math.PI;
  27.  
  28. //use current rotation and previous rotation
  29. //to find acceleration
  30. //averages the acceleration with the
  31. //previous acceleration for smoother spins
  32. accr = ((r - oldr) + accr)/2;
  33. //apply the acceleration to the rotation
  34. knob._rotation += accr;
  35. //remember current rotation as old rotation
  36. oldr = r;
  37. feedbacka.text = a;
  38. feedbackb.text = b;
  39. }
  40. else {
  41. knob._rotation += accr;
  42. //apply friction to acceleration force
  43. //and if acceleration gets tiny, just set it to zero
  44. if (Math.pow(accr, 2) > .0001 ) {
  45. accr *= damp;
  46. }
  47. else{
  48. accr = 0;
  49. }
  50. }
  51. //spit out feedback continuosly
  52. feedbackr.text = knob._rotation;
  53. feedbackaccr.text = accr;
  54. }

I commented the code to explain what is happening, if you need more just post a comment. Let me know if you find this useful and what you end up making with it.

Downloads:

spin fla
interactive spin fla

Tags: , , , , , , , , , , ,

Dynamic Flash Vertical Scrolling Link List with XML download at Flashden

Go get the source files at Flashden

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

circlecube on FlashDen

Tags: , , , , , , , , , ,

City Skyline Test | Depth Study

Gives feel of perspective and depth by reacting to mouse movements. The effect is parallax, read more…
The city images are very choppy and ugly, I know, it’s just a test.
(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Sample Actionscript. This in on one of the buildings which are separate movie clips. Adjust the equation for different effect.
The basic formula is as follows: this._x = _root._xmouse / (speed) + transform

  1. onClipEvent (enterFrame) {
  2. this._x = _root._xmouse/7 - 50;
  3. }

Update: Here’s a similr effect achieved by just negating the relation between the mouse and the building movie clips.

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

  1. onClipEvent (enterFrame) {
  2. this._x = -_root._xmouse/7 - 50;
  3. }

Download Source Fla File

Tags: , , , , , , ,

More Circle Cube on Free IQ

Here’s that music video for the Wrens- Faster Gun, on Free IQ

Tags: , , , ,

Circle Cube on Free IQ

Embedded player from Free IQ.
Nicholsong song by Dionysos, Music Video by Circle Cube Studio

Tags: , , , , , , , , , ,
Next entries »