Game Development Reference
In-Depth Information
m_btn.filters = filters;
}
}
}
Here is an example from the login screen class on how you can add the button effect
in a single line of code:
public function addOKBtn():void {
// Get the sprite for the OK button
// from the skinner
m_okBtn = Skinner.getOK();
// Position it
m_okBtn.x = 170;
m_okBtn.y = 220;
// Set up the mouse event for click
m_okBtn.addEventListener(MouseEvent.CLICK,
mouseClickHandler);
// Add the button effect
new ButtonEffect(m_okBtn);
}
The Slider class
Although flash.motion package provides a complete set of functionality to move
sprites in numerous ways, it is often helpful to have a simple class to move things
around with a simple interface. If you have a sprite that you need to move from its
current position to a new position, you may use the Slider class to achieve this.
Sample usage of using this may be found in PlayersDisplay . When the scores are
updated for players and the players' ranks change, the sprites representing the player
slide to their new position, rather than simply being redrawn at the new position.
Here is how you can slide the sprite to a new position:
new Slider(aSprite, new Point(newX, newY)).play();
The above line causes aSprite to move from its current position to the new X and Y .
The play method is what causes the sprite to move.
In addition to the slider class that is responsible for moving the sprite, the
accompanying class SliderEvent is dispatched, notifying any listener that the
sprite has finally arrived at the new position.
 
Search WWH ::




Custom Search