All pastes #153109 Raw Edit

Supernaut

public text v1 · immutable
#153109 ·published 2006-08-29 12:15 UTC
rendered paste body
	/**
	 * 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 with to
	 * @param   heig\ht             
	 * @return  Void
	 */	
	function loadClip( movieClip_mc:MovieClip, movieClip_str:String, swf_str:String, x:Number, y:Number, width:Number, height:Number ):Void
	{
		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 );
		var mc:MovieClip = this.target_mc.createEmptyMovieClip( movieClip_str, this.getDepth() );
		movieClip_mc = mc;
		loader.loadClip( swf_str, movieClip_mc );
	}