فلاش:خطأ عند محاولة استخدام setChildIndex و TweenLite إلى إنشاء زر تأثير التغيير

StackOverflow https://stackoverflow.com/questions/1406363

سؤال

alt text
(المصدر: flickr.com)

مرحبا مرة أخرى الجميع :) حتى اليوم أحاول في الأساس بسيطة تأثير توهج على زر التمديد.قد يكون أكثر تعقيد الأمور ، ولكن الطريقة التي سأقوم في هذا هو وجود 2 movieClips(الافتراضي دولة فوق الدولة).

أولا أود أن أضيف الحالة الافتراضية إلى المرحلة القادمة إضافة التمديد الدولة إلى مرحلة ، ولكن على عمق من 0 و ألفا تعيين إلى 0 كذلك.الآن أريد التمديد الدولة لمبادلة أعماق الافتراضي الدولة فضلا عن تحريك تصل إلى كامل ألفا باستخدام TweetLite الدرجة حتى الحصول على لطيفة على نحو سلس الانتقال.

أنا على الحصول على خطأ الآن ولكن هيريس قانون بلدي:

import gs.TweenLite;
import fl.motion.easing.*;
import flash.display.MovieClip;


var shopButton:MovieClip;
var shopButtonRoll:MovieClip;
var maxIndex:Number = this.numChildren - 1;

// Button - places the default state onto the stage
shopButton = new ShopButton();
shopButton.name = "shopButton";
shopButton.x = 262;
shopButton.y = 207;
shopButton.stop();
thumbsMov.addChild(shopButton);

// Button Glow - places rollOver state under the default and with 0 alpha
shopButtonRoll = new ShopButtonRoll();
shopButtonRoll.name = "shopButtonRoll";
shopButtonRoll.x = 262;
shopButtonRoll.y = 207;
shopButtonRoll.alpha = 0;
thumbsMov.addChildAt(shopButtonRoll, 0);

// Listeners

shopButton.addEventListener(MouseEvent.MOUSE_UP, shopClick);
shopButton.addEventListener(MouseEvent.ROLL_OVER, sendToTop);
shopButton.addEventListener(MouseEvent.ROLL_OUT, shopOff);
shopButtonRoll.addEventListener(MouseEvent.ROLL_OVER, shopOver);

// Button Actions 
// shopOver should bring rollOver to top and animate to 100%

function shopOver(event:MouseEvent):void
{
     TweenLite.to(shopButtonRoll, 1, {alpha:1});
}
function shopOff(event:MouseEvent):void
{
     // Code to animate back to 0 then change depth of rollOver to 0
}
function shopClick(event:MouseEvent):void
}
     trace("You clicked Shop");
}

// sendToTop Function
// Sent to top - depth change
function sendToTop(e:Event):void
{
     //this.setChildIndex(ShopButton(e.target), maxIndex);
     this.setChildIndex(e.currentTarget as MovieClip, maxIndex);
}

الخطأ أنا على الحصول على التمديد :(

ArgumentError:خطأ #2025:الموردة DisplayObject يجب أن يكون الطفل من المتصل.في فلاش.عرض::DisplayObjectContainer/setChildIndex() في test_fla::MainTimeline/sendToTop()

أنا لا أفهم ما الخطأ الوسائل الموردة DisplayObject يجب أن يكون الطفل من المتصل ؟

هل كانت مفيدة؟

المحلول

بناء على ما تحاول إنجازه لم يكن لديك لإدارة الأعماق.أساسا يمكنك فقط إضافة تأثير التغيير داخل shopButton ثم توالت مرة واحدة على shopButton تحريك توهج.أنا udpated التعليمات البرمجية التالية:

import gs.TweenLite;
import fl.motion.easing.*;
import flash.display.MovieClip;


var shopButton:MovieClip;
var shopButtonRoll:MovieClip;

// Button - places the default state onto the stage
shopButton = new ShopButton();
shopButton.name = "shopButton";
shopButton.x = 262;
shopButton.y = 207;
shopButton.stop();
thumbsMov.addChild(shopButton);

// Button Glow - places rollOver state under the default and with 0 alpha
shopButtonRoll = new ShopButtonRoll();
shopButtonRoll.name = "shopButtonRoll";
shopButtonRoll.alpha = 0;
shopButton.addChild(shopButtonRoll);


// Listeners
shopButton.buttonMode = true;
shopButton.addEventListener(MouseEvent.MOUSE_UP, shopClick);
shopButton.addEventListener(MouseEvent.ROLL_OVER, shopOver);
shopButton.addEventListener(MouseEvent.ROLL_OUT, shopOff);

// Button Actions 
// shopOver should bring rollOver to top and animate to 100%

function shopOver(event:MouseEvent):void
{
     TweenLite.to(shopButtonRoll, 1, {alpha:1});
}
function shopOff(event:MouseEvent):void
{
    TweenLite.to(shopButtonRoll, 1, {alpha:0});
     // Code to animate back to 0 then change depth of rollOver to 0
}
function shopClick(event:MouseEvent):void
}
     trace("You clicked Shop");
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top