![]() |
|
||||||||||
|
|||||
|
Регистрация: Apr 2011
Сообщений: 83
|
Привет. Вот хотел узнать, можно ли сменить цвет созданного объекта? Вот пример.
Клас Box package { import flash.display.Sprite; public class Box extends Sprite { public var boxGame:Sprite = new Sprite ( ); public function Box() { boxGame.graphics.lineStyle ( 1 ); boxGame.graphics.beginFill ( 0xffff ); boxGame.graphics.drawRect ( 0, 0, 20, 20); boxGame.graphics.endFill ( ); addChild ( boxGame ); } } } При запуске программы на экране мы получаем квадрат заданного цвета. Как поменять цвет данного квадрата, допустим при щелчке на него мышкой? |
|
|||||
|
Примерно так.
__________________
Ну все, теперь Забава м-о-я. Гы-гы, а корабль мой! |
|
|||||
|
А кто Вам мешает сделать класс, который умеет менять свой цвет:
package { import flash.display.Sprite; public class Box extends Sprite { public var boxGame:Sprite = new Sprite ( ); private var _color:uint; public function Box() { this.color = 0xffffff; addChild ( bGame ); } public function set color(value:uint):void { _color = value; draw(); } private function draw():void { boxGame.graphics.clear(); boxGame.graphics.lineStyle ( 1 ); boxGame.graphics.beginFill ( _color ); boxGame.graphics.drawRect ( 0, 0, 20, 20); boxGame.graphics.endFill ( ); } } }
__________________
http://www.chessmax.ru |
![]() |
![]() |
Часовой пояс GMT +4, время: 17:48. |
|
|
« Предыдущая тема | Следующая тема » |
|
|