All pastes #163204 Raw Edit

Supernaut

public text v1 · immutable
·published 2006-09-07 08:47 UTC
rendered paste body
//!-- UTF8
import com.johannesaxner.util.XMLLoader;
import com.johannesaxner.util.SWFLoader;
import mx.utils.Delegate;
/**
 * Application class for Jerlov
 * @author Johannes Axner <contact@johannesaxner.com>
 */
class se.jerlov.jerlov.Application
{
	/** 
    * An internal instance of the application for singleton reasons
    */
	public static var instance:Application;
	/** 
    * A reference to the target MovieClip
    */
	private var target_mc:MovieClip;
	/** 
    * Maximum height of application
    */
	private var maxHeight:Number;
	/** 
    * Maximum width of application
    */
	private var maxWidth:Number;
	/**
	 * Background MovieClip
	 */
	private var background_mc:MovieClip;
	/**
	 * Base MovieClip
	 */
	private var base_mc:MovieClip;
	private var jobs_mc:MovieClip;
	private var navigation_mc:MovieClip;
	private var scene_mc:MovieClip;
	var navigationLoader:SWFLoader;
	var sceneLoader:SWFLoader;
	/** 
    * Class constructor
	* @param target	Target MovieClip
    */
	private function Application()
	{
		_quality        = "BEST";
		Stage.scaleMode = "noScale";
		Stage.align     = "LT";
		Stage.addListener( this );
		this.navigation_mc._visible = false;
	}
	function init( target_mc:MovieClip )
	{
		this.target_mc = target_mc;
		this.navigationLoader = new SWFLoader();
		this.sceneLoader = new SWFLoader();
		this.navigationLoader.addEventListener( 'onLoadInit', Delegate.create( this, onNavigationLoadInit ) );
		this.navigationLoader.addEventListener( 'onLoadStart', Delegate.create( this, onNavigationLoadStart ) );

		
		target_mc.navigation_mc = this.navigationLoader.loadClip( target_mc.navigation_mc, "navigation_mc", "navigation.swf" );
		target_mc.scene_mc = this.sceneLoader.loadClip( target_mc.scene_mc, "scene_mc", "archive.swf" );
		
		/*
		this.navigation_mc.onLoad = function()
		{
			this.navigation_mc.stopMove();
		}
		*/
		//this.navigation_mc.init( this.target_mc );
	}
	function onNavigationLoadStart( eventObj:Object )
	{
		trace("loading of navigation started")
		this.navigation_mc._visible = false;
	}
	function onNavigationLoadInit( eventObj:Object )
	{
		trace("loading of navigation done")
		this.navigation_mc._visible = true;
	}
	/**
	 * Loads a movieClip from an external .swf to the stage
	 * 
	 * @usage   
	 * @param   movieClip_mc  Target movieClip object
	 * @param   movieClip_str String with name of target movieClip
	 * @param   swf_str       Name of the .swf file to load
	 * @param   x             Where to place the clip on the x axis
	 * @param   y             Where to place the clip on the y axis
	 * @param   width         The width which to scale the movieClip to
	 * @param   height        The height which to scale the movieClip to
	 * @return  Void
	 */	
	function loadClip( movieClip_mc:MovieClip, movieClip_str:String, swf_str:String, x:Number, y:Number, width:Number, height:Number ):MovieClip
	{
		var loader:MovieClipLoader = new MovieClipLoader();
		var loadListener:Object = new Object();
		loadListener.onLoadStart = function( loadTarget ) {
			// do something fancy later on
		};
		loadListener.onLoadProgress = function( loadTarget, bytesLoaded:Number, bytesTotal:Number ) {
			// do something fancy later on
		};
		loadListener.onLoadError = function( loadTarget, target_mc ) {
			// do something fancy later on
		};
		loadListener.onLoadComplete = function( loadTarget ) {
			// do something fancy later on
		};
		loadListener.onLoadInit = function( loadTarget ) {
			
			if ( x ) {
				loadTarget._x = x;
			}
			if ( y ) {
				loadTarget._y = y;
			}
			if ( width ) {
				loadTarget._width  = width;
			}
			if ( height ) {
				loadTarget._height  = height;
			}
		};
		loader.addListener( loadListener );
		loader.loadClip( swf_str, movieClip_mc );
		return movieClip_mc;
	}
	/**
	 * Returns the next depth for the target clip
	 * 
	 * @usage   
	 * @return  Number
	 */
	
	public function getNextDepth()
	{
		return this.target_mc.getNextHighestDepth();
	}
	/** 
    * Moves the MovieClip on resize
    */
	function onResize()
	{
		/*
		this.target_mc._x = Math.round( (Stage.width/2)-430 );
		this.target_mc._y = Math.round( (Stage.height/2)-265 );
		*/
	}

	/** 
    * Returns an application instance (singleton)
	* @param target	Target MovieClip
    */
	public static function getInstance()
	{
		if ( Application.instance == null ) {
			Application.instance = new Application();
		}
		return Application.instance;
	}
}