So I am porting a game I started in html canvas to flash as3.
In this game there is a tank. This tank has a body and a turret. It can rotate 360 degrees and move foward and backwards and swivel it's turret 360 degrees. The tank base and the turret are seperate animated images.
I have set it up so that there is a tank movieclip and a turret movieclip. And I have added code to the tank movieclip so that it creates a turret for itself in the constructor part like this.
turret= new turretMovieClip();
addChild(turret)
So the tank movieclip class now has this turret variable that holds an instance of the turret movieclip. Also in the constructor of the tank movieclip, there is code to give itself a shadow.
var dropShadow:DropShadowFilter = new DropShadowFilter();
dropShadow.distance = 5;
dropShadow.angle = 45;
dropShadow.color = 0x000000;
etc....
this.filters = new Array(dropShadow);
But this is the weird part. I expected the code above to only put a shadow around the tank because this is code for the tank movieclip. But it put a shadow around the tank and the turret. When I added the turret, the tank movieclip changed or something! I did not want this to happen. I want the tank to have it's own shadow and the turret to have it's own shadow.
Here is an image I made illustrating the problem: http://i.imgur.com/EJuf3.jpg
Fig #1 is from my old game. The shadow correctly casts itself over the tank and the ground. Fig #2 shows what the above code did. It gave a shadow for the tank and turret, but it only casts over the ground. Anyone know what I am doing wrong? I think I could fix this by making a master tank class that then creates a tank movieclip and then a turret movieclip. Is that how I'm supposed to do this?