View comments | RSS feed

noise (BitmapData.noise method)

public noise(randomSeed:Number, [low:Number], [high:Number], [channelOptions:Number], [grayScale:Boolean]) : Void

Fills an image with pixels representing random noise.

Availability: ActionScript 1.0; Flash Player 8

Parameters

randomSeed:Number - The random seed to use.

low:Number [optional] - The lowest value to generate for each channel (0 to 255). The default is 0.

high:Number [optional] - The highest value to generate for each channel (0 to 255). The default is 255.

channelOptions:Number [optional] - A number that can be a combination of any of the four color channel values: 1 (red), 2 (green), 4 (blue), and 8(alpha). You can use the logical OR operator | to combine channel values. The default value is (1 | 2 | 4).

grayScale:Boolean [optional] - A Boolean value. If the value is true, a grayscale image is created by setting all of the color channels to the same value. The alpha channel selection is not affected by setting this parameter to true. The default value is false.

Example

The following example shows how to apply pixel noise to a BitmapData object for both a color and black-and-white bitmap.

import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;

var bitmapData_1:BitmapData = new BitmapData(100, 80, false, 0x00CCCCCC);
var bitmapData_2:BitmapData = new BitmapData(100, 80, false, 0x00FF0000);

var mc_1:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_1.attachBitmap(bitmapData_1, this.getNextHighestDepth());

var mc_2:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_2.attachBitmap(bitmapData_2, this.getNextHighestDepth());
mc_2._x = 101;

mc_1.onPress = function() {
        bitmapData_1.merge(bitmapData_2, new Rectangle(0, 0, 50, 40), new Point(25, 20), 128, 0, 0, 0);
}

mc_1.onPress = function() {
        bitmapData_1.noise(128, 0, 255, 1, true);
}

mc_2.onPress = function() {
        bitmapData_2.noise(128);
}

Version 8

Comments


joelamay said on Oct 13, 2005 at 3:12 PM :
I think the attachBitmap lines should look like:

mc_1.attachBitmap(bitmapData_1, mc_1.getNextHighestDepth());

The depth arg refers to depth within mc_1, not the depth in _root.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001961.html