Jump to content
Search Community

transformAroundCenter problem

AlexGD test
Moderator Tag

Recommended Posts

Sometimes I have error:

 

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock.plugins::TransformAroundPointPlugin/_onInitTween()[/Active/_Flash/_AS3_v12/src/com/greensock/plugins/TransformAroundPointPlugin.as:96]
at com.greensock.plugins::TransformAroundCenterPlugin/_onInitTween()[/Active/_Flash/_AS3_v12/src/com/greensock/plugins/TransformAroundCenterPlugin.as:58]
at com.greensock::TweenLite/_initProps()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:590]
at com.greensock::TweenLite/_init()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:555]
at com.greensock::TweenLite/render()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:700]
at com.greensock::TweenLite()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:488]
at com.greensock::TweenLite/_init()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:505]
at com.greensock::TweenMax/render()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenMax.as:970]
at com.greensock.core::SimpleTimeline/render()[/Active/_Flash/_AS3_v12/src/com/greensock/core/SimpleTimeline.as:166]
at com.greensock.core::Animation$/_updateRoot()[/Active/_Flash/_AS3_v12/src/com/greensock/core/Animation.as:570]

 

Problem is not so critical for flash player, but very critical for iOS (application crash).

 

We are using club swc (latest version).

 
Link to comment
Share on other sites

Hi and welcome to the GreenSock forums.

 

99.9% of the times error 1009 is caused by passing an invalid (undefined) target to a tween.

The best thing to do is trace() out your tween target before running the tween that is causing the error like so

trace("target = " + mc);
TweenLite.to(mc, 1, {x:100})

If that trace produces "target = undefined", then you know the problem is with your code and not the engine. 

 

However, if mc is defined immediately prior to the tween, then perhaps there is something we need to look at. 

 

Either way, it would be most helpful if you could provide a very simple set of files that clearly illustrates the problem. You can zip your files and attach them to this thread

  • Like 1
Link to comment
Share on other sites

Yeap, I understand it.

 

In my case mc defined at start of Tween. Of course, it is defined until tween is not completed, but... in progress of tween I can remove this mc from stage (container), so mc will not have parent. 

 

In this plugin - parent of mc is not checked.

 

This is not so rare situation to ignore it...

 

Thanks in advance for fix it..

Link to comment
Share on other sites

Hi,

 

I created a small sample file where I remove an object from its parent mid-tween and could not replicate the error your are referring to:

 

import com.greensock.TweenLite; 
import com.greensock.plugins.TweenPlugin; 
import com.greensock.plugins.TransformAroundPointPlugin; 
import com.greensock.plugins.TransformAroundCenterPlugin; 
TweenPlugin.activate([TransformAroundPointPlugin, TransformAroundCenterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.


TweenLite.to(container.mc, 2, {transformAroundCenter:{scale:1.5, rotation:150}}); 


TweenLite.delayedCall(0.5, remove)


function remove() {
trace(container.mc.parent);
trace("remove");
container.removeChild(container.mc); 
trace(container.mc.parent);
}

 

I've attached my version, it would be most helpful if you could edit it or provide a similar file that illustrates the error in a clear and concise fashion. If there's a bug somewhere, we certainly want to fix it.

 

Thanks

TransformAroundCenterTest.fla.zip

Link to comment
Share on other sites

import com.greensock.TweenLite; 
import com.greensock.plugins.TweenPlugin; 
import com.greensock.plugins.TransformAroundPointPlugin; 
import com.greensock.plugins.TransformAroundCenterPlugin; 
import flash.display.Sprite;

TweenPlugin.activate([TransformAroundPointPlugin, TransformAroundCenterPlugin]); //activation is permanent in the SWF, so this line only needs to be run once.


var container:Sprite = new Sprite();
container.name = "container";
container.graphics.clear();
container.graphics.beginFill(0xff00ff,1);
container.graphics.drawRect(0, 0, 300, 300);
container.graphics.endFill();

this.addChild(container);

var mc:Sprite = new Sprite();
mc.name = "mc";
mc.graphics.clear();
mc.graphics.beginFill(0xffff00,1);
mc.graphics.drawRect(0, 0, 100, 100);
mc.graphics.endFill();

container.addChild(mc);

TweenLite.to(mc, 2, {transformAroundCenter:{scale:2, rotation:360}, delay:1}); 
TweenLite.delayedCall(0.5, remove)


function remove() {
	container.removeChild(mc); 
}

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock.plugins::TransformAroundPointPlugin/_onInitTween()[/Active/_Flash/_AS3_v12/src/com/greensock/plugins/TransformAroundPointPlugin.as:96]
at com.greensock.plugins::TransformAroundCenterPlugin/_onInitTween()[/Active/_Flash/_AS3_v12/src/com/greensock/plugins/TransformAroundCenterPlugin.as:58]
at com.greensock::TweenLite/_initProps()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:590]
at com.greensock::TweenLite/_init()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:555]
at com.greensock::TweenLite/render()[/Active/_Flash/_AS3_v12/src/com/greensock/TweenLite.as:700]
at com.greensock.core::SimpleTimeline/render()[/Active/_Flash/_AS3_v12/src/com/greensock/core/SimpleTimeline.as:166]
at com.greensock.core::Animation$/_updateRoot()[/Active/_Flash/_AS3_v12/src/com/greensock/core/Animation.as:570]
 

 

I see that delay bigger than start moment. But it is not rare situation too...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...