Jump to content
GreenSock

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

Nestled movieclips & updating variable

Recommended Posts

Great stuff from GreenSock!

For my MSc thesis i'm building an interactive experiment. I want to proof that pilots perform better with my improved cockpit primary flight display design. Therefore I'm animating different flight scenario's with the current display and my improved version. Using the flight simulator X-plane I generated data of i.e. the airspeed in an array that is updated every second. Same for altitude, roll, pitch (but I'll try to explain my problem with the airspeed indicator part. The airspeed indicator is designed that it will play from 0% to 100% (0 tot 200 knots) over 200 frames. With a TweenMax.to command I can now easily give the airspeed indicator the command to go to 150 knots by setting the variable AIRSPEED = 150. This works great and really saves me years of manual programming.

 

The problem is that the airspeed indicator is not just a simple rotating arrow, but build up out of 10 nested movie clips that all go from 0% to 100% over 200 frames.

 

Example of the movieclip (and instance names) structure:

 

Scene 1

- AS (MC where I want the actionscript in frame1)

- AS_VERTICAL

- AS_VERTICAL_SUBTAPE

 

I got a lot more nestled movieclips, but writing them all down doesn't make it simpler.

Using the actionscript below which is in frame 1 of AS the tween works correct. However I also want to immidiatly control the underlying movieclips with the same AIRSPEED variable. Putting the multiple MC between brackets doesn't work [AS_VERTICAL, AS_VERTICAL.AS_VERTICAL_SUBTAPE]. However if I only put one of the two in the script it works. var arrays also don't work...

 

Actionscript

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.TweenMax;
import com.greensock.TimelineMax;
import com.greensock.plugins.*;

TweenPlugin.activate([FramePlugin]); //activation is permanent in the SWF, so this line only needs to be run once.
var AIRSPEED:int;
AIRSPEED = 150;
function repeating():void {
var speedmovingtimeline:TimelineMax = new TimelineMax({onComplete:repeating});
speedmovingtimeline.insert(TweenMax.to(AS_VERTICAL, 2,  {frame:AIRSPEED, ease:Quad.easeInOut, yoyo:false}) );
}
repeating();

 

 

That was the first problem. The timelineMax script is repeating it self and right know reloading the same variable again and again. I want to put a pre-generated list of airspeed values (extracted from X-Plane) somewhere in actionscript. And the AIRSPEED variable reads every second the next airspeed value from that list. THis is not specifically Tween related, but I have no clue :oops: . I also have the feeling that, once a tweenMax.to has loaded a variable it keeps on using it (caching).

 

 

airspeed parameters from x-plane (1sec intervals) example:

120
123
126
129
134
138
143
148
153
160
170

 

Sorry for my two questions in one topic.

Link to comment
Share on other sites

are you using v11 or v12 of the platform?

 

v11 allows you to tween multiple objects with TweenMax.allTo();

http://www.greensock.com/as/docs/tween/com/greensock/TweenMax.html#allTo()

 

v12 Beta now allows the tweening of multiple objects with a basic TweenLite.to();

http://api.greensock.com/as/com/greensock/TweenLite.html#to()

 

either way you should be able to tween multiple clips with 1 tween.

knowing what version you are using will help us provide a better solution.

 

thx

 

c

Link to comment
Share on other sites

attached is an example (cs4 fla and swf) that will tween 4 objects to new values on each repeat.

code available for v11 or v12.

 

 

 

 

var mcs:Array = [mc1, mc2, mc3, mc4]
var airSpeeds:Array = [500, 200, 300, 100, 400, 0];
var maxSpeed:int = airSpeeds.length - 1;

var current:int = 0;

function doNextTween(){

//v11 TweenMax.allTo(mcs, 1, {width:airSpeeds[current], onComplete:doNextTween});

//v12 tween below:
TweenLite.to(mcs, 1, {width:airSpeeds[current], onComplete:doNextTween});

//increment the value used to get data from airSpeeds array
if (current < maxSpeed){
  current++;
}else{
  trace("all done, back to the beginning");
  current = 0;
  }
}

doNextTween(); 

 

This is just a basic implementation. Typically we don't go too far beyond offering general GreenSock-related support, but this seems like an interesting project. If you need to learn more about arrays and conditional statements:

 

http://www.republicofcode.com/tutorials/flash/as3arrays/

http://www.republicofcode.com/tutorials/flash/as3conditionals/

 

c

tweenMultipleMCs.fla.zip

  • Like 2
Link to comment
Share on other sites

Many thanks. I'm going to try the examples this weekend. Will give an update when it works.

Really stupid, but I can't find anywhere which version I'm using. The greensock-as3.zip is modified at 26 April 2012 and it doesn't says v12, so I guess it's V11.

 

:)

Link to comment
Share on other sites

are you using v11 or v12 of the platform?

 

v11 allows you to tween multiple objects with TweenMax.allTo();

http://www.greensock...Max.html#allTo()

 

v12 Beta now allows the tweening of multiple objects with a basic TweenLite.to();

http://api.greensock...enLite.html#to()

 

either way you should be able to tween multiple clips with 1 tween.

knowing what version you are using will help us provide a better solution.

 

thx

 

c

 

Got the first part working. The problem was not the TweenMax.allTo, but after calling the TimelineMax variable I forgot to write 'insertMultiple' instead of 'insert'. So now the MC inside MC works. Going to work on the second part now :)

Link to comment
Share on other sites

Array with speeds also working like charm!! Thank you so much. This is definitely going to speed up my thesis experiment animation process. I only had to change 'width' to 'frame' in order to go to a frame instead of a width. Now I can copy and paste a CSV with speed parameters from X-plane flight simulator and simulate realistic airspeeds on the Primary Flight Display. (as well as altitude, roll, and pitch).

 

I will give an update when finishing the final animations.

 

attached is an example (cs4 fla and swf) that will tween 4 objects to new values on each repeat.

code available for v11 or v12.

 

 

 

 

var mcs:Array = [mc1, mc2, mc3, mc4]
var airSpeeds:Array = [500, 200, 300, 100, 400, 0];
var maxSpeed:int = airSpeeds.length - 1;

var current:int = 0;

function doNextTween(){

//v11 TweenMax.allTo(mcs, 1, {width:airSpeeds[current], onComplete:doNextTween});

//v12 tween below:
TweenLite.to(mcs, 1, {width:airSpeeds[current], onComplete:doNextTween});

//increment the value used to get data from airSpeeds array
if (current < maxSpeed){
  current++;
}else{
  trace("all done, back to the beginning");
  current = 0;
  }
}

doNextTween(); 

 

This is just a basic implementation. Typically we don't go too far beyond offering general GreenSock-related support, but this seems like an interesting project. If you need to learn more about arrays and conditional statements:

 

http://www.republico...lash/as3arrays/

http://www.republico...s3conditionals/

 

c

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