Error with simple rollover colour transition please help
trying to do a simple rollover colour transition in Actionscript 3, and I'm getting
ReferenceError: Error #1069: Property transform not found on
fl.transitions.Tween and there is no default value. at dell_fla::MainTimeline/tweenToFinal() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at fl.transitions::Tween/setPosition() at fl.transitions::Tween/update() at fl.transitions::Tween/set time() at fl.transitions::Tween/nextFrame() at fl.transitions::Tween/onEnterFrame()
Heres my script
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: 开发者_Go百科'+localPos+ ' global pos:'+globalPos);
initColorTransform(countryMc);
}
Have a look at the TweenEvent docs. The e.target
is not your movie clip but the tween itself. Obtain your movieclip using 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;
}
精彩评论