Game Development Reference
In-Depth Information
public class Rules extends Sprite
{
static private const NUMBER_OF_PAGES:int = 2;
public var clipRulesText:Sprite;
public var btnBack:SimpleButton;
private var mCurrentPage:int = 1;
public function Rules()
{
addEventListener( Event.ADDED_TO_STAGE,
onAddedToStage, false, 0, true );
}
private function onAddedToStage( _evt:Event ):void
{
addEventListener( TransformGestureEvent.GESTURE_
SWIPE, onGestureSwipe, false, 0, true );
btnBack.addEventListener( MouseEvent.CLICK,
onBackButtonClick, false, 0, true );
clipRulesText.cacheAsBitmap = true;
}
Note that in setting up the input for this screen, we use the pre-
defined GESTURE_SWIPE event. Also worth noting is that we
attached a normal mouse listener to the back button since that is
how any nongesture input will be treated by Flash in this mode.
We also cache the text box as a bitmap for the best performance
when animating it with TweenNano.
private function onGestureSwipe( _evt:TransformGestureEvent ):
void
{
if ( _evt.offsetX < 0)
{
changePage( 1 );
}
else if ( _evt.offsetX
>
0)
{
changePage( -1 );
}
}
private function onBackButtonClick( _evt:MouseEvent ):void
{
Main.getInstance().gotoAndStop( Main.FRAME_TITLE );
}
Search Nedrilad ::




Custom Search