Change variables in Class with a function

My first post ever!

Ok, I’m building an interactive webcam thing… In a few words I try to make a color trace when you move in front of your webcam. I use different kinds of filters but mainly I want to change the variables in the ColorMatrixFilter, that’s in my class.

I have also this little ball that sense if you “touch” it, a kind of motion detection. When you touch the ball I call this function. I want that function to change the variables in the ColorMatrixFilter that’s in my class called “WebcamMotion”. But I don’t know how to do…

Here is the code for the motion detection of “ball-mc” in my fla:

var vid:Video;
var cam:Camera = Camera.get();
vid.attachVideo(cam);

//
// 2. the activityLevel property
//

this.onEnterFrame = function() {
var actLevel:Number = cam.activityLevel;
};
cam.onActivity = function(isActive:Boolean) {
};

//
// 3. The BitmapData class
//

import flash.display.BitmapData;
var screenS = new BitmapData(cam.width, cam.height);

////

var sizeDif:Number = videoW/cam.width;

var now = new BitmapData(cam.width, cam.height);
var before = new BitmapData(cam.width, cam.height);

function hitDetect() {

var ballX:Number = (ball_mc._x-videoX)/sizeDif
var ballY:Number = (ball_mc._y-videoY)/sizeDif

now.draw(vid)

var valNow:Number = (now.getPixel(ballX, ballY) >> 16 & 0xFF);
var valBefore:Number = (before.getPixel(ballX, ballY) >> 16 & 0xFF);


if (valNow>valBefore+30 || valNow<valBefore-30) {
trace ("hit")
if (ball_mc._currentframe == 1)
ball_mc.gotoAndPlay(2)
}


before.draw(vid)
}


var intervalID:Number = setInterval(hitDetect, 20);

And here is the code for the class:

class WebcamMotion extends MovieClip


{

    var fireBmp, prevBmp, tempBmp, greyBmp, mtx, pnt, blurF, greyscaleCMF, fireCMF, dispMapF, webcam, createEmptyMovieClip, fireBmpHolder;

    function WebcamMotion()    
    

    {

        super();

        fireBmp = new flash.display.BitmapData(640, 480, false, 0);

        prevBmp = fireBmp.clone();

        tempBmp = fireBmp.clone();

        greyBmp = new flash.display.BitmapData(640, 480, false, 16743424);

        mtx = new flash.geom.Matrix();

        pnt = new flash.geom.Point();

        blurF = new flash.filters.BlurFilter(20, 20, 10);

        greyscaleCMF = new flash.filters.ColorMatrixFilter([3.300000E-001, 3.300000E-001, 3.300000E-001, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]);

        fireCMF = new flash.filters.ColorMatrixFilter([9.000000E-001, 2.000000E-001, 0, 0, 0, 0, 1.500000E-001, 0, 0, 0, 0, 0, 9.000000E-001, 0, 0, 0, 0, 1, 0]);

        dispMapF = new flash.filters.DisplacementMapFilter(tempBmp, pnt, 40, 40, 40, -35, "wrap");
        

        

    } // End of the function

    function onLoad()

    {

        this.configUI();

    } // End of the function

    function configUI()

    {
        //webcam._visible = false;
        webcam._alpha = 100;    

        webcam._xscale = webcam._yscale = 100;

        var _loc2 = Camera.get();

        webcam.vid.attachVideo(_loc2);

        fireBmpHolder = this.createEmptyMovieClip("fireBmpHolder", 1);

        fireBmpHolder._xscale = fireBmpHolder._yscale = 100;

        fireBmpHolder.attachBitmap(fireBmp, 1, "always", false);

        fireBmpHolder.blendMode = "hardlight";

        

    } // End of the function

    function onEnterFrame()

    {

        tempBmp.copyPixels(prevBmp, prevBmp.rectangle, pnt);

        prevBmp.draw(webcam);

        if (tempBmp.getPixel(1, 1) < 2)        

        

        {

            return;

        } // end if

        tempBmp.draw(prevBmp, mtx, null, "overlay");

        tempBmp.applyFilter(tempBmp, tempBmp.rectangle, pnt, greyscaleCMF);

        tempBmp.threshold(tempBmp, tempBmp.rectangle, pnt, ">", 1638400, 4.289379E+009, 16711680, false);

        tempBmp.applyFilter(tempBmp, tempBmp.rectangle, pnt, blurF);

        fireBmp.draw(tempBmp, mtx, null, "add");

        tempBmp.perlinNoise(13, 10, 1, random(100), false, true, 3, false);

        tempBmp.draw(greyBmp, mtx, null, "screen");

        fireBmp.applyFilter(fireBmp, fireBmp.rectangle, pnt, dispMapF);

        fireBmp.applyFilter(fireBmp, fireBmp.rectangle, pnt, fireCMF);


    } // End of the function

    static var CLASS_REF = WebcamMotion;

    static var LINKAGE_ID = "WebcamMotion";

} // End of Class

If anyone know how to solve this it would be awesome!

I post my fla and class too.

/Sewen