Newb AS3 error: 1046: Type was not found or was not a compile-time constant: Tween
I seem to have a problem here with my AS3 code.
Im just trying out AS3 for pratically the first time and I keep runing into errors. Usually I tinker about and seem to resolve them, but this one stumps me, since it "should" work. Can anyone help me out please?
package {
import flash.display.*;
import flash.events.*;
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.events.MouseEvent;
public class InfoModule extends MovieClip
{
function InfoModule()
{
trace("InfoModule Added.");
addEventListener(Event.ADDED_TO_STAGE, GetData);
addEventListener(Event.CLICK, InfoTweenIn);
//addEventListener(Event.MOUSE_LEAVE, InfoTweenOut);
}
public function GetData(event):void
{
//future php code here
}
private function InfoTweenIn(Event:MouseEvent){
var TweenIn:Tween = new Tween (this,"_y",Regular.easeInOut,this.y,400,1,true);
}
private function destroyMe(object:*):开发者_C百科void {
if(object.parent != null){
var parent:DisplayObjectContainer = object.parent;
parent.removeChild(object);
}
}
}
}
Sooo, I keep getting an error on the Tween class, line 34 saying:
1046: Type was not found or was not a compile-time constant: Tween. and
1180: Call to a possibly undefined method Tween.
and a few more. If you need the full error list, please tell me.
Anyway, I'm pretty sure I imported the Tween library, so what's up?
Please help and thank you.
Assuming you are using Flash Professional IDE? The Tween class is in the fl.* package these days:
import fl.transitions.Tween;
You are mixing up snippets from Actionscript 2.0 and Actionscript 3.0 which is why the compiler cannot find the Tween classes. I recommend you don't use mx.transitions.Tween which is AS2. Stick to Actionscript 3.0 and use an easy to use third party tween engine such as TweenLite or Tweener. Both have example pages to get you started:
http://www.greensock.com/tweenlite/
http://code.google.com/p/tweener/
精彩评论