Posted By

chrisaiv on 09/16/09


Tagged

as2


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

surajnaikin


AS2: Bitmap Smoother


 / Published in: ActionScript
 

This is a test to show that when you smooth Bitmaps, you can rotate them beautifully.

  1. import flash.display.*;
  2.  
  3. function loadBitmapSmoothed(url:String, target:MovieClip) {
  4. // Create a movie clip which will contain our unsmoothed bitmap
  5. var bmc:MovieClip = target.createEmptyMovieClip("bmc",target.getNextHighestDepth());
  6.  
  7. // Create a listener which will notify us when the bitmap loaded successfully
  8. var listener:Object = new Object();
  9. // Track the target
  10. listener.tmc = target;
  11.  
  12. // If the bitmap loaded successfully we redraw the movie into
  13. // a BitmapData object and then attach that BitmapData to the target
  14. // movie clip with the smoothing flag turned on.
  15. listener.onLoadInit = function(mc:MovieClip) {
  16. var mc:MovieClip = mc;
  17. mc._visible = false;
  18. // mc.forceSmoothing
  19. var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
  20. this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(),"auto", true);
  21. bitmap.draw(mc);
  22. };
  23.  
  24. // Do it, load the bitmap now
  25. var loader:MovieClipLoader = new MovieClipLoader();
  26. loader.addListener(listener);
  27. loader.loadClip(url, bmc);
  28. }
  29.  
  30. // Sample code
  31.  
  32. createEmptyMovieClip("mc1", getNextHighestDepth());
  33. mc1.createEmptyMovieClip("mc", mc1.getNextHighestDepth());
  34.  
  35. //mc1.mc.loadMovie("flash.png");
  36. loadBitmapSmoothed("http://digitallibrary.usc.edu/assetserver/controller/rendition/VIT-001470/page-1", mc1.mc);
  37.  
  38. mc1.onEnterFrame = function() {
  39. // Ugly, but we are not using a MovieClipLoader for the unsmoothed case
  40. mc1.mc._x = -150;
  41. mc1.mc._y = -230;
  42. mc1._x = Stage.width / 2;
  43. mc1._y = Stage.height / 2;
  44. mc1._rotation += 0.5;
  45. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: surajnaikin on September 28, 2009

nice one

You need to login to post a comment.