/src/cocktail/domElement/as3/ImageDOMElement.hx

http://github.com/silexlabs/Cocktail · Haxe · 61 lines · 25 code · 9 blank · 27 comment · 2 complexity · cb7fe1bae4ed1fa1d26bdd123b36c391 MD5 · raw file

  1. /*
  2. This file is part of Silex - see http://projects.silexlabs.org/?/silex
  3. Silex is Š 2010-2011 Silex Labs and is released under the GPL License:
  4. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  5. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  6. To read the license please visit http://www.gnu.org/copyleft/gpl.html
  7. */
  8. package cocktail.domElement.as3;
  9. import cocktail.nativeElement.NativeElement;
  10. import flash.display.Bitmap;
  11. import flash.display.BitmapData;
  12. import flash.display.Loader;
  13. import haxe.Log;
  14. import cocktail.domElement.abstract.AbstractImageDOMElement;
  15. /**
  16. * This is the Image DOMElement implementation for Flash.
  17. *
  18. * @author Yannick DOMINGUEZ
  19. */
  20. class ImageDOMElement extends AbstractImageDOMElement
  21. {
  22. public function new(nativeElement:NativeElement = null)
  23. {
  24. super(nativeElement);
  25. }
  26. //////////////////////////////////////////////////////////////////////////////////////////
  27. // Overriden GETTER/SETTER
  28. //////////////////////////////////////////////////////////////////////////////////////////
  29. /**
  30. * Override to use the flash API to smooth/unsmooth bitmap
  31. * @param value
  32. * @return
  33. */
  34. override public function setSmooth(value:Bool):Bool
  35. {
  36. super.setSmooth(value);
  37. //cast the native element as a loader
  38. // and retrieve its bitmap content
  39. var typedNativeElement:Loader = cast(this._nativeElement);
  40. var bitmap:Bitmap = cast(typedNativeElement.content);
  41. if (bitmap != null)
  42. {
  43. //activate/deactivate picture smoothing
  44. bitmap.smoothing = value;
  45. }
  46. return value;
  47. }
  48. }