blob: 6015fb188ce8733de09a329d15b8917820942df0 [file] [log] [blame]
////////////////////////////////////////////////////////////////////////////////
//
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.GradientType;
import flash.geom.ColorTransform;
import flash.events.MouseEvent;
public class ColorTransformExample extends Sprite {
public function ColorTransformExample() {
var target:Sprite = new Sprite();
draw(target);
addChild(target);
target.useHandCursor = true;
target.buttonMode = true;
target.addEventListener(MouseEvent.CLICK, clickHandler)
}
public function draw(sprite:Sprite):void {
var red:uint = 0xFF0000;
var green:uint = 0x00FF00;
var blue:uint = 0x0000FF;
var size:Number = 100;
sprite.graphics.beginGradientFill(GradientType.LINEAR, [red, blue, green], [1, 0.5, 1], [0, 200, 255]);
sprite.graphics.drawRect(0, 0, 100, 100);
}
public function clickHandler(event:MouseEvent):void {
var rOffset:Number = transform.colorTransform.redOffset + 25;
var bOffset:Number = transform.colorTransform.redOffset - 25;
this.transform.colorTransform = new ColorTransform(1, 1, 1, 1, rOffset, 0, bOffset, 0);
}
}
}