// Import packages.
import mx.core.UIComponent;
import com.wisdomtools.scenarios.objects.SceneContentSWF;
// Declare the class and extend from the parent class.
class com.wisdomtools.scenarios.ui.Pagination extends UIComponent {
// Identify the symbol name that this class is bound to.
static var symbolName:String = "Pagination";
// Identify the fully qualified package name of the symbol owner.
static var symbolOwner:Object = Object(Pagination);
// Provide the className variable.
var className:String = "Pagination";
// The movie clips that are the component's graphical representation
private var pagination:MovieClip;
private var boundingBox_mc:MovieClip;
// The tab's paramaters
private var _showPrevious:Boolean = true;;
private var _showNext:Boolean = true;
private var _sceneComplete:Boolean = false;
// Define constructor.
function Pagination() {}
// Call the parent's init method.
// Hide the bounding box--it's used only during authoring.
function init():Void {
super.init();
boundingBox_mc._visible = false;
boundingBox_mc._width = 0;
boundingBox_mc._height = 0;
}
function createChildren():Void {
// Call createClassObject to create subobjects.
pagination = createObject("paginationFinal", "pagination", 10);
size();
invalidate();
//setup button rollover functionality
pagination.button_next.onRollOver = function() {
this.gotoAndStop('over');
};
pagination.button_next.onRollOut = function() {
this.gotoAndStop('up');
};
pagination.button_next.onPress = function() {
this._parent._parent.nextPageEvent();
};
//
pagination.button_previous.onRollOver = function() {
this.gotoAndStop('over');
};
pagination.button_previous.onRollOut = function() {
this.gotoAndStop('up');
};
pagination.button_previous.onPress = function() {
this._parent._parent.previousPageEvent();
};
}
function size() {
// Write code to handle sizing.
super.size();
invalidate();
}
function draw() {
// Write code to handle visual representation.
super.draw();
trace("Current Status {prev:"+_showPrevious+", next:"+_showNext+", complete:"+_sceneComplete+"}");
if(_showPrevious){
pagination.button_previous.enabled = true;
pagination.button_previous._alpha = 100;
} else {
pagination.button_previous.enabled = false;
pagination.button_previous._alpha = 50;
}
if(_showNext){
pagination.button_next.enabled = true;
pagination.button_next._alpha = 100;
} else {
pagination.button_next.enabled = false;
pagination.button_next._alpha = 50;
}
}
//-----------------------------------------
//PAGINATION CONTROLS
//-----------------------------------------
public function previousPageEvent() {
//go to previous page
_parent.prevFrame();
}
public function nextPageEvent() {
//go to next page
_parent.nextFrame();
}
//DEFINE PARAMETER GETTER SETTERS
[Inspectable(name="Show Previous Button?", defaultValue=true)]
public function get showPrevious():Boolean {
return _showPrevious;
}
public function set showPrevious(newBoolean:Boolean) {
_showPrevious = newBoolean;
invalidate();
}
[Inspectable(name="Show Next Button?", defaultValue=true)]
public function get showNext():Boolean {
return _showNext;
}
public function set showNext(newBoolean:Boolean) {
_showNext = newBoolean;
trace('showNext = '+_showNext);
invalidate();
}
[Inspectable(name="Scene Complete", defaultValue=false)]
public function get sceneComplete():Boolean {
return _sceneComplete;
}
public function set sceneComplete(newBoolean:Boolean) {
_sceneComplete = newBoolean;
// When parent is completable/observable, update state based on __sceneComplete
/*if(__sceneComplete && _parent._parent instanceof SceneContentSWF)
_parent._parent.updateState(__sceneComplete);
*/
}
}