All pastes #832910 Raw Edit

Pagination

public text v1 · immutable
#832910 ·published 2007-12-26 19:37 UTC
rendered paste body
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;
	private var __showNext:Boolean; 
	private var __sceneComplete:Boolean;
	  
	// 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);   
		*/
	}
}