Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/StephanPartzsch/as3-buttons
library for the usage of timeline based button in ActionScript 3
https://github.com/StephanPartzsch/as3-buttons
Last synced: about 2 months ago
JSON representation
library for the usage of timeline based button in ActionScript 3
- Host: GitHub
- URL: https://github.com/StephanPartzsch/as3-buttons
- Owner: StephanPartzsch
- License: mit
- Created: 2012-04-27T12:53:39.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-11-16T14:38:18.000Z (about 12 years ago)
- Last Synced: 2024-08-03T05:05:26.212Z (5 months ago)
- Language: ActionScript
- Size: 1.42 MB
- Stars: 4
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
- awesome-actionscript-sorted - as3-buttons - library for the usage of timeline based button in ActionScript 3 (Unsorted / Other API)
README
#AS3 Buttons#
This library provides an easy way to handle timeline based graphics as buttons in ActionScript 3.
Some frame labels are required, but beside this, the button can be very simple with only one graphical state. The library extends this graphical representation with the usual button behavior (buttonMode, enable/disable) and an optional heavy click protection.But the classical meaning of this library is represented by the `FrameButton`. It controls the graphical states of the button for `MOUSE.ROLL_OVER`, `MOUSE.ROLL_OUT`, `MOUSE.MOUSE_DOWN` and `MOUSE.MOUSE_UP` events as well as for a disabled state. If the graphical states for `MOUSE.ROLL_OVER` and `MOUSE.ROLL_OUT` events contain animations the library calculates the appropriate frame of the next label. This is done by taking the position of the playhead in the current label into consideration.
Furthermore the library contains a `ToggleFrameButton` which handles a selection state in addition to the `FrameButton`. This class manages the graphical states for mouse events and the disabled state if the button is selected `true` or `false`.With `LabeledFrameButton` and `LabeledToggleFrameButton` a label text field can be set and managed. The text field has to have the name `labelText`. It is possible to place this text field directly on the timeline or wrap it in an other MovieClip named `textContainer`.
Moreover the label text can be centered vertically, if the text field is bigger than required.The most important classes are:
- FrameButton
- ToggleFrameButton
- LabeledFrameButton
- LabeledToggleFrameButton---
###Usage#######Graphical button representation####
The timeline based button graphics have to contain some required labels. A `FrameButton` representation has to contain "default" as a label on the timeline. And for a `ToggleFrameButton` it has to be "default" as well as "selected_default".
Typical timeline representation of a `FrameButton`:
![Typical timeline representation of a FrameButton](https://github.com/StephanPartzsch/as3-buttons/blob/master/example/asset_example/graphic/typical_frame_button.png?raw=true "Typical timeline representation of a FrameButton")
Simple timeline representation of a `FrameButton`:
![Simple timeline representation of a FrameButton](https://github.com/StephanPartzsch/as3-buttons/blob/master/example/asset_example/graphic/simple_frame_button.png?raw=true "Simple timeline representation of a FrameButton")
Typical timeline representation of a `ToggleFrameButton`:
![Typical timeline representation of a ToggleFrameButton](https://github.com/StephanPartzsch/as3-buttons/blob/master/example/asset_example/graphic/typical_toggle_frame_button.png?raw=true "Typical timeline representation of a ToggleFrameButton")
Simple timeline representation of a `ToggleFrameButton`:
![Simple timeline representation of a ToggleFrameButton](https://github.com/StephanPartzsch/as3-buttons/blob/master/example/asset_example/graphic/simple_toggle_frame_button.png?raw=true "Simple timeline representation of a ToggleFrameButton")
####Basic usage####
*FrameButton*
var frameButton : FrameButton = FrameButton.createFromClass( ExampleButton );
addChild( frameButton );
*ToggleFrameButton*var toggleFrameButton : ToggleFrameButton = ToggleFrameButton.createFromClass( ExampleToggleButton );
addChild( toggleFrameButton );*LabeledFrameButton*
var labeledFrameButton : LabeledFrameButton = LabeledFrameButton.createFromClass( ExampleLabelButton, "Test" );
addChild( labeledFrameButton );
*LabeledToggleFrameButton*var labeledToggleFrameButton : LabeledToggleFrameButton = LabeledToggleFrameButton.createFromClass( ExampleLabelButton, "Test" );
addChild( labeledToggleFrameButton );
The `FrameButton`, `ToggleFrameButton`, `LabeledFrameButton` as well as the `LabeledToggleFrameButton` can be used like normal MovieClips because nearly everything is delegated to the graphical button representation which is managed these button classes.frameButton.x = 100;
frameButton.rotationX = 20;
frameButton.addEventListener( MouseEvent.CLICK, handleFrameButtonClicked );
- - -
###Known issues###*Nested animations*
If the button MovieClip contains a nested animation (another MovieClip) you have to make sure that this animation ends two frames before the label is over.
One empty label is required to reset the nested animation. Otherwise the nested animation will play only once.
A different solution is to leave empty the first frame of the label that contains the nested animation.