Jump to content
Search Community

Tweening freeze

Luigi Vercotti test
Moderator Tag

Recommended Posts

Hello

What do you thing could be the problem.

I've got on different frames buttons when I click one of them the tweening the tweening shows up.

The problem is: when I click button tweening shows up pretty fine but when I click another button DURING the tweening the next tweening crash/freeze.

When I wait for tweening to finish it works fine, the problem is only during the tweening...

???

Link to comment
Share on other sites

Ok, I managed to something, but now it does only with one tweening

logoAB.alpha=0;
logoFerrit.alpha=0;
logoSkv.alpha=0;
logoPharmax.alpha=0;
logoMladez2.alpha=0;
logoGR.alpha=0;
logoZTPM.alpha=0;

function sponsorPic(e:Event):void {
logoAB.alpha=1;
logoFerrit.alpha=1;
logoSkv.alpha=1;
logoPharmax.alpha=1;
logoMladez2.alpha=1;
logoGR.alpha=1;
logoZTPM.alpha=1;
var timeline:TimelineLite = new TimelineLite();
var logoPics:Array=[logoAB,logoFerrit,logoSkv,logoPharmax,logoMladez2,logoGR,logoZTPM];
var i:Number=Pics.length;
while (i--) {
	timeline.insert( TweenLite.from(logoPics[i], 1, {x:460,y:360, rotationZ:Math.random() * 360, rotationY:Math.random() * 360, rotationX:Math.random() * 360, alpha:0}), i * 0.1);
}
}

I click a button and it goes to this frame and here is the code at that frame

contactRadekPic.visible=false;
function contactPic(e:Event):void {

contactRadekPic.visible=true;
var timeline:TimelineLite = new TimelineLite();
var Pics:Array=[contactRadekPic.radekContact01,contactRadekPic.radekContact02,contactRadekPic.radekContact10,contactRadekPic.radekContact16,contactRadekPic.radekContact08,contactRadekPic.radekContact13,contactRadekPic.radekContact05,contactRadekPic.radekContact055,contactRadekPic.radekContact15,contactRadekPic.radekContact04,contactRadekPic.radekContact14,contactRadekPic.radekContact12,contactRadekPic.radekContact06,contactRadekPic.radekContact09,contactRadekPic.radekContact03,contactRadekPic.radekContact11,contactRadekPic.radekContact07];
var i:Number=Pics.length;
while (i--) {
	timeline.insert( TweenLite.from(Pics[i], 1, {y:10, rotationZ:Math.random() * 360, rotationY:Math.random() * 360, rotationX:Math.random() * 360, alpha:0, onComplete:contactFrame}), i * 0.1);
}
}

contactMain.alpha=0;
function contactFrame() {
//contactMain.visible=true;
var contactTxtMc:TimelineLite = new TimelineLite();
contactTxtMc.insert(TweenMax.fromTo(contactMain, .8, {alpha:0, scaleX:0, scaleY:0},{alpha:1, scaleX:1, scaleY:.09}));
contactTxtMc.append(TweenMax.to(contactMain, .8, {scaleY:1, ease:Elastic.easeOut}));
}

This works perfect....BUT...when I click the button (with the code above, function sponsorPic()) before the tweening finish (this code here) the tweening above just freeze :cry:

here is the Error code

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.greensock::TweenLite/init()
at com.greensock::TweenMax/init()
at com.greensock::TweenMax/renderTime()
at com.greensock::TimelineLite/forceChildrenToEnd()
at com.greensock::TimelineLite/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()

What do you thing? What am I doing wrong? Please :roll:

Link to comment
Share on other sites

You must be tweening a null object, like the target doesn't exist. You can add a trace() right before your tweens to see which object is null (trace() each target). And if you are skipping to another frame where the object doesn't exist on the MovieClip timeline, that could be your problem too. It's VERY difficult to troubleshoot without seeing an example FLA and being able to publish it and see exactly what you're talking about. If you're still having trouble, please post a simplified FLA that isolates the issue so we can see it in action.

Link to comment
Share on other sites

Yeah, as I suspected, you've got your objects positioned on the MovieClip timeline in such a way that they exist in some places and not others. Like if I click the contactButton you have it skipping ahead to the "contactButton" label on the MovieClip timeline where contactRadekPic exists and you start tweening objects inside of it. But then if I click the sponsorButton, it skips to the "sponsorButton" label on the MovieClip timeline where contactRadekPic does NOT exist anymore, so the tweens that are trying to affect properties inside contactRadekPic are suddenly unable to do so because those objects no longer exist!

 

Also, be very careful about using from() tweens because they always use the current values as end values (as they should) but if your app's logic allows those properties to be changed at other times or the tween to be re-created, you might run into logic problems. For example, if I click your "contactButton", the objects start animating fine, but if I click the button AGAIN (before those tweens finished), new from() tweens are created and use the CURRENT values as end values, meaning the flying pieces will never reach the end state that you intended. That's not a weakness or bug in TweenLite/Max - it's just a logic issue with your code. You can reposition the objects randomly and then tween to consistent end values with to() tweens instead. Or create one TimelineLite instances initially that you just restart() or play()/reverse() whenever you want.

Link to comment
Share on other sites

Thank you very much Greensock :);)

I will have to read you reply few times over so I can fully understand it. :) Generally I think I understand you. I know mostly my problem is that I am working with frames which lots of people say to me don't you use it. Probably they are right. I will start working on it later today.

Thanks ;)

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...