我在班上很新。下面是一個嘗試創建一個StageObject類,我可以設置寬度,高度,xy和背景顏色。班 - 新手上課「這個。」
package
{
import flash.display.MovieClip;
public class StageObjects extends MovieClip
{
public function StageObjects()
{
// constructor code
}
public function setUpStageObject(w:int, h:int, X:int, Y:int, color:Number):void
{
this.width = w;
this.height = h;
this.x = X;
this.y = Y;
this.cacheAsBitmap = true;
this.graphics.beginFill(color,1);
this.graphics.drawRect(0,0,w,h);
this.graphics.endFill();
this.opaqueBackground = color;
trace("parameters: " + w + " - " + h + " - " + X + " - " + Y + " - " + color);
}
/*~~~ adjust position and scale functions ~~~*/
public function adjustXY(ch:Object, par:Object):void
{
var w = par.width;
var h = par.height;
ch.x = par.x + (w - ch.width)/2;
ch.y = par.y + (h - ch.height)/2;
}
public function adjustWH(ch:Object, par:Object):void
{
var w = par.width;
var h = par.height;
}
}
}
在主時間軸(閃存)我這樣做:
var titleBkg:StageObjects = new StageObjects();
titleBkg.setUpStageObject(imageBoxWidth, titleBkgHeight, -1, imageBoxHeight +1, 0x589199);
this.addChild(titleBkg);
但它不會顯示出來。我有沒有提到「這個」。錯誤?
設置一個空的影片剪輯的寬度/高度沒有任何影響。你可以刪除'this.width = w; this.height = h;' –
如何給剪輯內容? – artcase
當然,如果你不需要任何一個動畫片段的功能,只需使用一個精靈。 –