I have the view class which adds a movieclip asteroidMap from inside a function. asteroidMap contains some Movieclips called priceFlags
I listen for mouseOver and mouseOut and then tweenLite the scale of the target.
I am having trouble with bringing the target(the target priceFlag in asteroidMap) to the front of the display list. I’m getting:
1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.
Heres ma code(the problem line is in red):
public function spaceForMap(e:KeyboardEvent):void {
if (e.keyCode == 32)
{
var shipIconX:Number;
var shipIconY:Number;
var shipIconXOffset:Number = -80;
var shipIconYOffset:Number = 30;
shipIconX = (playScreen.rocks.x*-.1182)+25;
shipIconY = (playScreen.rocks.y*-.1173)+252;
switch(mapOut)
{
case("false"):
asteroidMap = new AsteroidMap((shipIconX), (shipIconY));
addChild(asteroidMap);
for (var pFA:Number = 0; pFA < asteroidMap.priceFlagsArray.length; pFA++ )
{
trace("v5501 in for loop for priceFlagsArray");
var currentName:String=asteroidMap.priceFlagsArray[pFA].name
asteroidMap[currentName+ "PriceFlagOreTextField"].text = _model[currentName+"OreTypeValue"];
asteroidMap[currentName+"PriceFlagCargoTextField"].text = _model[currentName+"PaysForCargo"];
asteroidMap[currentName].addEventListener(MouseEvent.MOUSE_OVER, priceFlagMouseOver);
asteroidMap[currentName].addEventListener(MouseEvent.MOUSE_OUT, priceFlagMouseOut);
}
updateMode = false;
mapOut = "true";
break;
case("true"):
removeChild(asteroidMap);
updateMode = true;
mapOut = "false";
break;
}
}
}
private function priceFlagMouseOut(e:MouseEvent):void
{
TweenLite.to(e.currentTarget, .5, { scaleX:.2, scaleY:.2 } );
}
private function priceFlagMouseOver(e:MouseEvent):void
{
[COLOR=#ff0000]asteroidMap.setChildIndex(e.target as MovieClip,asteroidMap.numChildren - 1)[/COLOR];
TweenLite.to( e.currentTarget, .5, {scaleX:2, scaleY:2});
}