[ActionScript 3.0] Dynamically change the color of a movie clip

Source: Internet
Author: User

Flash.geom.ColorTransform

You can use the ColorTransform class to adjust the color values of the display object. You can apply color adjustment or color conversion to all four channels: red, green, blue, and Alpha transparency.

When the ColorTransform object is applied to the display object, the new value is calculated for each color channel as follows:

    • New Red value = (Old red value * redmultiplier) + Redoffset
    • New Green value = (old green value * greenmultiplier) + Greenoffset
    • New Blue value = (Old blue value * bluemultiplier) + Blueoffset
    • New Alpha value = (old alpha value * alphamultiplier) + Alphaoffset

If any one of the color channel values is greater than 255 after the calculation, the value is set to 255. If the value is less than 0, it is set to 0.

You can use the ColorTransform object in the following ways:

    • In the ColorTransform parameter of the ColorTransform () method of the BitmapData class
    • The ColorTransform property as a Transform object (this object can be used as the Transform property of the display object)

You must use the new ColorTransform () constructor to create a ColorTransform object before you can invoke the methods of the ColorTransform object.

Color transformations are not applied to the background color of movie clips, such as loaded SWF objects, and they apply only to graphics and symbols attached to a movie clip.

Simple example:

var New  = 0xffff00= ct;

[ActionScript 3.0] Dynamically change the color of a movie clip

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.