开发者

Some code not working in Flash 10

Why does this code not work for 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 || reda开发者_运维百科mount == 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;
}


try this...

//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;
}


that code is for Actionscript 2 not 3 .. compile your flash file for actionscript 2 and it will work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜