Flex Gumbo中如何通过设置repeat属性给Rect对象填充位图的例子

By Minidxer | June 2, 2009

接下来的例子演示了Flex Gumbo中如何通过将BitmapFill对象设置到repeat属性,给Rect对象填充位图。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Application name="BitmapFill_repeat_test"
  3.         xmlns="http://ns.adobe.com/mxml/2009"
  4.         layout="vertical"
  5.         verticalAlign="middle"
  6.         backgroundColor="white">
  7.  
  8.     <ApplicationControlBar dock="true">
  9.         <Form styleName="plain">
  10.             <FormItem label="repeat:">
  11.                 <CheckBox id="checkBox" selected="true" />
  12.             </FormItem>
  13.             <FormItem label="width:">
  14.                 <HSlider id="widthSlider"
  15.                         minimum="100"
  16.                         maximum="300"
  17.                         value="300"
  18.                         snapInterval="1"
  19.                         tickInterval="50"
  20.                         liveDragging="true" />
  21.             </FormItem>
  22.             <FormItem label="height:">
  23.                 <HSlider id="heightSlider"
  24.                         minimum="100"
  25.                         maximum="300"
  26.                         value="200"
  27.                         snapInterval="1"
  28.                         tickInterval="50"
  29.                         liveDragging="true" />
  30.             </FormItem>
  31.         </Form>
  32.     </ApplicationControlBar>
  33.  
  34.     <Graphic>
  35.         <Rect id="rect"
  36.                 width="{widthSlider.value}"
  37.                 height="{heightSlider.value}">
  38.             <fill>
  39.                 <BitmapFill id="bitmapFill"
  40.                         repeat="{checkBox.selected}"
  41.                         source="@Embed('assets/fx_appicon-tn.gif')" />
  42.             </fill>
  43.         </Rect>
  44.     </Graphic>
  45.  
  46. </Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Gumbo, Other | No Comments » | Tags: , ,

Search Posts