Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   Програмное изменение цвета объекта. (http://www.flasher.ru/forum/showthread.php?t=186363)

imediasun 01.11.2012 15:42

Програмное изменение цвета объекта.
 
Как программно задать изменение цвета объекта анимированно и плавно например с красного на синий (при этом будет заметно изменение спектра.

Друзья - вот ссылка http://imedia.in.ua/images/bottoms.swf Это сделано в Adobe Flash с помощью анимации формы. Вопрос в том как это сделать программно. Так чтобы полоса была растянута в соответствии с окном браузера Если обратите внимание то полоса начинает расширяться с момента четверть слева и еще с переливом цветов как быть тоже программно???, этот вопрос интересен, хотя мне для решения задачи достаточно будет если можно будет как то отметить что расширяется прямоугольник до краев браузера и с использованием анимации формы (хотя вряд ли насколько я понимаю) Есть некоторое решение http://imedia.in.ua/images/bottoms3.swfно оно мне не нравится, во первых не знаю как цвета уточнить а во вторых с анимацией формы должно быть так же как и в первом варианте.
Код AS3:

bottom1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame);
 
function fl_ClickToGoToAndPlayFromFrame(event:MouseEvent):void
{
 
        TweenLite.to(quad_mc, 30, {scaleX:0, ease:Elastic.easeOut});
        TweenLite.to(quad_mc, 30, {scaleX:stage.stageWidth, ease:Elastic.easeOut});
 
}
 
// This line defines a variable of type ColorTransform and naming it colorTransform 
var colorTransform:ColorTransform = new ColorTransform()
 
// Adding an eventlistener to my button to "envoke" the doAnimate_ function when the button is clicked 
bottom1.addEventListener(MouseEvent.CLICK, doAnimate_)
// here is what happens when the button is clicked 
function doAnimate_(event:Event):void 
{ 
    // the colorTransform get a redOffset, we set it to -255 because the values goes from -255 to +255, 
    // so the transistion will be adding 10 to the value -255 and so on untill we get 255 which is max. 
 
 
        colorTransform.redOffset = 25;
 
    // Now adding an eventlistener to the stage, an enterframe event, to call the function doAnimate. 
    // Remember the enter_frame event is called as many times per second as the fps is set to in the flash settings (usually 12 frames per second). 
    this.addEventListener(Event.ENTER_FRAME, doAnimate)
} 
 
// The function here to do the animation 
function doAnimate(event:Event):void 
{ 
    // This is what happens in the animation, first we add 10 to the redoffset value, this is done 12 times a second. 
    // so that is 120 in offset per second. 
    colorTransform.redOffset += 5;
 
 
    // Now we "attach" the colortransform to our object (myBox), without this there will be no effect. 
    quad_mc.transform.colorTransform = colorTransform;
}

Примного благодарен за ответы

DaFive 01.11.2012 16:13

Google -> colorTransform as3 animation
Даже с туториалами есть.


Часовой пояс GMT +4, время: 09:22.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.