La classe loaderInfo vous permet de faire un preloader en actionscript 3. Le code est assez simple et je pense que si vous avez suivi mes prĂ©cĂ©dents articles, vous n’aurez pas de mal Ă  le comprendre.

var debutChargement:Number = getTimer( ) ;
var tempsChargement:Number ;

loaderInfo.addEventListener( ProgressEvent.PROGRESS, fctPreload ) ;
loaderInfo.addEventListener( Event.INIT, fctInitLoad ) ;
loaderInfo.addEventListener( Event.COMPLETE, fctLoadComplete ) ;

function fctPreload( pEvt:ProgressEvent ):void {
	pourcentage = Math.round( pEvt.bytesLoaded / pEvt.bytesTotal * 100 ) ;

	preloadTxt.text = String( pourcentage ) ;

	if ( pourcentage == 100 || pEvt.bytesLoaded == pEvt.bytesTotal ) {
		tempsChargement = getTimer( ) - debutChargement ;
		pourcentage = 0 ;
		loaderInfo.removeEventListener( ProgressEvent.PROGRESS, fctPreload ) ;
	}
}

function fctInitLoad( event:Event ):void {
	loaderInfo.removeEventListener( Event.INIT, fctInit ) ;
	loaderInfo.addEventListener( ProgressEvent.PROGRESS, fctPreload ) ;
}

function fctLoadComplete( event:Event ) {
	// Action a faire une fois que le flash est loadé.
}

A voir aussi :

Quelques articles au hasard

Plus de liens