Let me introduce the new version of ScaleBitmap :
I have totally rewritten ScaleBitmap to suit my needs :
The outer drawing & ScaleBitmapSprite allows you to :
Usage 1 : ScaleBitmap
ScaleBitmap.draw( bitmap : BitmapData, // the bitmap source graphic:Graphics, // the destination graphic width:Number, // width (defined by outer rectangle if not null) height:Number, // height (defined by outer rectangle if not null) inner : Rectangle, // inner rectangle for scale 9 outer : Rectangle=null // outer rectangle : visual size reference ):void
If outer is not null, ScaleBitmap use a negative offset for drawing (according to outer properties)
If outer is null, ScaleBitmap works as a classic Scale9 grid drawer
Usage 2 : ScaleBitmapSprite
ScaleBitmapSprite( bitmap : BitmapData, // the bitmap source inner : Rectangle, // inner rectangle for scale 9 outer : Rectangle=null) // outer rectangle : visual size reference var s:ScaleBitmapSprite=new ScaleBitmapSprite(mySkin, new Rectangle(20,20,80,20), new Rectangle(15,15,90,30)); addChild(s); s.width=80; s.height=40;</a>
ScaleBitmapSprite override public size setter & getter : you can move & resize a ScaleBitmapSprite object without taking care of bitmap outer drawing.
Simple MyButton class using ScaleBitmapSprite (click the button) :
Sources FCS4 [ require Eaze to compile]
Download ScaleBitmap & ScaleBitmapSprite :
Repository : http://gist.github.com/264250
Some of you prefer gist, so as possible, I will share my new projects via gist.
Hope this class help & merry Xmas to bytearray readers.
[EDIT 2010-05-18]
A new version 1.1 is available !
Jerôme Decoster, a talented french developer have made a lot of improvements in this new version :
- smooth support
- invalidation for ScaleBitmapSprite
- code optimization
- inner drawing correction
So many thanks to you Jerôme
Repository : http://gist.github.com/264250
Comments (17)
Long waiting for these improvements, many congratulations on this great and usable class
Very nice work!
The original class was great and this one is even better. The new outer rectangle is going to be a time saver. Thanks!
Thanks for the excellent utility class. Stuff like this really helps with every scale of web design project’s productivity. You’re the man.
Génial ! Très beau boulot, bravo !
Thanks guys, don’t hesitate to report any problems or bugs
Really nice update. I on download the source and see myself the improvment around the ‘BitmapData’
Thanks, this is great
Not sure if some of you know this, but you can embed a bitmap with scale9 as long as you set the scale dimesions, and make sure you embed it as MovieClip rather than Bitmap or BitmapData.
Either way this is extremely useful for non-embedded assets
great job! thanks for sharing!!
this is just great! the outer addition is really useful!
Something odd: it seems that with ScaleBitmapSprite, the original bitmap size is not respected by default (at least without outer Rectangle).
Anyway… thanks a lot!
thank you for sharing the source code
Yes nice job, thanks!
Bonsoir, à quand le scale nine grid et scale Bitmap porté à Photoshop ?Une feature pour Photshop cs6 ?
Bonjour, pourquoi se limiter au scale9 ? A quand le scale15 ? Une feature pour Flash CS6 ?
hello all, many thanks for your comments.
@sitron> Do you use the outer capability ? could you send me an example ?
@jerome> Well, just for you : http://www.didierbrun.com/demos/scale_grid.swf (using one PNG file http://www.didierbrun.com/demos/layout.png)
Thanks, I just used it, very nice ! It works perfectly.
Trackbacks/Pingbacks (2)
[...] 在AS3环境下,可以通过著名的ScaleBitmap来实现。 No Comments [...]
[...] bytearray.org のDemoで使われていた EazeTween が面白そう。 ScaleBitmap : New version [...]