嵌套MovieClip时尺寸的编程陷阱

呵呵:) 发个中文的~~

 

新建三个MovieClip symbol,命名为symbol_inner1、symbol_inner2和symbol_container。symbol_inner1里面画一个100*100的正方形,位置为(0,0)。symbol_inner2里面画一个50*50的正方形,位置为(0,0)。在symbol_container中添加symbol_inner1、symbol_inner2的instance各一个,分别命名为m1和m2,位置均设为(0,0)。
回到根舞台,添加symbol_container的instance,命名为m。

 

 

下面分别改变三个MovieClip的_width/_height、_xscale/_yscale。测试工具是AcmeWebWorks的AdminTool beta 1.1.1。

将m1的_width改为200,m2的_height改为200,m的_width和_height分别变成了200和200.3(误差)。m的_xscale和_yscale均为原来的100。

将m的_width该为200,看上去m1和m2也跟着变了。但事实上用AS访问,m1和m2的_width和_xscale仍为原来的值!这可是超级大陷阱!

结论

  • 尺寸和scale总是相挂钩,保持一致。
  • 尺寸有可能由误差,因此用if(_width == 200)要注意了!
  • Container MC的尺寸由所有inner MC共同决定,为能包含所有inner MC的最小矩形。
  • Container MC的尺寸被直接改变后,inner MC的尺寸保持不变!(外面不影响里面)
  • inner MC的尺寸改变后,Container MC会受影响。(里面要影响外面)
  • 另外一个根尺寸有关的陷阱,Luar讲过。

“假設有一個Movie Clip(mc),裡面畫了一個100*100正方形,上面被一個50*50的正方形Mask了。將Movie Clip放在Stage,Info Panel說Movie Clip的寬高度都是50;可惜事與願違,ActionScript卻說Movie Clip的寬高度都是100。
這樣毛病使編程人員難以知道Movie Clip是否到達某位置,ActionScript上到了,但視覺上根本未到。我寫了一個地圖Zoom in Zoom out應用程序,一直沒有問題;直到美工用Mask去做Movie Clip,就發生問題,用ActionScript拿不到準確地圖邊緣位置,使移動時會衝過了。這個編程陷阱,害我Debug了兩晚,XYZ!@#。”

原文在<http://www.luar.com.hk/flashbook/archives/001070.php>

 

Advertisements
This entry was posted in Flash and ActionScript. Bookmark the permalink.

4 Responses to 嵌套MovieClip时尺寸的编程陷阱

  1. Unknown says:

    wow gold!All wow gold US Server 24.99$/1000G on sell! Cheap wow gold,wow gold,wow gold,Buy Cheapest/Safe/Fast WoW US EU wow gold Power leveling wow gold from the time you wWorld of Warcraft gold ordered!

    wow power leveling wow power leveling power leveling wow power leveling wow powerleveling wow power levelingcheap wow power leveling wow power leveling buy wow power leveling wow power leveling buy power leveling wow power leveling cheap power leveling wow power leveling wow power leveling wow power leveling wow powerleveling wow power leveling power leveling wow power leveling wow powerleveling wow power leveling buy rolex cheap rolex wow gold wow gold wow gold wow gold -29612907209143

  2. Unknown says:

    wow gold!All wow gold US Server 24.99$/1000G on sell! Cheap wow gold,wow gold,wow gold,Buy Cheapest/Safe/Fast WoW US EU wow gold Power leveling wow gold from the time you wWorld of Warcraft gold ordered!

    wow power leveling wow power leveling power leveling wow power leveling wow powerleveling wow power levelingcheap wow power leveling wow power leveling buy wow power leveling wow power leveling buy power leveling wow power leveling cheap power leveling wow power leveling wow power leveling wow power leveling wow powerleveling wow power leveling power leveling wow power leveling wow powerleveling wow power leveling buy rolex cheap rolex wow gold wow gold wow gold wow gold -34617395491395

  3. Unknown says:

    wow gold!All wow gold US Server 24.99$/1000G on sell! Cheap wow gold,wow gold,wow gold,Buy Cheapest/Safe/Fast WoW US EU wow gold Power leveling wow gold from the time you wWorld of Warcraft gold ordered!

    wow power leveling wow power leveling power leveling wow power leveling wow powerleveling wow power levelingcheap wow power leveling wow power leveling buy wow power leveling wow power leveling buy power leveling wow power leveling cheap power leveling wow power leveling wow power leveling wow power leveling wow powerleveling wow power leveling power leveling wow power leveling wow powerleveling wow power leveling buy rolex cheap rolex wow gold wow gold wow gold wow gold -209890934629795

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s