use trace(_myBug,_myBug.stage) to see what the problem is.
I get [object SmallFlyImg] [object Stage] as the output, which is exactly as I would expect. In this case _myBug will be an instance of SmallFlyImg (Small Fly Image).
and click file/publish settings/swf and tick permit debugging. when you retest note the line number triggering the error message.
Good idea. Tracing the name returns the exact same name as the one in the error message :/ (In the last test run I did it was instance441 rather than instance454, but that is irrelevant I think). It is this line that is triggering the error:
_myAnim = _myAnimFactory.addTarget(_myBug, 1);
Arg, Flash hurts my brain some days.
Incidentally, I have just tried reverting back to my old basic tweening method and it works perfectly, _myBug is appearing and functioning as normal. So it shouldn't be the source of the issue. I know this problem is all going to be cause by some tiny misunderstanding but I honestly can't get my head around it just now.
something's out of scope.
comment out your listener to see if that's part of the problem.
Great minds think alike, I just tried that. Same problem.
I also tried commenting out the 'problem' line (e.g. _myAnim = ...), just to see if it was possibly the line before causing the error and Flash was mistakenly thinking it was the line after, no errors.
Finally, I tried making _myBug a public var (trying anything now haha) and still the same issue.
I also tried tracing _myBug.name from the subclass (SmallFly) and it came up no problem.
I'm not sure if this is progress or not, but I came across a post which said that display objects created dynamically couldn't be used with the AnimatorFactory. So I tried putting an instance of the image I want to move on the timeline of the SmallFly class, and got this error instead:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.motion::AnimatorBase/set target()
dynamically created objects CAN be used with the AnimatorFactory. that's not the problem.
there's something else about your setup that's causing the problem. i'm not sure if the problem is because _myMotion or _myBug is out of scope.
Hmmm... If I use trace(_myAnimFactory.toString()); on the line after it is created I get a compiler error saying that there is no "toString" method (Call to possibly undefined function through reference with static type fl.motion.AnimatorFactory), even though it is listed in the official documentation.
the toString() method is inherited from the object class so you should cast your instance: