0
我有一個問題要在其容器中居中放置一個動畫。AS3:將一個動畫加載到另一個動畫的中心
這是集裝箱或裝載器:
public function Main():void
{
trace("Constructor...");
this.addEventListener(Event.ADDED_TO_STAGE, this.addEvent);
}
public function addEvent(e:Event):void
{
trace("AddedToStage");
this.stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.align = StageAlign.TOP_LEFT;
var url = new URLRequest("testfile.swf");
movie = new Loader();
movie.contentLoaderInfo.addEventListener(Event.COMPLETE, this.eventComplete);
this.stage.addChild(movie);
movie.load(url);
}
public function eventComplete(e:Event):void
{
trace("Complete...");
movie.x = (this.stage.stageWidth - movie.width) * 0.5;
movie.y = (this.stage.stageHeight - movie.height) * 0.5;
}
用時添加的動作是在場景中的對象,而與對象完全這項工作......這樣的:
public function Main():void
{
trace("Constructor of included file!");
stage.scaleMode = StageScaleMode.NO_SCALE;
var movieclip = new symbol_an();
stage.addChild(movieclip);
}
你有解決方案嗎?
謝謝,問候。
第一個文件是第二個testfile.swf(上面的第二個代碼)的container.swf(上面的第一個代碼);這不是兩個不同的例子,而是一個! ADDED_TO_STAGE不會產生任何問題,它只是一箇中心問題。 – Acti67 2010-08-15 18:11:09
更多信息:第二個代碼不能改變,因爲這可能是任何動畫文件...第一個包含在這個例子中的代碼第二個代碼必須將動畫集中在裏面。 示例:如果動畫是300x300,她必須居中放置在容器800x600內,但動作定義自己的(x,y)值時動畫不會居中居中(這可與直接在Flash中添加和放置動畫片段現場)。 – Acti67 2010-08-15 18:11:37
從不暗示ADDED_TO_STAGE是它不會居中的原因:)再次閱讀...對於以容器爲中心的內容,您需要知道兩個元素的寬度和高度。在你的第二個代碼中,你需要知道你的symbol_an的寬度和高度是多少,因爲我猜這是你的測試文件的大小,因爲我沒有看到任何其他的代碼。有辦法找出,但取決於您加載的動畫。 – PatrickS 2010-08-16 01:31:49