0

我已經將AS2 swf加載到AS3 swf中,但MovieClipLoader對象的onLoadInit函數未執行;這使我的圖像不居中,並沒有減少尺寸(寬度/高度)AS2 Gallery swf加載到主網頁AS3 swf

它的作品,如果我直接運行AS2 SWF(畫廊)。

listenerObj.onLoadInit = function (target:MovieClip) { 
     if (target._height > _root.maxHeight) 
     { 
      var ratio = target._height/_root.maxHeight; 
      target._height = target._height/ratio; 
      target._width = target._width/ratio; 
     } 
     if (target_mc._width > _root.maxWidth) 
     { 
      var ratio = target._width/_root.maxWidth; 
      target._height = target._height/ratio; 
      target._width = target._width/ratio; 
     } 
     target._x = ((Stage.width/2)-(target._width/2)); 
     target._y = ((Stage.height/2)-(target._height/2)); 
    } 
    MCL.addListener(listenerObj); 

回答

0

在AS3中加載AS2電影時,存在一些行爲和錯誤方面的細微差異。我也遇到了你所看到的行爲 - 當電影在AS3中加載時,沒有任何加載處理程序在偵聽器上工作。加載AVM1電影時有一些奇怪的問題,特別是在嵌套加載時。

也許你可以做的最好的方法就是在onFrame上查詢加載剪輯的時間。一種方法是觀察_width!= 0.這應該在剪輯加載後發生。然後你可以初始化位置:

function onEnterFrame() 
{ 
    if(target._width) 
    { 
    // your positioning+init code here 
    onEnterFrame = null; 
    } 
} 
+0

我在哪裏附加onEnterFrame? – klj613 2011-03-28 18:06:14

+0

tmpImg.onEnterFrame = function(){trace(tmpImg._width)}總是返回0 – klj613 2011-03-28 18:10:04

+0

終於得到它的工作,感謝您的幫助。你引導我在正確的方向:) – klj613 2011-03-28 19:04:17

相關問題