Posted By

orazal on 12/21/07


Tagged

as2


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

willcodeforfood


customLoadClip


 / Published in: ActionScript
 

A wrapper function for the MovieClipLoader class, it creates a MovieClipLoader object and adds listeners to it.

  1. /**
  2. * A wrapper function for the MovieClipLoader class, it creates a MovieClipLoader object
  3. * and adds listeners to it. It should be customized with a preloader
  4. *
  5. * @param url The absolute or relative URL of the SWF, JPEG, GIF, or PNG file to be loaded.
  6. * @param target The target path of a movie clip into which the movie will be loaded.
  7. * @return The loadListener object that works with the loader object
  8. */
  9. function customLoadClip(url:String, target:MovieClip):Object {
  10. var loader:MovieClipLoader = new MovieClipLoader();
  11. var loadListener:Object = new Object();
  12. loader.addListener(loadListener);
  13. loader.loadClip(url, target);
  14. loadListener.onLoadStart = function(target:MovieClip) {
  15. };
  16. loadListener.onLoadProgress = function(target:MovieClip,
  17. bytesLoaded:Number, bytesTotal:Number):Void {
  18. var percent:Number = Math.floor(bytesLoaded/bytesTotal*100);
  19. };
  20. loadListener.onLoadInit = function(target:MovieClip):Void {
  21. };
  22. loadListener.onLoadError = function(target:MovieClip,
  23. errorCode:String, httpStatus:Number):Void {
  24. trace("LOAD ERROR : " + errorCode + "\>httpStatus : " + httpStatus +"\n");
  25. };
  26. return loadListener;
  27. }

Report this snippet  

You need to login to post a comment.