Flash navigation/loadbar
November 14, 2007 1:46 PM   Subscribe

How to preload images dynamically in flash so that the image navigation doubles as the load bar. Like http://big.dk/projects/lim/lim.html

If someone could point me in the right direction would be great, since i am a bit rusty with flash and am not quite sure which way to look.
posted by Raff to Technology (2 answers total)
 
Somthing like this (Actionscript 2.0):


//this script goes in frame one of the Timeline
//this array is a list of movieClips in the library. Each is a
//screen in this site. Make sure these mcs have their Linkage
//set to Export for Actionscript;
var arrScreens:Array = ["screen1","screen2","screen3","screen4","screen5"];

//the navigation-button symbol in the library.
var strNavGraphic:String = "navGraphic";

var numNavHolderX:Number = 10;
var numNavHolderY:Number = 300;
var numDistanceBetweenNavs:Number = 45;

var numId:Number;

init();

function init():Void
{
_root.createEmptyMovieClip("mcScreenHolder",_root.getNextHighestDepth());
_root.createEmptyMovieClip("mcNavHolder,_root.getNextHighestDepth());
mcNavHolder._x = numNavHolderX;
mcNavHolder._y = numNavHolderY;
numId = setInterval(preloader,50);
}

function preloader():Void
{
var numPercent:Number = getPercentLoaded();
var numNavs:Number = getNumberOfNavsNow(numPercent);
displayNavs(numNavs);
if (numPercent == 1) clearInterval(numId);
}

//returns the percent as a fraction (e.g. .05)
function getPercentLoaded():Number
{
return Math.floor(_root.getBytesLoaded/_root.getBytesTotal);
}

function getNumberOfNavsNow(numPercent:Number):Number
{
//one nav item for each screen;
var numTotal:Number = arrScreens.length;
return Math.floor(numTotal * numPercent);
}

function displayNavs(numUpThrough:Number):Void
{
for (var i:Number = 0; i <> {
if (!exists("mcNav"+i)) addNav(i);
}

function exists(strInstanceName:String):Boolean
{
return (mcNavHolder[strInstanceName] != undefined);
}

function addNav(i):Void
{
var mcNav:MoveClip;
mcNav = mcNavHolder.attachMovie("strNavGraphic","mcNav"+i,mcNavHolder.getNextHighestDepth());
mcNav._x = i * numDistanceBetweenNavs;
addClickHandler(mcNav,i);
}

function addClickHandler(mcNav:MovieClip,num:Number):Void
{
mcNav.onRelease = function():Void {mcScreenHolder.attachMovie("screen"+1,1)}
}
posted by grumblebee at 4:30 PM on November 14, 2007


Thanks just what i was looking for!
posted by Raff at 12:51 PM on November 15, 2007


« Older How can I simmer my crazy emotions down in the...   |   Style Wars Poster Newer »
This thread is closed to new comments.