开发者

Flex 4 - 9scalling is not working at runtime (although working in Flash)

I created a 9-scalled background in Flash CS5 which is working fine in Flash CS5

But when i imported it as embeded graphic in Flex, and change dimensions in runtime, 9-scalling doesnt work.

Here is my code.

<?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();
       开发者_如何学C    }

      ]]>
 </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>

Here is the fla file of my 9-scalled file http://rapidshare.com/files/405441500/9scalledgraphic.fla

Thanks


if you have a sprite/movieclip, that uses 9slice-scaling and you scale this thing directly, it works nicely. If this things is a child of another sprite/movieclip/whatever and you scale that one, the 9slice-scaling of your child does not work anymore.

A workaround for this is normally to write functions, that take size-change requests and then resize the children that use9slice-scaling directly, instead of resizing themselves.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜