Hey yoww! Ever wanted a background pattern in a complete flash/flex application? Yeah, I know it can be easily done using CSS and setting windowmode = “transparent” while embeding flash object in to html. But upon setting windowmode = “transparent” your flash application doesn’t react to mouse (or) sometimes creates unwanted mess by loosing focus. So, here is one more option. Draw patterned image using “flash.display.Graphics”
- import mx.core.BitmapAsset;
- [Embed(source="assets/skins/pat.gif")]
- [Bindable]
- public var pat:Class;
- private var gd:Graphics;
- private var bg:BitmapAsset = new pat()as BitmapAsset;
- private function init():void{
- gd = this.graphics;
- paintBG();
- }
- /*
- You can call this function on resize event
- So I put it in a separate block
- */
- private function paintBG():void{
- gd.clear();
- gd.beginBitmapFill(bg.bitmapData);
- gd.drawRect(0,0,this.width, this.height);
- gd.endFill();
- }
import mx.core.BitmapAsset;
[Embed(source="assets/skins/pat.gif")]
[Bindable]
public var pat:Class;
private var gd:Graphics;
private var bg:BitmapAsset = new pat()as BitmapAsset;
private function init():void{
gd = this.graphics;
paintBG();
}
/*
You can call this function on resize event
So I put it in a separate block
*/
private function paintBG():void{
gd.clear();
gd.beginBitmapFill(bg.bitmapData);
gd.drawRect(0,0,this.width, this.height);
gd.endFill();
}
I have used this technique in Flickr Browser, See it in action here
http://blog.insanepixel.com/2008/02/06/background-pattern-flex/
'ria > flex' 카테고리의 다른 글
| Flex Resources (0) | 2008/03/04 |
|---|---|
| [Flex] CSS를 Embed 하는 방법과 런타임시 적용하는 방법 예제 (0) | 2008/02/27 |
| Background pattern - Flex (0) | 2008/02/27 |
| Flex Skin 사이트 (0) | 2008/02/21 |
| Mapping client-side objects to Java objects (0) | 2008/02/20 |
| Changing the close button skin on a Flex TitleWindow container (0) | 2008/02/15 |




댓글을 달아 주세요