简单翻转颜色过渡错误请帮忙

时间:2011-08-18 04:57:49

标签: actionscript-3 flash-cs5

尝试在Actionscript 3中进行简单的翻转颜色转换,我正在

ReferenceError: Error #1069: Property transform not found on
     

fl.transitions.Tween并且没有默认值。             在dell_fla :: MainTimeline / tweenToFinal()             在flash.events::EventDispatcher/dispatchEventFunction()             at flash.events::EventDispatcher/dispatchEvent()             在fl.transitions :: Tween / setPosition()             在fl.transitions :: Tween / update()             at fl.transitions :: Tween / set time()             在fl.transitions :: Tween / nextFrame()             在fl.transitions :: Tween / onEnterFrame()

继承我的剧本

import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.Strong;
    import fl.motion.Color;
    import flash.events.Event;
    import flash.geom.ColorTransform;
    import flash.display.DisplayObject;

    var startColor:uint=0xCCFF00;
    var finalColor:uint=0x003399;
    var colorInfo:ColorTransform;
    // Colour transition for country mouseover
    function initColorTransform(mc:MovieClip):void
    {
        colorInfo = mc.transform.colorTransform;
        var myTween:Tween=new Tween(mc,'alpha',Strong.easeOut,0,1,1,true);
        myTween.addEventListener(TweenEvent.MOTION_CHANGE,tweenToFinal);
    }
    function tweenToFinal(e:TweenEvent):void
    {
        colorInfo.color=Color.interpolateColor(startColor,finalColor,e.position);
        e.target.transform.colorTransform=colorInfo;
    }

    function countryMouseOver(e:Event):void{
        trace('countryMouseOver '+e.target);
        var countryMc = e.target;
        var localPos:Point = new Point(countryMc.x,countryMc.y);
        var globalPos:Point = countryMc.localToGlobal(localPos);
        trace('local pos: '+localPos+ ' global pos:'+globalPos);
        initColorTransform(countryMc);
    }

1 个答案:

答案 0 :(得分:1)

查看TweenEvent docse.target不是您的影片剪辑,而是补间本身。使用Tween(e.target).obj获取动画片段。

   function tweenToFinal(e:TweenEvent):void
    {
        colorInfo.color=Color.interpolateColor(startColor,finalColor,e.position);
        MovieClip(Tween(e.target).obj).transform.colorTransform=colorInfo;
    }