All pastes #204899 Raw Edit

Untitled

public text v1 · immutable
#204899 ·published 2006-10-16 10:49 UTC
rendered paste body
var img:Array;
var i:Number;
var loaded:Number = 0;
var index:Number = 0;
var load_msg:String = "Loading Technology Tour... ";

_root.intv = null;

createEmptyMovieClip("images_mc", getNextHighestDepth(), { _x:0 , _y:0 , _width:750 , _height:364 , _visible:false });

function draw_percentage(mc:MovieClip, p:Number)
{
	var w:Number = p * 500;
	
	mc.clear();
	mc.moveTo(0, 0);
	mc.lineStyle(1, 0xCCCCCC, 100);
	mc.beginFill(0xCCCCCC, 100);
	mc.lineTo(0, 14);
	mc.lineTo(500, 14);
	mc.lineTo(500, 0);
	mc.lineTo(0, 0);
	mc.endFill();
	
	if ( w > 0 )
	{
		mc.lineStyle(1, 0x999999, 1);
		mc.moveTo(0, 0);
		mc.beginFill(0x999999, 100);
		mc.lineTo(0, 14);
		mc.lineTo(w, 14);
		mc.lineTo(w, 0);
		mc.lineTo(0, 0);
		mc.endFill();
	}
	
	//getURL("javascript:{status='"+ mc +", percentage, "+ p +"';void(0);}", "_self");
}

function hide_loading()
{
	//getURL("javascript:{alert('hiding progress');void(0);}", "_self");
	loading_txt._visible = false;
	//image_loading_txt._visible = false;
	total_status_mc._visible = false;
	//image_status_mc._visible = false;
	
	var i:Number;
	for (i = 0; i < load_images.count; i++)
		images_mc[i].onPress = getNextImage;
	
	images_mc._visible = true;
}

function load_next()
{
	// progress bar, load the next image
	
	var i:Number = loaded + 1;
	//image_loading_txt.htmlText = "<font face=\"arial\" color=\"#666666\" size=\"11\">Loading image, "+ load_images["f_"+ index] +"</font>";
	mcl.loadClip( "i/header/"+ send.name +"/"+ load_images["f_"+ i] , images_mc.createEmptyMovieClip(String(i), images_mc.getNextHighestDepth(), { _x:0 , _y:0 , _width:750 , _height:364 }) );
}

function getNextImage()
{
	if ( load_images.count <= 1 )
		return;
	
	var i:Number = (index + 1) % load_images.count
	fadeIn( images_mc[i] , index );
	index = i;
}

function fadeIn(mc:MovieClip, old_index:Number)
{
	if ( mc.interval )
		clearInterval(mc.interval);
	
	mc._alpha = 0;
	mc._visible = true;
	
	if ( old_index )
		mc.interval = setInterval(mc, "fade", 30, 1, old_index);
	else
		mc.interval = setInterval(mc, "fade", 30, 1, null);
}

/*
function fadeOut(mc:MovieClip, old_mc:MovieClip)
{
	if ( mc.interval )
		clearInterval(mc.interval);
	
	mc.interval = setInterval(mc, "fade", 15, -1, old_mc);
}
*/

function mc_fade(step:Number, old_index:Number)
{
	if ( step == 1 && this._alpha + 10 >= 100 )
	{
		this._alpha = 100;
		
		clearInterval(this.interval);
		this.interval = null;
		
		if ( old_index != null )
		{
			images_mc[old_index]._alpha = 0;
			images_mc[old_index]._visible = false;
		}
	} else if ( step == 1 )
		this._alpha += 10;
	/*
	} else if ( step < 1 && this._alpha - 10 <= 0 ) {
		this._alpha = 0;
		
		clearInterval(this.interval);
		this.interval = null;
	} else if ( step < 1 )
		this._alpha -= 10;
	*/
}

var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(
	{
		onLoadInit : function(mc:MovieClip)
		{
			loaded += 1;
			
			var p:Number = (loaded + 1) / load_images.count;
			
			draw_percentage(total_status_mc, p);
			
			loading_txt.htmlText = "<font face=\"arial\" color=\"#666666\" size=\"11\">"+ load_msg + Math.round(p * 100) +"%</font>";
			
			if ( loaded >= load_images.count - 1 )
			{
				hide_loading();
				getNextImage();
				//fadeIn( images_mc[0] , null );
			} else
				load_next();
			
			mc._x = 0;
			mc._y = 0;
			mc._alpha = 0;
			mc._visible = false;
			mc.interval = null;
			mc.fade = mc_fade;
			
			/*
			if ( load_images.intv_speed == undefined )
				mc.onPress = getNextImage;
			else if ( mc._name == load_images.count - 1 )
				_root.intv = setInterval(getNextImage, parseInt(load_images.intv_speed) + 250);		// + 250 for fade time
			
			if ( mc._name == "0" )
				fadeIn( mc );
			*/
		}
		/* ,
		onLoadProgress : function(mc:MovieClip, loadedBytes:Number, totalBytes:Number)
		{
			var p:Number = 0;
			
			if ( loadedBytes < totalBytes )
			{
				//getURL("javascript:{status='"+ mc._name +", "+ loadedBytes +", "+ totalBytes +", "+ (loadedBytes / totalBytes) +", "+ loaded +", "+ load_images.count +"';void(0);}", "_self");
				draw_percentage(image_status_mc, loadedBytes / totalBytes);
			}
		}
		*/
	}
);

// show status bars
createEmptyMovieClip("total_status_mc", getNextHighestDepth());
//createEmptyMovieClip("image_status_mc", getNextHighestDepth());
createTextField("loading_txt", getNextHighestDepth(), 125, 0, 0, 0);
//createTextField("image_loading_txt", getNextHighestDepth(), 125, 180, 0, 0);

loading_txt.autoSize = true;
loading_txt.html = true;
loading_txt.htmlText = "<font face=\"arial\" color=\"#666666\" size=\"11\">"+ load_msg +"</font>";

//image_loading_txt.autoSize = true;
//image_loading_txt.text = "Loading...";

total_status_mc._x = 125;
total_status_mc._y = 166;

loading_txt._y = 146;

//image_status_mc._x = 125;
//image_status_mc._y = 200;

draw_percentage(total_status_mc, 0);
//draw_percentage(image_status_mc, 0);

var load_images:LoadVars = new LoadVars();
var send:LoadVars = new LoadVars();

load_images.onLoad = function(success:Boolean)
{
	var i:Number;
	
	if ( !success )
		return;

	if ( err == undefined )
	{
		if ( this.count > 0 )
		{
			//image_loading_txt.htmlText = "<font face=\"arial\" color=\"#666666\" size=\"11\">Loading image, "+ load_images["f_1"] +"</font>";
			mcl.loadClip( "i/header/"+ send.name +"/"+ this["f_0"] , images_mc.createEmptyMovieClip(String(0), images_mc.getNextHighestDepth(), { _x:0 , _y:0 , _width:750 , _height:364}) );
			index = this.count - 1;
		}
	} else
		getURL("javascript:alert(\""+ err +"\");", "_self");
}

send.name = _root.name;
send.sendAndLoad("i/header/get_slideshow.php", load_images, "post");