私はスライドショースタイルのプレゼンテーションを作成しようとしています。プレゼンテーションは、各スライド/ページがムービークリップであり、スライドアニメーションを介して移行します。私が持っている の問題は、私はラグの問題を防ぐために、一度に、ステージ上のすべてのムービークリップを望んでいないことを私が達成しようとしているものの例である:Flash AS3:ArgumentError:Error#2025:指定されたDisplayObjectは、呼び出し元の子でなければなりません。
- 現在のページは、次のボタンがあるページAであり、ページBにはaddChildを使用してステージ上に載置された(しかし、ビューの外に配置される)
- をクリック
- ページAがオフスライド可視段階
- ページBはページAを使用して、ステージから除去さ
- 可視段階にスライドremoveChild - これが問題の原因です。
私のコードは事前に謝罪しなければなりません。私は実際にデザイナーですが、私はまだAS3の基礎を学んでいます。私はおそらく、非常に迂回した/愚かな方法でこれをやったことがありますが、今は私が推測します。
code
// greensock stuff import com.greensock。 ; import com.greensock.easing。;
//buttons that navigate to next and previous slides
prevBtn.addEventListener(MouseEvent.CLICK,prevClicked,false,0,true);
nextBtn.addEventListener(MouseEvent.CLICK,nextClicked,false,0,true);
//setting up array of all the pages
var pageArray:Array = [page1, page2, page3, page4, page5];
var currentArray:Number = 0;
//defining the first page and placing it on the stage
var currentPage:MovieClip = new pageArray[currentArray];
addChild(currentPage);
function nextClicked(event:MouseEvent):void{
//check to ensure it is not the last page
if (currentArray < pageArray.length - 1){
//define the current slide as oldPage
var oldPage:MovieClip = new pageArray[currentArray];
currentArray++;
//define the next slide as currentPage and place on stage
var currentPage:MovieClip = new pageArray[currentArray];
addChild(currentPage);
currentPage.x = 1024;
TweenMax.to(currentPage, 1, {x:0});
TweenMax.to(oldPage, 1, {x:-1024,onComplete:removeChild,onCompleteParams:[oldPage]});
}
}
function prevClicked(event:MouseEvent):void{
//check to ensure it is not the first page
if (currentArray > 0){
//define the current slide as oldPage
var oldPage:MovieClip = new pageArray[currentArray];
currentArray--;
//define the next slide as currentPage and place on stage
var currentPage:MovieClip = new pageArray[currentArray];
addChild(currentPage);
currentPage.x = -1024;
TweenMax.to(currentPage, 1, {x:0});
TweenMax.to(oldPage, 1, {x:1024,onComplete:removeChild,onCompleteParams:[oldPage]}); }
}
code
これは私が間違ってしまった場所だと思う - 私は本当にいつでもステージに 'oldPage'を追加することはない、名前を変更しようとした/ 'currentPage'を 'oldPage'として再定義しようとした左にはremoveChildを使用する前に動作していません。 – user1172903