Archive for September, 2007
Flash 3D Flight
Friday, September 28th, 2007 by Carsten SchneiderFlash 3D engine demo by Electric Oyster. Nice lake texture, too.
Update: The new engine is actually Papervision. The lake is still a nice touch.
onReleaseOutside: AS3 Button Engine revisited
Saturday, September 22nd, 2007 by LuisA few months ago I wrote a post with a solution to the missing onReleaseOutside event in AS3.
Unfortunately the post has disappeared completely while upgrading some wordpress plugins.
Here there is a resume of the post, a swf demo and the source code of the Button engine that allows you to set sprites as buttons very easily, with some additional events such onReleaseOutside, onRollOutWhileMouseDown, onRollOverWhileMouseDown and the ability to manage in a very natural and intuitive way all the Button Instances in your project.
Download src code.
Simple Usage:
- package
- {
- import com.lessrain.as3lib.utils.stage.TopLevel;
- import flash.display.Sprite;
- import com.lessrain.as3lib.controls.button.Button;
- import com.lessrain.as3lib.controls.button.ButtonEvent;
- import com.lessrain.as3lib.controls.button.ButtonList;
- import com.lessrain.as3lib.controls.button.ButtonListEvent;
- public class Test extends Sprite
- {
- private var _myButton : Button;
- private var _mySprite : Sprite;
- public function Test()
- {
- TopLevel.getInstance().stage = this.stage;
- initialize();
- }
- public function initialize():void
- {
- ButtonList.getInstance().addEventListener(ButtonListEvent.BUTTON_ADDED,buttonAddedToList);
- ButtonList.getInstance().addEventListener(ButtonListEvent.BUTTON_REMOVED,buttonRemovedFromList);
- _mySprite = new Sprite();
- _mySprite.graphics.beginFill(0x660000);
- _mySprite.graphics.drawCircle(250,250,50);
- _mySprite.graphics.endFill();
- addChild(_mySprite);
- _myButton = new Button();
- _myButton.addEventListener(ButtonEvent.RELEASE,release);
- _myButton.addEventListener(ButtonEvent.RELEASE_OUTSIDE,releaseOutside);
- _myButton.addEventListener(ButtonEvent.PRESS,press);
- _myButton.addEventListener(ButtonEvent.ROLL_OVER,rollOver);
- _myButton.addEventListener(ButtonEvent.ROLL_OUT,rollOut);
- _myButton.addEventListener(ButtonEvent.ROLL_OVER_WHILE_DOWN,press);
- _myButton.addEventListener(ButtonEvent.ROLL_OUT_WHILE_DOWN,rollOutWhileDown);
- _myButton.initialize(_mySprite,'myID','myGroup',false,true);
- }
- private function press(event_:ButtonEvent):void
- {
- trace(String(event_.type));
- }
- private function release(event_:ButtonEvent):void
- {
- trace(String(event_.type));
- }
- private function releaseOutside(event_:ButtonEvent):void
- {
- trace(String(event_.type));
- }
- private function rollOutWhileDown(event_:ButtonEvent):void
- {
- trace(String(event_.type));
- }
- private function rollOver(event_:ButtonEvent):void
- {
- trace(String(event_.type));
- }
- private function rollOut(event_:ButtonEvent):void
- {
- trace(String(event_.type));
- }
- private function buttonAddedToList(event_:ButtonListEvent):void
- {
- var myButton:Button = event_.getButton() as Button;
- trace('--------------------------------------------------');
- trace('Button has been added to the ButtonList:');
- trace('Button GroupID: '+Button(event_.getButton()).groupID);
- trace('Button ID: '+Button(event_.getButton()).id);
- trace('--------------------------------------------------');
- }
- private function buttonRemovedFromList(event_:ButtonListEvent):void
- {
- trace('button has been removed:'+event_.currentTarget);
- }
- }
- }
Related Links:
- SimpleMouseEvents (onReleaseOutside, onDragOut,…), Andre Michelle.
- AS3: Where is my onReleaseOutside, code zen.
- Handling onReleaseOutside in AS3 / flex, Eric Cancil.
- Wherefore Art Thou onReleaseOutside?, Automata on ActionScript.
- Custom event for "onReleaseOutside", Kirupa Forum.
- SimpleButton, Flash Obscura



