Navigation
 
 
 
 
Languages
 
 

Reply to comment

Как поменять цвет бекграунда у муви клипа используя ActionScript 3


Приходится немного программировать на ActionScript 3. Так как мои познания в AS3 не особо глубоки, иногда убивается время на решение достаточно тривиальных задач. Например как програмно менять цвет бекграунда?

Решение оказывается очень простое, надо использовать ColorTransform класс для этого. Вот пример, как сделать бекграунд у myMC черным (или используя любой другой цвет в hex формате):

import flash.geom.ColorTransform;
import flash.geom.Transform;

var rgbColor = hex2rgb('0x000000');
var newColorTransform:ColorTransform = new ColorTransform(0,0,0,1,rgbColor.r,rgbColor.g,rgbColor.b,0);
myMC.transform.colorTransform = newColorTransform;

function hex2rgb (hex):Object{
    var red = hex>>16;
    var greenBlue = hex-(red<<16)
    var green = greenBlue>>8;
    var blue = greenBlue - (green << 8);
    return({r:red, g:green, b:blue});
}


Америки не открыл, но может кому-то будет в помощь.






Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Syntax highlight code surrounded by the {syntaxhighlighter OPTIONS}...{/syntaxhighlighter} tags.

More information about formatting options

CAPTCHA
Are You Human?
 
 
 
 
 
 
  • emmie
  • hooligan
  • cupuyc
  • ESoImk
  • LeKz
 
 
 
© 2006-2009 kobyleha.com