0
votes

for some reason Im getting the following error

Implicity coercion of a value with a static type flash.display:DisplayObject to a possibly unrelated type flash.display:MovieClip

The line the error points to is "addInfoBubble(item)" below

for(var i:Number=0; i < MapContainer.numChildren; i++) {
    var item:DisplayObject = MapContainer.getChildAt(i);
    if(item!=null && item is MovieClip){ // make sure its a movieclip
        trace('Found movieclip');
        addInfoBubble(item);
        item.addEventListener(MouseEvent.MOUSE_OVER, countryMouseOver);
        item.addEventListener(MouseEvent.MOUSE_OUT, countryMouseOut);
    } 

}
1

1 Answers

5
votes

Even though you made sure it's a MovieClip, the compiler doesn't know that. The variable needs to be typed as a MovieClip.

Change these 2 lines:

var item:DisplayObject = MapContainer.getChildAt(i);
if(item!=null && item is MovieClip){ // make sure its a movieclip

to

var item:MovieClip = MapContainer.getChildAt(i) as MovieClip;
if(item){