At 9/1/07 05:37 AM, Paranoia wrote:
At 9/1/07 05:17 AM, manicmonkeydrummer wrote:
I have a movieclip with instance name "player". When it hits another movieclip with the instance name "lava". When the player touches (hitTest) the lava I want the player to have a red tint. I tried putting this actionscript on the lava but it doesn't work.
onClipEvent (enterFrame) {
if (this.hitTest(_root.player)) {
_root.player = "FF0000"
}
}
Well, it wouldn't work since all you're doing is trying to change the reference of your player, which is a MovieClip, to a string :P Also, colours are represented by numbers and not strings - it's 0xFF0000 for hex values - no inverted commas.
For tinting you need to use the ColorTransform class. I'm a little rusty on it, but I think it's along the lines of -
import flash.geom.Transform;
import flash.geom.ColorTransform;
var mc_trans:Transform = new Transform(your_mc);
onEvent = function():Void{
trans.colorTransform = new ColorTransform(1, 1, 1, 1, 255, 0, 0, 0);
// parameters indicate red, green, blue, alpha multipliers and red, reen, blue, alpha offsets
}
The code is not right:
import flash.geom.Transform;
import flash.geom.ColorTransform;
var mc_trans:Transform = new Transform(your_mc);
onLoad = function():Void{
mc_trans.colorTransform = new ColorTransform(1, 1, 1, 1, 255, 0, 0, 0);
// parameters indicate red, green, blue, alpha multipliers and red, reen, blue, alpha offsets
}
This is the right code!