Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
sti1

loading with local connection and repeating

Recommended Posts

Can´t seem to make this play each time the "my_lc_as2" connect executes - it just plays plays one time. Can someone please help me out here

 

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([MotionBlurPlugin]);
receiving_lc = new LocalConnection();

receiving_lc.execute_this = function(FT2) {
var myTimeline:TimelineLite = new TimelineLite({onComplete:myFunction});
myTimeline.append(new TweenLite(FT, 0.3, { _x:50, _xscale:10, motionBlur:true, ease:yoyo.easeInOut}));
 myTimeline.append(new TweenLite(FT, 0.2, { _x:50, _xscale:10, _rotation:90, motionBlur:true, ease:cubic.easeInOut}));
myTimeline.append(new TweenLite(FT, 0.5, { _x:50, _y:1200, _xscale:100,  motionBlur:true, ease:Cubic.easeInOut}));
}
receiving_lc.connect("my_lc_as2");

function myFunction(){
myTimeline.invalidate();

}

Link to post
Share on other sites

I noticed a few things

 

1: you declare var myTimeline inside a function

 

receiving_lc.execute_this = function(FT2) {
var myTimeline:TimelineLite = new TimelineLite({onComplete:myFunction});
myTimeline.append(new TweenLite(FT, 0.3, { _x:50, _xscale:10, motionBlur:true, ease:yoyo.easeInOut}));
...
}

which means that you can't access it from other functions.

 

try this:

 

 

function myFunction(){
myTimeline.invalidate();
trace("myTimeline = " + myTimeline) // undefined
}

 

you will see that myFunction can't access myTimeline and thus that invalidate() call never happens.

 

Also since you are declaring a new timeline inside that first function everytime you receive a local connection that means that new start values are recorded for each tween. The first time your timeline runs it ends by setting the _y value of your FT to 1200.

 

Every new timeline you create is going to create new tweens. The first new tween that gets created is using _y:1200 because that is where FT currently is. Maybe you just aren't seeing the timeline play because FT is super far offstage. Just a guess.

 

I would suggest that you declare and define your timeline once outside of any functions and then just restart() it each time you get a new local connection

 

something like:

 

 

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([MotionBlurPlugin]);
//create new timeline and pause it
var myTimeline:TimelineLite = new TimelineLite({onComplete:myFunction, paused:true});

myTimeline.append(new TweenLite(FT, 0.3, { _x:50, _xscale:10, motionBlur:true, ease:yoyo.easeInOut}));
 myTimeline.append(new TweenLite(FT, 0.2, { _x:50, _xscale:10, _rotation:90, motionBlur:true, ease:cubic.easeInOut}));
myTimeline.append(new TweenLite(FT, 0.5, { _x:50, _y:1200, _xscale:100,  motionBlur:true, ease:Cubic.easeInOut}));


receiving_lc = new LocalConnection();

receiving_lc.execute_this = function(FT2) {
//restart the existing timeline
myTimeline.restart();
}
receiving_lc.connect("my_lc_as2");

function myFunction(){
//myTimeline.invalidate();
}

 

let us know if this works better for you.

Link to post
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.

×