/ Published in: ActionScript 3
A method pulled from a Preloader class (vars _lastUpdate and _isComplete, _dotsExploded not included).
_lastUpdate = is the amount last sent to the preloader _isComplete = whether the preloader is finished _dotsExploded = an array of 10 falses (1/clip), as preloader advances each is set to true
This can be adapted for any preloader with 10 movieclips that need to do something every 10% loaded.
Expand |
Embed | Plain Text
/** * Updates the preload amount * @parmam percentLoaded 0-100 amount of load completed */ public function update(percentLoaded:int = 0) : void { if (percentLoaded <= _lastUpdate || _isComplete) return; _lastUpdate = percentLoaded; var currentActiveSeed:int = Math.round(percentLoaded) / 10; for (var i:int = 0; i < currentActiveSeed; i++) { var seed:MovieClip = getChildByName("dot" + String(i + 1)) as MovieClip; if (!_dotsExploded[i]) { _dotsExploded[i] = true; seed.gotoAndPlay(2); } } if (percentLoaded == 100) { _isComplete = true; dispatchEvent( new PreloaderEvent( PreloaderEvent.COMPLETE, true, false)); } //trace("Loaded " + percentLoaded); }
You need to login to post a comment.
