PDA

View Full Version : TypeError: Error #2007: Parameter listener must be non-null. Problem



greetification
June 13th, 2008, 03:20 AM
Hi I'm very new to AS3 and so I was playing around with the Tween class trying to make it similar to what i've used in AS2. Currently what I have posted below works fine except I get this error when I run it:

TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()
at AS3MotionTween_fla::MainTimeline/motionTween()
at AS3MotionTween_fla::MainTimeline/moveButton()

I've been looking all over and I can't figure out what's wrong, if anyone could help that would be great.

Thanks!



import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;

play_btn.addEventListener(MouseEvent.CLICK, moveButton);

function moveButton(e:MouseEvent):void {
motionTween("test", e.currentTarget, "x", Elastic.easeOut, 30, 350, 3);
}

play_btn.buttonMode = true;

function motionTween(type:String, mc:Object, transType:String, easeType:Function, begin:Number, end:Number, time:Number):void {
var newTween:Tween = new Tween(mc, transType, easeType, begin, end, time, true);
newTween.addEventListener(TweenEvent.MOTION_FINISH , onMotionFinished(type, mc, transType, easeType, begin, end, time));
}

function onMotionFinished(type:String, mc:Object, transType:String, easeType:Function, begin:Number, end:Number, time:Number) {
switch(type) {
case "trigger_":
break;
default:
trace(mc.btn_test);
break;
}
}

hasch2o
June 13th, 2008, 03:47 AM
Hey greetification

Welcome to the forum

The flash tweening class is pretty slow.
Use this one: http://blog.greensock.com/tweenliteas3/
it's really small, fast and easy to use!

hope that helps a little, don't have flash to test your script, sorry. Just thought I show you this class.

cheers Carlo

greetification
June 13th, 2008, 11:12 AM
Hey greetification

Welcome to the forum

The flash tweening class is pretty slow.
Use this one: http://blog.greensock.com/tweenliteas3/
it's really small, fast and easy to use!

hope that helps a little, don't have flash to test your script, sorry. Just thought I show you this class.

cheers Carlo

Thanks, I'll check that out. Any idea why this is happening in what I have?

I thought it might have something to do with me not passing the event in "onMotionFinished()" along with everything else I was passing, but I can't for the life of me figure out what I would pass.

Also is there any place that compares all the different tweeing pakcages?