All pastes #391539 Raw Edit

Something

public text v1 · immutable
·published 2007-03-12 06:19 UTC
rendered paste body
var img:Array;
var i:Number;

var index:Number = 0;
var last_index:Number = -1;

_root.intv = null;

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

function getNextImage()
{
	var i:Number = index + 1;
	
	if ( i >= load_images.count )
		i = 0;
	
	if ( index == i )
		return;
	
	if ( index >= 0 )
		fadeOut( images_mc[index] );
	
	fadeIn( images_mc[i] );
	
	last_index = index;
	index = i;
}

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

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

function mc_fade(step:Number)
{
	if ( step == 1 && this._alpha + 5 >= 100 )
	{
		this._alpha = 100;
		
		clearInterval(this.interval);
		this.interval = null;
	} else if ( step == 1 ) {
		this._alpha += 5;
	} else if ( step < 1 && this._alpha - 5 <= 0 ) {
		this._alpha = 0;
		this._visible = false;
		
		clearInterval(this.interval);
		this.interval = null;
	} else if ( step < 1 )
		this._alpha -= 5;
}

var mcl:MovieClipLoader = new MovieClipLoader();
mcl.addListener(
	{
		onLoadInit : function(mc:MovieClip)
		{
			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 );
		}
	}
);

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 )
	{
		for (i = 0; i <= this.count; i++)
			mcl.loadClip( "i/header/"+ send.name +"/"+ this["f_"+ i] , images_mc.createEmptyMovieClip(String(i), images_mc.getNextHighestDepth(), { _x:0 , _y:0 , _width:750 , _height:364}) );
	} else
		getURL("javascript:alert(\""+ err +"\");", "_self");
}

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