Flex 4 ~ set BorderContainer background (backgroundFill) by url

這範例是用AS去改BorderContainer 的背景圖~~~~透過loader讀取url路徑並assign


Action Script
---------------------------------------------------------------------------------------------
var loader:Loader;
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,handleLoadComplete);
loader.load(new URLRequest('img/bg.jpg'));


private function handleLoadComplete( evt:Event ):void{
var bmp:Bitmap = ( evt.target as LoaderInfo ).content as Bitmap;
bg.source = bmp;
}




MXML
---------------------------------------------------------------------------------------------
<s:BorderContainer x="42" y="80" width="502" id="container" borderVisible="false" backgroundImageFillMode="repeat">
<s:backgroundFill>
<s:BitmapFill id="bg" fillMode="repeat" />
</s:backgroundFill>
</s:BorderContainer>



reference
http://css.dzone.com/news/flex-4-graphics-display-bitmap?mz=8019-adobe

沒有留言: