Skip to content

crosspop/spin.as

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Spin.as

Preview here: http://wonderfl.net/c/dcgM.

Spin.as is a straightforward port of Spin.js. It has completely equivalent features to Spin.js, but for ActionScript 3.

Quickstart

import spin.Spinner;
var spinner:Spinner = new Spinner;
addChild(spinner);
spinner.spin();

Advanced usage

The constructor of spin.Spinner takes optional parameters (although they have their own default values). The signature looks like:

Spinner(
    lineCount:uint = 12,
    length:Number = 7,
    thickness:Number = 5,
    radius:Number = 10,
    roundness:Number = 1,
    color:uint = 0x000000,
    speed:Number = 1,
    trail:Number = 1,
    opacity:Number = 0.25,
    shadow:Boolean = false
)

Or you can simply set these values into the same name of properties e.g.:

var spinner:Spinner = new Spinner;
spinner.color = 0xABCDEF;
spinner.opacity = 0.5;
spinner.shadow = true;

Differences from Spin.js

Although it's the almost same to Spin.js, there are several differences from it because Flash/ActionScript itself differs from HTML/JavaScript.

For example, Spin.as lacks rotate that Spin.js has. You can use rotation property of flash.display.DisplayObject instead. (Indeed spin.Spinner is a subtype of DisplayObject.)

Also note that trail has the value of floating number which is 0.0 to 1.0, though Spin.js takes 0 to 100 for this option. We thought it's more natural.

Open source

Written by JongChan Choi http://0xabcdef.com/ to be used for Crosspop.

It's distributed under MIT license. Feel free to contribute via GitHub pull requests! Checkout the source code from GitHub:

$ git clone git://github.com/crosspop/spin.as.git

Changelog

Version 1.0

Released on October 26, 2012. Initial release.