首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Flash >

动态创建的几个MC怎样添加鼠标响应?该如何处理

2012-03-17 
动态创建的几个MC怎样添加鼠标响应?我用如下的方法创建了四个MC,varmc:MovieClipcreateEmptyMovieClip(

动态创建的几个MC怎样添加鼠标响应?
我用如下的方法创建了四个MC,
var   mc:MovieClip   =   createEmptyMovieClip( "mc ",   getNextHighestDepth());
var   mc1:MovieClip   =   createEmptyMovieClip( "mc1 ",   getNextHighestDepth());
var   mc3:MovieClip   =   createEmptyMovieClip( "mc3 ",   getNextHighestDepth());
var   mc4:MovieClip   =   createEmptyMovieClip( "mc4 ",   getNextHighestDepth());

//添加图片
loadMovie( "1.jpg ",mc);
loadMovie( "2.jpg ",mc1);
loadMovie( "3.jpg ",mc3);
loadMovie( "4.jpg ",mc4);

setproperty   ( "mc ",   _xscale,   50);  
setproperty   ( "mc ",   _yscale,   50);
setproperty   ( "mc ",   _x,   0);  
setproperty   ( "mc ",   _y,   0);  

setproperty   ( "mc1 ",   _xscale,   50);  
setproperty   ( "mc1 ",   _yscale,   50);  
setproperty   ( "mc1 ",   _x,   275);  
setproperty   ( "mc1 ",   _y,   0);

setproperty   ( "mc3 ",   _xscale,   50);  
setproperty   ( "mc3 ",   _yscale,   50);
setproperty   ( "mc3 ",   _x,   0);  
setproperty   ( "mc3 ",   _y,   200);  

setproperty   ( "mc4 ",   _xscale,   50);  
setproperty   ( "mc4 ",   _yscale,   50);  
setproperty   ( "mc4 ",   _x,   275);  
setproperty   ( "mc4 ",   _y,   200);

可是给其中一个添加onMouseDown方法,其他几个也响应。
我如何区分是按下的哪个MC呢?
mc.onMouseDown   =   function   ()   {
        trace   (mc._x);
}

[解决办法]
for (var i = 0; i <movieID; i++) {
for(var j = 0; j <picNum; j++)
{
var thisMC:MovieClip = this.createEmptyMovieClip( "image "+i+j+ "_mc ",this.getNextHighestDepth());
//在影片剪辑实例中加载图片

mcLoader_mcl.loadClip(urlArray[i][j], thisMC);

setproperty ( "image "+i+j+ "_mc ", _alpha, 0)
thisMC._x = _global.mcX;
thisMC._y = _global.mcY;
}
}

热点排行