更改 MovieClip Actionscript 3 的填充颜色 [英] Changing fill color of MovieClip Actionscript 3

查看:23
本文介绍了更改 MovieClip Actionscript 3 的填充颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下,如何仅更改舞台上实例的填充颜色 - 我可以通过使用 ColorTransform 对象来实现,但它会更改整个实例的颜色,而不仅仅是填充.我只想更改填充颜色,而不是笔触颜色.有人可以帮我吗?

i want to ask, how to change only fill color of an instance on the stage - i can do it by using ColorTransform object, but it changes color of the whole instance, not just the fill. I want to change only the fill color, not the stroke color. can anybody help me?

这是我的代码:

function paint(){
    var myColorTransform:ColorTransform = new ColorTransform();

    myColorTransform.color = someColorNumber;

    coloredObject.transform.colorTransform = myColorTransform;

}

推荐答案

一旦您绘制了一个形状,就无法做到这一点,因为动作脚本无法确定什么是笔画,什么是填充.

This cant be done once you've drawn a shape as action script has no way of determining what is a stroke and what is a fill.

您有几个选择.

将填充和描边分离到单独的影片剪辑中,并将颜色变换设置为仅应用于填充.

Separate your fill and stroke into separate movie clips and set the color transform to only apply to the fill.

如果它是一个简单的形状,请使用 Graphics 对象绘制它,您可以在其中指定填充颜色和笔触颜色.

If it's a simple shape, draw it using the Graphics object where you can specify fill colours and stroke colours.

可能的引擎盖是第一个选项,我更喜欢的方法是,因为形状可能很复杂,将它留在 fla 中可以为设计师而不是开发人员提供更大的控制权来更改它.不过,这需要做更多的工作,而且稍微复杂一些.

Likely hood is, and my preferred method, would be the first options as the shape is likely to be complex and leaving it in the fla gives greater control for a designer being able to change it rather than a developer. It's a little more work though and slightly more complex.

这篇关于更改 MovieClip Actionscript 3 的填充颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆