2010-07-10 31 views
1

我創建在Flash CS5 9縮減規模背景,其在Flash CS5的Flex 4 - 9scalling不會在運行時工作(雖然在閃光工作)

工作正常但是,當我進口它作爲Flex中內嵌的圖形,並在運行時更改尺寸,9-scalling不起作用。

這是我的代碼。

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"> 
<fx:Script> 
     <![CDATA[ 
      import mx.events.FlexEvent; 



      [Embed(source='mgraphic.swf', symbol='Bck')] 
      [Bindable] 
      public var imgCls:Class; 


      protected function button1_clickHandler(event:MouseEvent):void 
      { 
       nineScalled.width = 100 + (this.width - 100) * Math.random(); 
       nineScalled.height = 100 + (this.height - 100) * Math.random(); 
      } 

     ]]> 
</fx:Script> 
<s:layout> 
     <s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/> 
</s:layout> 

<s:Button label="change" click="button1_clickHandler(event)"/> 
<s:BorderContainer id="nineScalled" backgroundImage="{imgCls}" backgroundImageFillMode="scale" width="469" height="187"/> 
</s:Application> 

這是我9縮減規模文件的FLA文件 http://rapidshare.com/files/405441500/9scalledgraphic.fla

感謝

回答

0

,如果你有一個精靈/影片剪輯,使用9slice縮放和你直接縮放這個東西,它很好地工作。如果這個東西是另一個精靈/動畫片夾的孩子,那麼你的孩子的九片縮放不再起作用。

解決此問題的方法通常是編寫函數,該函數需要大小更改請求,然後調整直接使用9slice縮放的子級的大小,而不是調整自己的大小。