Dynamic Flash Scrolling Link List XML driven Component on FlashDen

Go get the file at ActiveDen

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

[kml_flashembed fversion=”9.0.0″ movie=” https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/03/LinkListNoWrap.swf” targetclass=”flashmovie” publishmethod=”dynamic” width=”550″ height=”250″]

Get Adobe Flash player

[/kml_flashembed]

Circlecube Flash Items at ActiveDen

21075 24687 45713 45893 22018

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:

[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/03/spin.swf” width=”500″ height=”300″ targetclass=”flashmovie”]Get Adobe Flash player

[/kml_flashembed]

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:

[cc lang=”actionscript” tab_size=”2″ lines=”40″]
drag = .96;
speed = 0;

slider.handle.onPress = function() {
spinning = false;
//drag along the line
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);
}
slider.handle.onRelease = slider.handle.onReleaseOutside = function() {
this.stopDrag();
}
_root.onEnterFrame = function() {
if (spinning) {
//apply the speed to the rotation
knob._rotation += speed;
//recalculate speed
speed = speed*drag;
//if speed gets unnoticeably tiny just set it to 0
if (Math.pow(speed, 2) < .0001) {
speed = 0;
}
}
else {
//set the rotation from the slider position
knob._rotation = slider.line._x + slider.handle._x + slider.handle._width/2;
}

//spit out feedback continuously
feedbackr.text = knob._rotation;
feedbackaccr.text = speed;
}
spinner.onRelease = function() {
//find a random speed
speed = (Math.random()* 50) – 25;
spinning = true;
}
[/cc]

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:
[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/03/interactivespin.swf” width=”500″ height=”300″ targetclass=”flashmovie”]Get Adobe Flash player

[/kml_flashembed]

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:

[cc lang=”actionscript” tab_size=”2″ lines=”40″]
damp = .96; //friction
r = 0; //rotation
accr = 0; //speed of rotation

knob.onPress = function() {
dragging = true;
//find mouse y coordinate in relation to knob origin
a = _root._ymouse – knob._y;
//find mouse x coordinate in relation to knob origin
b = _root._xmouse – knob._x;
//using arctangent find the spot of rotation (in degrees)
oldr = Math.atan2(a,b)*180/Math.PI;
}

knob.onRelease = knob.onReleaseOutside = function() {
dragging = false;
}

knob.onEnterFrame = function() {
if (dragging) {
//find mouse y coordinate in relation to knob origin
a = _root._ymouse-knob._y;
//find mouse x coordinate in relation to knob origin
b = _root._xmouse-knob._x;
//using arctangent find the spot of rotation (in degrees)
r = Math.atan2(a,b)*180/Math.PI;

//use current rotation and previous rotation
//to find acceleration
//averages the acceleration with the
//previous acceleration for smoother spins
accr = ((r – oldr) + accr)/2;
//apply the acceleration to the rotation
knob._rotation += accr;
//remember current rotation as old rotation
oldr = r;
feedbacka.text = a;
feedbackb.text = b;
}
else {
knob._rotation += accr;
//apply friction to acceleration force
//and if acceleration gets tiny, just set it to zero
if (Math.pow(accr, 2) > .0001 ) {
accr *= damp;
}
else{
accr = 0;
}
}
//spit out feedback continuosly
feedbackr.text = knob._rotation;
feedbackaccr.text = accr;
}
[/cc]

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 and interactiveSpin.fla

Local Connection Actionscript – Communicate between seperate Flash files | Tutorial

Overview:

Local Connection
Communication between two separate flash files placed on the same page (or even running simultaneously on one machine) is a nice way to spread a project out. You can send variable, call functions, pretty much do anything in one swf from another. Easiest case use would be a navigation menu set up in one flash file to control the other one containing the content. I’ve made an example here showing how to send text from one to another. I’ve done it both directions here. Send text from the red swf to the blue swf, and from mr. Blue you send to the red flash file. I have named the flash functions in actionscript accordingly (or tried to, now I notice a few places I misspelled receive, ‘i’ before ‘e’, right? oh yea, except after ‘c’)…
Anyways, try out the example here, I made it a little easier by putting a keyListener on ‘Enter’, so you don’t have to actually press the send button. Didn’t realize it before, but this is like a chat app built in flash! So go ahead and chat with yourself to prove that it works!

Execute actionscript in one swf from another! Inter-swf communication.

Example:

Type here to send Red text to Blue flash file
[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/03/localConnectionRed.swf” width=”550″ height=”400″ targetclass=”flashmovie”]Get Adobe Flash player

[/kml_flashembed]

And see it received here, and go ahead and send some back to Red.
[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/03/localConnectionBlue.swf” width=”550″ height=”400″ targetclass=”flashmovie”]Get Adobe Flash player

[/kml_flashembed]

Actionscript:

Red:
[cc lang=”actionscript” tab_size=”2″ lines=”40″]
// Receiving
//create a local connection for reciept of text
var receiving_lc:LocalConnection = new LocalConnection();
//function called from other swf
receiving_lc.recieveBlueText = function(textRecieved:String) {
feedback.text += textRecieved+”\n”;
};
//receive connection of specified name
receiving_lc.connect(“fromBlue”);

//Sending
sendButton.onRelease = function() {
//create local connection for sending text
var sending_lc:LocalConnection = new LocalConnection();
//put text from input into a var
var textToSend = inputText.text;
//send through specified connection, call specified method, send specified parameter
sending_lc.send(“fromRed”, “recieveRedText”, textToSend);
//set the input empty
inputText.text = “”;
}
[/cc]

Blue:
[cc lang=”actionscript” tab_size=”2″ lines=”40″]
// Receiving
var receiving_lc:LocalConnection = new LocalConnection();
receiving_lc.recieveRedText = function(textRecieved:String) {
feedback.text += textRecieved+”\n”;
};
receiving_lc.connect(“fromRed”);

//Sending
sendButton.onRelease = function() {
var sending_lc:LocalConnection = new LocalConnection();
var textToSend = inputText.text;
sending_lc.send(“fromBlue”, “recieveBlueText”, textToSend);
inputText.text = “”;
}
[/cc]

And the code to listen to the ‘enter’ key(this is in both files):
[cc lang=”actionscript” tab_size=”2″ lines=”40″]
//Enter button to send
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.getCode() == “13”) {
sendButton.onRelease();
}
};
Key.addListener(keyListener);
[/cc]

Download Source:

localConnectionRedBlue.zip

StomperNet Scrutinizer Update | Features include Bookmarking, Screenshots & Loader

Scrutinizer is constantly being updated and enhanced and with the launch of Adobe AIR 1.0 is easier than ever to install!

It now supports bookmarking, capturing and saving screenshots and displays progress as pages load.
With even more to come soon!

Go check it out at StomperNet’s public site for free download!
Here’s some images to show off scrutinizer!

Watching the loader while my page loads:
scrutinizer loader

Scrutinizing this circlecube blog:
scrutinizer screenshot

Bookmarking my page for quick access:
scrutinizer bookmark

Detect Flash Player Version | Actionscript based detection method (as2)

looking for this in as3!? look no more Detect Flash Player Version | Actionscript based detection method (as3)

Overview

Recently I had a requirement that I had to detect which version of the flash player was currently installed. This is a normal thing, we do it all the time when embedding flash into html, we detect which version of the player is installed and if the user has an old version they are invited to upgrade…

But what about finding the flash version from within flash? An actionscript based detection method? I hadn’t ever thought about doing that…

It turns out it is very simple. From adobe I found the flash detection kit. Which had a lot of code I didn’t need. I only want to know what version of the player is running, not forward to upgrade sites and redirect… So I made this little testing file to save and share what I learned:

Steps

Internally flash knows it’s version number as $version. So to read it we must evaluate that variable.

eval(“$version”);

This returns a string, 3 letter operating system, a space, and then the version number as four numbers seperated with commas.
I display the $version and to split it out I split the string on the space, and then split the version number with the comma delimiter and display them all.

Example

Here’s what mine is (gif):

version detection actionscript gif

And here’s what yours is (swf):
[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/03/flashversiondetectionactionscriptmethod.swf” width=”160″ height=”160″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

Actionscript (as2)

[cc lang=”actionscript” tab_size=”2″ lines=”40″]
version = eval(“$version”);

//The operating system: WIN, MAC, LNX
var osType;
//The player version.
//The latest as of December ’07: 9,0,115,0
var majorVersion; //9
var majorRevision; //0
var minorVersion; //115
var minorRevision; //0

vers.text = version;

osArray = version.split(‘ ‘);
osType = osArray[0];

versionArray = osArray[1].split(‘,’);
majorVersion = versionArray[0];
majorRevision = versionArray[1];
minorVersion = versionArray[2];
minorRevision = versionArray[3];
[/cc]

Download

Here’s the source fla file: flash version detection actionscript method

Let me know how and if you find this useful

Reason Live @ Caledonia Lounge 5 Feb 2004

REASON ~ Live at the Caledonia Lounge ~ 5 February 2004

If you know me you probably know that I love music, and that I love to play music…

I have been in a few bands before, not for the money (cause there wasn’t any), nor the fame (not much of that either), but for the fun. Looking through my old stuff, I found a recording of what I consider the most fun concert I played. I’ve talked with people about the “rocking” days and had no point of reference, so here it is, the point of reference. I just wanted a place to put this for anyone that’s interested. Because at home, these tracks aren’t doing much- other than collecting dust. So noticing that it is now over four years old, I want to give it away for the musically minded out there. Enjoy!

This is Reason, the band, which is now dis-banded, but we had fun while it lasted.

Reason was: Chris Scredon, Evan Mullins and Rhett Coleman

Here is the set list from the show (note my favorites):

01 Intro
02 On the Riverbed
03 Miss America
04 Cats Have Freedom Too
05 Aquarius
06 Broken Bones
07 Time And Again
08 Shout (Beatles cover)
09 Goodbye To Forever
10 Never Needed
11 Lullabye
12 Nathaniel
13 Holiday

The songs are all copyright to either Reason or Chris.

For more info visit the old reason website I made, this outdated MySpace page, but more likely the latest on bandcamp.

Dynamic Flash Vertical Scrolling Link List with XML download at Flashden

Go get the source files at Activeden

[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2007/08/linklist.swf” width=”550″ height=”500″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

circlecube on activeden

Circlecube Flash Items at ActiveDen

21075 24687 45713 45893 22018

Distance Formula in Actionscript Tutorial | Pythagorean theorem

Overview

To find the distance of any two points on an axis is easy, just subtract them. But what about when you have to find the distance of something not on the axis (a diagonal)? Find the distance between any two points with the Pythagorean theorem. This is an old problem we can look to history and find the Pythagorean theorem and Pythagoras, the Greek we’ve named this after. His theorem states that ‘In any right triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).’
pythagorean img

You may remember it as the formula you memorized in geometry or algebra class ‘a squared plus b squared equals c squared’
a^2 + b^2 = c^2
pythag equ

Okay, but how does that help in flash? You want to find the distance between point a and point b. Well c would be the distance between the two points. We know the formula, solving for c.
c = square root of (a^2 + b^2).
pythag equ 2
c = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
Math.sqrt()
is the square root function, so Math.sqrt(4)=2.
Math.sqrt(x) computes and returns the square root of x.
Math.pow() is the power function, so Math.pow(4, 2)=16 (4 squared). Math.pow(x, y) computes and returns x to the power of y.

You say I remember using this for triangles and stuff, I just want to know the distance between two points, there’s no triangles.
Well, there actually is a triangle we can draw. Go from your first, along an axis (this makes one side), and the other point, along the other axis (this is another side), and you’ll see that the distance you’re looking for is the third side of the triangle (the hypotenuse).

Example

Here’s a quick interactive flash file to show the idea.
[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/02/distance.swf” width=”500″ height=”500″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

Actionscript

[cc lang=”actionscript” tab_size=”2″ lines=”40″]
xmid = Stage.width/2;
ymid = Stage.height/2;
a = _root._ymouse-ymid;
b = _root._xmouse-xmid;
c = Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
feedbacka.text = Math.round(a);
feedbackb.text = Math.round(b);
feedbackc.text = Math.round(c);
[/cc]

Download

As usual, here’s the source flash file (flash 8 compatible) to take a look: distance.fla

CSS and HTML WYSIWYG in Flash | Open Source Example

Overview:

Using what I learned with the Actionscript Javascript Communication Tutorial, and pushing it a little further I’ve set up this example of how flash renders html and css. This is basically a wysiwyg (What you see is what you get) html editor! Natively flash only handles some html and css. Many people have enhanced it’s capabilities with projects and Classes, but I made this to show what is accepted by default as far as html and css is concerned. I know there are specs and many lists about what will work, but to me the best way to know if my code will work is to try and see…
I’ve made this app so if I have a question, I just paste in my html/css and send it to the swf to see it rendered live. This saved me a few headaches, so I thought other might enjoy it as well… So here it is.

Example:

Render your own html and or css in flash. htmlToFlash.html
Here is the flash rendering of some dummy text as html with css applied
htmltoflash thumb

Here’s the html interface where I paste in the html and css.
htmltoflash thumb 2
Each supported css property has a corresponding actionscript property, but the naming convention is a little different for css in actionscript. Each actionscript property name is derived from the corresponding CSS property name; the hyphen is omitted and the subsequent character is capitalized. So for example: ‘font-weight’ becomes ‘fontWeight’.

Download:

Here’s the open source files if you want to get your hands dirty.

Let me know if you improve this or even have any questions about it!

Again, note there are only certain HTMl and CSS supported by flash, follow the links for more info.
HTML supported by Flash and CSS supported by Flash

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.
[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/02/city.swf” width=”550″ height=”350″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

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
[cc lang=”actionscript” tab_size=”2″ lines=”40″]
onClipEvent (enterFrame) {
this._x = _root._xmouse/7 – 50;
}
[/cc]

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

[kml_flashembed publishmethod=”dynamic” fversion=”9.0.0″ movie=”https://circlecube.com/circlecube/wp-content/uploads/sites/10/2008/02/city2.swf” width=”550″ height=”350″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

[cc lang=”actionscript” tab_size=”2″ lines=”40″]
onClipEvent (enterFrame) {
this._x = -_root._xmouse/7 – 50;
}
[/cc]

Download Source Fla File