import flash.geom.ColorTransform;//ورود کلاس تغيير رنگ ها
var myElements_array1:Array = [1, 0, 0, 0, 19,
0, 1, 0, 0, 100,
0, 0, 1, 0, -43,
0, 0, 0, 1, 4];//تعيين آرايه ماتريس جابجايي رنگها
var myColorMatrix_filter1:ColorMatrixFilter = new ColorMatrixFilter(myElements_array1);
//ساخت شي تعيين رنگ اول و قرار دادن آرايه ماتريس در آن
var myElements_array2:Array = [1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0];//تعيين آرايه ماتريس جابجايي رنگها دوم
var myColorMatrix_filter2:ColorMatrixFilter = new ColorMatrixFilter(myElements_array2);
//ساخت شي تعيين رنگ دوم و قرار دادن آرايه ماتريس در آن
addEventListener(Event.ENTER_FRAME,ChangeTheColor);//تابع تغيير رنگ ها در شي سمت راست
MC2.addEventListener(MouseEvent.MOUSE_OVER,OverFunctiom);//تابع اجرايي در حالت لمس شي وسط
MC2.addEventListener(MouseEvent.MOUSE_OUT,OutFunctiom);//تابع اجرايي در حالت رهايي موس از شي وسط
//.......................................شي سمت چپ
MC3.transform.colorTransform = new ColorTransform(1,0,0,1,200,0,25,100);//تغيير رنگ مووي کليپ سمت چپي
//چهار پارامتر سمت چپ بين 0 و 1 انتخاب شده و فقط براي تعيين به ترتيب از چپ مربوط به قرمز و سبز و آبي و آلفا هستند .
//چهار پارامتر سمت راست مربوط به آفست به ترتيب از چپ به راست ، قرمز و سبز و ابي و الفا هستند و اعداد بين 0 تا 255 را شامل مي شوند .
//....................................................
function OverFunctiom(evt:MouseEvent):void//تابع لمس شي وسط
{
MC2.filters = [myColorMatrix_filter1];//اختصاص فيلتر اول به شي وسط
}
function OutFunctiom(evt:MouseEvent):void//تابع رهايي از لمس شي وسط
{
MC2.filters = [];//فيلتر خالي
}
function ChangeTheColor(evt:Event):void//تابع اجرايي لحظه لحظه اي براي تغيير رنگ در شي سمت راست
{
myElements_array2[0]=Math.floor(Math.random()*2);
myElements_array2[1]=Math.floor(Math.random()*2);
myElements_array2[2]=Math.floor(Math.random()*2);
myElements_array2[3]=Math.floor(Math.random()*2);
myElements_array2[5]=Math.floor(Math.random()*2);
myElements_array2[6]=Math.floor(Math.random()*2);
myElements_array2[7]=Math.floor(Math.random()*2);
myElements_array2[8]=Math.floor(Math.random()*2);
myElements_array2[10]=Math.floor(Math.random()*2);
myElements_array2[11]=Math.floor(Math.random()*2);
myElements_array2[12]=Math.floor(Math.random()*2);
myElements_array2[13]=Math.floor(Math.random()*2);
myElements_array2[15]=Math.floor(Math.random()*2);
myElements_array2[16]=Math.floor(Math.random()*2);
myElements_array2[17]=Math.floor(Math.random()*2);
myElements_array2[18]=Math.floor(Math.random()*2);
myElements_array2[4]++;
myElements_array2[9]++;
myElements_array2[14]++;
myElements_array2[19]++;
if(myElements_array2[4] == 100)
{
myElements_array2[4] = -100;
myElements_array2[14] = -100;
myElements_array2[9] = -100;
myElements_array2[19] = -100;
}
myColorMatrix_filter2.matrix=myElements_array2;
MC1.filters = [myColorMatrix_filter2];
}