如何平滑用作控制皮肤的图像?

发布于 2024-07-29 05:30:50 字数 355 浏览 1 评论 0原文

我正在嵌入这样的图像:

[Embed(source="/tool_deleteUp.png")]
private static const c_deleteButton_styleUp:Class;

我正在这样使用它:

_removeButton = new Button();
_removeButton.setStyle('upSkin', c_deleteButton_styleUp);

当我旋转按钮时,图像不会平滑缩放。 我知道人们用来缩放图像控件中加载的图像的技巧,但我正在用头撞墙,试图弄清楚如何在这里做到这一点。

帮助!

I'm embedding an image like this:

[Embed(source="/tool_deleteUp.png")]
private static const c_deleteButton_styleUp:Class;

I'm using it like this:

_removeButton = new Button();
_removeButton.setStyle('upSkin', c_deleteButton_styleUp);

When I rotate the button, the image doesn't scale smoothly. I know the tricks one uses to scale an image loaded in an Image control, but I'm banging my head against a wall trying to figure out how to do it here.

Help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情归归情 2024-08-05 05:30:51

一种巧妙的方法是遍历按钮的子/孙子,找到类型为 c_deleteButton_styleUp 的相应 Bitmap,并将其平滑设置为 true ...这是 Flex 的一个大缺陷,有时它需要类来进行样式设置,尽管一些 IDisplayObjectFactory 完全足以满足该目的,并且会让您的生活变得更加轻松......但生活就是生活......

不要'不知道一个干净的Flex唯一方法...我能想到的唯一可能性是创建一个SWF,其中包含您的资源作为符号,打开平滑功能,并从该SWF中嵌入该符号...

希望帮助...

问候

back2dos

a hacky way would be to traverse the children/grandchildren of the button, to find the corresponding Bitmap that is of type c_deleteButton_styleUp, and set its smoothing to true ... it is a big flaw of flex, that sometimes it requires classes for styling although some IDisplayObjectFactory would completely suffice for that purpose and would make your life a lot easier ... but life is life ...

don't know of a clean flex only way ... the only possibility i could think of, is to create an SWF, that contains your asset as a symbol, with smoothing turned on, and embed this symbol from that SWF ...

hope that helps ...

greetz

back2dos

走走停停 2024-08-05 05:30:51

更好、更通用的解决方案。 它不仅可以处理上述情况,而且

  • 无需子类即可
  • 与任何 UIComponent 一起使用,包括 IRawChildContainers(如 Container),它在 rawChildren 中隐藏皮肤子项。
  • 它仅平滑新添加的项目,而不是每次控件更新时运行。

public static function smoothChildBitmaps(object:UIComponent):void{

    // Define a nested smooth method
    function smoothChildren(val:UIComponent):void{
        var childList:IChildList;
        if(val is IRawChildrenContainer){
            childList = (val as IRawChildrenContainer).rawChildren;
        }
        else{
            childList = object;
        }

        for(var i:int = 0; i < childList.numChildren; i++){
            var child:Bitmap = childList.getChildAt(i) as Bitmap;
            if(child != null){
                child.smoothing = true;
            }
        }
    };

    // Call the nested method on the object right away
    smoothChildren(object);

    // Set up an event handler to re-call the method when a child is added
    object.addEventListener(
        Event.ADDED,
        function(args:Event):void{
            smoothChildren(object);
        }
    );
}

A better, more general solution. Not only does it handle the above case, but it does it

  • Without subclasses
  • It works with any UIComponent, including IRawChildContainers (like Container), which hide skin children in rawChildren
  • It only smooths newly added items, instead of running every time the control updates.

public static function smoothChildBitmaps(object:UIComponent):void{

    // Define a nested smooth method
    function smoothChildren(val:UIComponent):void{
        var childList:IChildList;
        if(val is IRawChildrenContainer){
            childList = (val as IRawChildrenContainer).rawChildren;
        }
        else{
            childList = object;
        }

        for(var i:int = 0; i < childList.numChildren; i++){
            var child:Bitmap = childList.getChildAt(i) as Bitmap;
            if(child != null){
                child.smoothing = true;
            }
        }
    };

    // Call the nested method on the object right away
    smoothChildren(object);

    // Set up an event handler to re-call the method when a child is added
    object.addEventListener(
        Event.ADDED,
        function(args:Event):void{
            smoothChildren(object);
        }
    );
}
已下线请稍等 2024-08-05 05:30:51

愚蠢,但它有效。

import flash.display.Bitmap;
import mx.controls.Button;

public class SmoothButton extends Button{
    protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
        for(var i:int = 0; i < this.numChildren; i++){
            var child:Bitmap = this.getChildAt(i) as Bitmap;
            if(child != null){
                child.smoothing = true;
            }
        }
    }

}

Silly, but it works.

import flash.display.Bitmap;
import mx.controls.Button;

public class SmoothButton extends Button{
    protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
        for(var i:int = 0; i < this.numChildren; i++){
            var child:Bitmap = this.getChildAt(i) as Bitmap;
            if(child != null){
                child.smoothing = true;
            }
        }
    }

}
策马西风 2024-08-05 05:30:51

我不知道你们是因为什么而撞头的无意冒犯,只是开玩笑。 我有一张桌子 :-P

无论如何,提供的那些脚本完全没用! 一方面,您无法将 uicomponent 转换为位图! 另一件事是,带有 rawchildren 的秒脚本或多或少相同。 rawchildren 获取您的孩子和容器的铬 - 就是这样。 如果容器中有一个按钮,您可以尝试平滑容器的镶边 - 其余部分保持不变,因为所有转换为位图都会失败。

那么,有人rdfm吗?

另一方面。 人们可以尝试 stage.quality 到 stagequality.best。 如果您查看 adobe 论坛http://forums.adobe.com/thread/427899,您会看到flex运行良好 - 只是空气有点忽略这一点:-(

如果这两个脚本曾经工作过 - 特别是带有按钮作为位图的部分 - 我会去某个地方砸碎我的头:-)。 我在类层次结构中看不到这可行的方法。 毕竟, numChildren 只为您提供 uicomponents 或 displayobjects,仅此而已!

I do not know what you folks banged your head on no offense, just joking. I had a desk :-P

Anyway, those scripts presented are totally useless! For one thing you cannot cast a uicomponent to bitmap! The other thing is, that the seconds script with rawchildren ist more ore less the same. rawchildren gets your the children and the chrome of the container - that's it. If you have a button in a container you can try to smooth the chrome of the container - the rest stays the same since all casts to bitmap will fail.

So, did anyon rdfm?

On the other hand. One could try out stage.quality to stagequality.best. If you check the adobe forums http://forums.adobe.com/thread/427899 you will see that flex runs well - just air kind of ignores this :-(

If those two scripts ever worked - esp. the part with button as bitmap - I'll go and smash my head somewhere :-). I see NO WAY in the class hierarchy that this could work. After all, numChildren only gives you uicomponents or displayobjects but nothing more!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文