Example of how to use the captureimage () event of MX. Graphics. imagesnapshot In Flex
- <? XML version = "1.0"?>
- <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml"
- Layout = "vertical"
- Verticalalign = "Middle"
- Backgroundcolor = "white">
- <Mx: SCRIPT>
- <! [CDATA [
- Import MX. Events. itemclickevent;
- Import MX. Controls. tabbarclasses. tab;
- Private function tabbar_creationcomplete (): void {
- VaR colorarr: array = ["red", "haloorange", "yellow", "halogreen", "haloblue"];
- VaR color: string;
- VaR tab: tab;
- VaR idx: uint;
- VaR Len: uint = tabbar. dataprovider. length;
- For (idx = 0; idx <Len; idx ++ ){
- VaR I: Int = idx % colorarr. length;
- Color = colorarr [I];
- Tab = tab (tabbar. getchildat (idx ));
- Tab. setstyle ("fillcolors", [color, "White"]);
- Tab. setstyle ("fillalphas", [1.0, 1.0]);
- Tab. setstyle ("backgroundcolor", color );
- }
- }
- Private function tabbar_itemclick (EVT: itemclickevent): void {
- Viewstack. selectedindex = EVT. index;
- }
- ]>
- </MX: SCRIPT>
- <Mx: array id = "arr">
- <Mx: Object Label = "red"/>
- <Mx: Object Label = "orange"/>
- <Mx: Object Label = "yellow"/>
- <Mx: Object Label = "green"/>
- <Mx: Object Label = "blue"/>
- </MX: array>
- <Mx: tabbar id = "tabbar"
- Dataprovider = "{arr }"
- Creationcomplete = "tabbar_creationcomplete ();"
- Itemclick = "tabbar_itemclick (event);"/>
- <Mx: viewstack id = "viewstack"
- Width = "{tabbar. Width }"
- Stylename = "plain">
- <Mx: vbox id = "redvbox" width = "100%" Height = "100">
- <Mx: Label text = "Red vbox"/>
- </MX: vbox>
- <Mx: vbox id = "orangevbox" width = "100%" Height = "100">
- <Mx: Label text = "Orange vbox"/>
- </MX: vbox>
- <Mx: vbox id = "yellowvbox" width = "100%" Height = "100">
- <Mx: Label text = "Yellow vbox"/>
- </MX: vbox>
- <Mx: vbox id = "greenvbox" width = "100%" Height = "100">
- <Mx: Label text = "Green vbox"/>
- </MX: vbox>
- <Mx: vbox id = "bluevbox" width = "100%" Height = "100">
- <Mx: Label text = "Blue vbox"/>
- </MX: vbox>
- </MX: viewstack>
- </MX: Application>
Image Description: The picture is displayed on the right.