Be a Supporter!

Browse Sections


Newgrounds Wiki: getPercentLoaded

Page Contents

Usage

import com.newgrounds.API;
var percent_loaded:Number = API.getPercentLoaded();
This method is used to determine how much of your movie (including assets loaded from the API Gateway) has been loaded.

This method will return a number between 0 and 100.

Examples

The following examples demonstrate how you might use this command in a custom preloader loop.

Actionscript 3.0

import flash.events.Event;
import com.newgrounds.API;

function preloaderLoop(e:Event):void { var percent_loaded:Number = API.getPercentLoaded(); if (percent_loaded == 100) { play(); } }

addEventListener(Event.ENTER_FRAME, preloaderLoop);

Actionscript 2.0

import com.newgrounds.API;

onEnterFrame = function() { var percent_loaded:Number = API.getPercentLoaded(); if (percent_loaded == 100) { play(); } }