for some reason Im gettin开发者_运维技巧g 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);
}
}
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){
精彩评论