AS3:由于eventListener而调整大小

时间:2010-06-16 16:20:45

标签: flash actionscript-3 resize cs3

我编写了一张地图,当点击省级对象时,它应该移动到屏幕的中心并增加宽度的百分比,同时显示许多不同的东西。

问题是,为了调整图像大小,需要点击两次。它移动,并且所有子项都按照设计的方式显示,但调整大小在第一次单击时不起作用。有任何想法如何解决这个问题?

menuItem4_mc.addEventListener(MouseEvent.CLICK, onClick);

public function onClick(mc:MouseEvent):void { 
   menuItem4_mc.width = width * .65;
   menuItem4_mc.height = height * .7;

   //brings Ontario To the front of the stage
   setChildIndex(menuItem4_mc,numChildren - 1);

   menuItem4_mc.x= 670/2;
   menuItem4_mc.y= 480/2;

   ...
}  

谢谢!

1 个答案:

答案 0 :(得分:0)

首先尝试将定位语句(指x和y)移到width和height语句之上。这可能有用。

如果没有,请在分配时尝试参考舞台的宽度和高度,而不是容器动画片段。我假设容器的尺寸与舞台相同。