Некоторый код не работает во Flash 10 - PullRequest
0 голосов
/ 22 августа 2010

Почему этот код не работает для Flash 10?:

onClipEvent(load){
    //Import the classes needed to transform the color
    import flash.geom.ColorTransform;
    import flash.geom.Transform;
    //A starting amount to tint the image
    redamount = 0;
    //Is the image getting more red or more blue?
    goingred = true;
}
//Run at the start of each frame
onClipEvent(enterFrame) {
    //if going red is set to true, set the color transform to tint the image more red
    if (goingred) {
        redamount++;
    //otherwise, it is getting more blue
    } else {
        redamount--;
    }
    //the boundaries. If a limit (0 or 64) has been reached, flip from going red to going blue
    if (redamount == 0 || redamount == 64) {
        goingred = !goingred;
    }
    //Declare a new ColorTransform object
    var colorTrans:ColorTransform = new ColorTransform();
    //Set the red offset to the specified amount. Higher is stronger
    colorTrans.redOffset = redamount;
    //when the red offset is low, the blue offset is high, and vice versa. 
    colorTrans.blueOffset = 64-redamount;
    //Create a new Transform object. This is attached to the movieclip 'tintedimage'
    var trans:Transform = new Transform(this);
    //apply the color transform to the transform object
    trans.colorTransform = colorTrans;
}

Ответы [ 2 ]

0 голосов
/ 23 августа 2010

этот код для Actionscript 2, а не 3 .. скомпилируйте ваш flash-файл для actionscript 2, и он будет работать

0 голосов
/ 22 августа 2010

попробуйте это ...

//Import the classes needed to transform the color
import flash.geom.ColorTransform;
import flash.geom.Transform;

//Declare a new ColorTransform object
var colorTrans:ColorTransform = new ColorTransform();

var readamount:Number;
var goingred:Boolean;

onClipEvent(load){

    //A starting amount to tint the image
    redamount = 0;
    //Is the image getting more red or more blue?
    goingred = true;
}

//Run at the start of each frame

onClipEvent(enterFrame) {

    //if going red is set to true, set the color transform to tint the image more red
    if (goingred) {
        redamount++;

    //otherwise, it is getting more blue
    } else {
        redamount--;
    }

    //the boundaries. If a limit (0 or 64) has been reached, flip from going red to going blue
    if (redamount == 0 || redamount == 64) {

        goingred = !goingred;
    }


    //Set the red offset to the specified amount. Higher is stronger
    colorTrans.redOffset = redamount;

    //when the red offset is low, the blue offset is high, and vice versa. 
    colorTrans.blueOffset = 64-redamount;   

    //apply the color transform to the transform object
    this.transform.colorTransform = colorTrans;
}
...