DownburstX Posted July 7, 2012 Share Posted July 7, 2012 Hi all, I created a cockpit Primary Flight Instrument (airspeed, altitude, pitch, roll), that uses predetermined values (see arrays) to tween the instrument parts towards the corresponding frame. I builded everything first separately and it worked fine. Now I'm combining all the instrument parts in one FLA and after exporting the fla all the tweens are not working correctly. I think because they are all using their own array so they all need their own timeline. However after adding: var SpeedTimeLine:TimelineMax = new TimelineMax({onComplete:doNextSpeed}); and writing this in front of the tweenmax: SpeedTimeLine.insertMultiple( tween.... ); It results in an Error: Error: Cannot tween a null object. at com.greensock::TweenLite() at com.greensock::TweenMax() at com.greensock::TweenMax$/allTo() at pfd_fla::MainTimeline/doNextSpeed() at Function/http://adobe.com/AS3/2006/builtin::apply() at com.greensock.core::TweenCore/complete() at com.greensock::TweenMax/complete() at com.greensock::TweenMax/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll() 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.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll() I have no idea in which direction I need to search for an solution. Searching on error 1009 doesn't make me wiser. Complete code: 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. //speed var SpeedIndicator:Array = [AS.AS_MOVE, AS.AS_MOVE.AS_MOVE_SUBTAPE] var airSpeeds:Array = [27, 63, 98, 130, 166, 208, 246, 276, 310, 350, 389, 420, 456, 486, 518, 552, 585, 620, 654, 686, 719, 750, 780, 811, 842, 872, 901, 931, 958, 988, 1020, 1047, 1070, 1097, 1121, 1142, 1165, 1177, 1189, 1201, 1212, 1222, 1230, 1227, 1221, 1218, 1210, 1207, 1206, 1204, 1204, 1205, 1206, 1209, 1216, 1217, 1213, 1212, 1214, 1215, 1218, 1220, 1229, 1237, 1244, 1251, 1259, 1265, 1269, 1275, 1281, 1286, 1288, 1292, 1299, 1304, 1309, 1312, 1311, 1312, 1317, 1320, 1321, 1322, 1320, 1319, 1314, 1312, 1309, 1306, 1305, 1302, 1303, 1302, 1297, 1293, 1292, 1289, 1280, 1274, 1268, 1263, 1265, 1264, 1264, 1263, 1259, 1258, 1261, 1263, 1260, 1259, 1260, 1261, 1264, 1267, 1270, 1272, 1273, 1274, 1280, 1287, 1294, 1304, 1317, 1330, 1343, 1358, 1379, 1400, 1420, 1440, 1455, 1473, 1491, 1510, 1531, 1551, 1568, 1585, 1602, 1619, 1636, 1653, 1671, 1688, 1706, 1723, 1737, 1751, 1764, 1777, 1789, 1802, 1817, 1831, 1842, 1854, 1865, 1877, 1891, 1906, 1917, 1929, 1944, 1959, 1970, 1982, 1994, 2007, 2022, 2036, 2046, 2056, 2066, 2076, 2086, 2096, 2106, 2117, 2131, 2147, 2160, 2174, 2188, 2203, 2218, 2234, 2255, 2276, 2292, 2307, 2325, 2345, 2364, 2382, 2397, 2410, 2421, 2432, 2444, 2455, 2462, 2466, 2471, 2475, 2481, 2487, 2493, 2498, 2497, 2495, 2497, 2500, 2502, 2502, 2502, 2502, 2502, 2501, 2499, 2494, 2492, 2491, 2489, 2487, 2486, 2488, 2486, 2481, 2477, 2473, 2470, 2464]; var maxSpeed:int = airSpeeds.length - 1; var currentSpeed:int = 0; var SpeedTimeLine:TimelineMax = new TimelineMax({onComplete:doNextSpeed}); function doNextSpeed(){ SpeedTimeLine.insertMultiple(TweenMax.allTo(SpeedIndicator, 0.5, {frame:(airSpeeds[currentSpeed]), ease:Linear.easeNone, onComplete:doNextSpeed})); //increment the value used to get data from airSpeeds array if (currentSpeed < maxSpeed){ currentSpeed++; }else{ trace("speed array finished"); currentSpeed = 0; } } doNextSpeed(); //altitude var altindicator:Array = [AT.AT_MOVE, AT.AT_MOVE.AT_MOVE_SUBTAPE] var altitudes:Array = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 9, 15, 23, 35, 49, 66, 85, 104, 126, 149, 174, 196, 220, 251, 275, 298, 321, 343, 363, 382, 401, 419, 438, 458, 477, 497, 517, 538, 558, 578, 598, 619, 641, 664, 687, 712, 737, 762, 788, 815, 842, 869, 898, 926, 953, 982, 1010, 1040, 1070, 1100, 1130, 1161, 1192, 1224, 1256, 1289, 1322, 1355, 1388, 1422, 1456, 1491, 1525, 1560, 1596, 1632, 1668, 1704, 1739, 1774, 1809, 1842, 1875, 1907, 1938, 1968, 1998, 2027, 2056, 2085, 2114, 2141, 2170, 2198, 2226, 2254, 2282, 2310, 2336, 2358, 2377, 2393, 2407, 2421, 2435, 2446, 2457, 2466, 2471, 2473, 2475, 2476, 2477, 2478, 2479, 2481, 2484, 2489, 2497, 2504, 2509, 2514, 2519, 2523, 2528, 2533, 2538, 2543, 2548, 2554, 2561, 2568, 2576, 2583, 2591, 2598, 2605, 2611, 2619, 2627, 2634, 2643, 2652, 2658, 2668, 2672, 2668, 2664, 2652, 2662, 2671, 2677, 2685, 2692, 2699, 2706, 2710, 2712, 2712, 2709, 2704, 2696, 2685, 2673, 2658, 2642, 2625, 2607, 2573, 2534, 2496, 2462, 2415, 2370, 2328, 2289, 2252, 2219, 2226, 2236, 2238, 2219, 2200, 2183, 2168, 2155, 2145, 2136, 2129, 2130, 2140, 2150, 2158, 2167, 2178, 2172, 2167, 2163, 2178, 2207, 2212, 2225, 2260, 2294, 2328, 2362, 2399, 2425, 2413, 2484, 2530]; var maxAlt:int = altitudes.length - 1; var currentAlt:int = 0; var AltTimeLine:TimelineMax = new TimelineMax({onComplete:doNextAlt}); function doNextAlt(){ AltTimeLine.insertMultiple(TweenMax.allTo(altindicator, 0.5, {frame:(altitudes[currentAlt]), ease:Linear.easeNone, onComplete:doNextAlt})); //increment the value used to get data from airSpeeds array if (currentAlt < maxAlt){ currentAlt++; }else{ trace("finished loop"); currentAlt = 0; } } doNextAlt(); //roll var rollindicator:Array = [AH.AH_PITCH.AH_PITCH_ROLL] var roll:Array = [179, 179, 179, 180, 180, 179, 179, 178, 178, 181, 180, 180, 181, 182, 181, 180, 180, 181, 180, 178, 177, 178, 178, 179, 178, 178, 179, 178, 179, 179, 179, 178, 175, 174, 173, 172, 172, 172, 175, 178, 180, 182, 184, 186, 187, 189, 192, 192, 192, 191, 186, 179, 176, 176, 176, 176, 176, 177, 179, 180, 181, 182, 183, 184, 185, 186, 188, 189, 190, 191, 193, 194, 194, 195, 195, 192, 188, 184, 181, 179, 178, 175, 175, 175, 176, 176, 177, 177, 178, 179, 179, 179, 180, 180, 181, 181, 182, 182, 183, 190, 203, 217, 230, 244, 258, 262, 261, 260, 259, 256, 253, 250, 247, 244, 242, 239, 235, 232, 230, 226, 208, 181, 159, 145, 137, 136, 135, 135, 139, 151, 165, 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, 174, 174, 174, 175, 175, 175, 175, 175, 175, 175, 175, 176, 176, 176, 176, 176, 176, 176, 177, 177, 177, 177, 177, 177, 177, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 179, 168, 145, 123, 101, 78, 61, 58, 53, 47, 40, 34, 27, 21, 17, 16, 16, 16, 16, 16, 16, 16, 16, 14, 13, 11, 10, 9, 7, 6, 4, 3, 1, 1, 8, 33, 59, 82]; // Times 8, plus 180 var maxRoll:int = roll.length - 1; var currentroll:int = 0; var RollTimeLine:TimelineMax = new TimelineMax({onComplete:doNextRoll}); function doNextRoll(){ RollTimeLine.insertMultiple(TweenMax.allTo(rollindicator, 0.5, {frame:(roll[currentroll]), ease:Linear.easeNone, onComplete:doNextRoll})); //increment the value used to get data from pitch array if (currentroll < maxRoll){ currentroll++; }else{ trace("finished loop"); currentroll = 0; } } doNextRoll(); //pitch var PitchIndicator:Array = [AH.AH_PITCH] //AT_MOVE.AT_MOVE_WINDOW.AT_MOVE_WINDOW_XXX, AT_MOVE.AT_MOVE_WINDOW.AT_MOVE_WINDOW_XX var pitch:Array = [386, 386, 385, 387, 386, 385, 385, 384, 384, 389, 388, 389, 388, 387, 388, 388, 389, 387, 387, 387, 387, 386, 387, 387, 385, 389, 393, 400, 433, 445, 452, 456, 465, 467, 477, 493, 500, 514, 511, 519, 526, 528, 533, 538, 543, 530, 529, 529, 524, 522, 514, 508, 506, 509, 509, 510, 511, 512, 512, 513, 513, 514, 516, 517, 519, 521, 524, 526, 526, 527, 529, 530, 533, 535, 537, 534, 534, 535, 537, 540, 542, 544, 547, 546, 549, 551, 553, 555, 557, 558, 560, 561, 562, 563, 565, 566, 567, 568, 570, 568, 567, 565, 562, 559, 556, 553, 551, 547, 545, 545, 543, 542, 541, 540, 539, 538, 538, 538, 537, 538, 516, 504, 487, 472, 465, 466, 452, 450, 442, 436, 431, 428, 428, 426, 424, 423, 424, 426, 428, 430, 432, 431, 428, 428, 427, 426, 425, 425, 425, 425, 426, 427, 428, 429, 430, 430, 429, 427, 426, 424, 422, 420, 418, 417, 415, 414, 414, 413, 413, 413, 413, 413, 414, 415, 416, 418, 417, 414, 407, 402, 396, 390, 385, 380, 375, 370, 366, 363, 359, 358, 357, 356, 356, 356, 356, 359, 366, 372, 377, 383, 388, 393, 398, 402, 405, 408, 411, 413, 415, 417, 419, 421, 422, 423, 425, 426, 428, 429, 430, 431, 433, 434, 435, 436, 437, 437, 438, 438, 438, 438, 440, 441, 444, 446]; // Times 8, + 400 var maxPitch:int = pitch.length - 1; var currentpitch:int = 0; var PitchTimeLine:TimelineMax = new TimelineMax({onComplete:doNextPitch}); function doNextPitch(){ PitchTimeLine.insertMultiple(TweenMax.allTo(PitchIndicator, 0.5, {frame:(pitch[currentpitch]), ease:Linear.easeNone, onComplete:doNextPitch})); //increment the value used to get data from pitch array if (currentpitch < maxPitch){ currentpitch++; }else{ trace("finished loop"); currentpitch = 0; } } doNextPitch(); Link to comment Share on other sites More sharing options...
DownburstX Posted July 7, 2012 Author Share Posted July 7, 2012 I removed the onComplete:doNext from all timelines. Now I'm not getting any errors, however the tweens still don't work correctly. After publishing I see only the first value (speed, alt, roll, pitch) from each array is tweened. Afterwards notting moves, however the trace output keeps saying every 0.5 sec "speed array finished" 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. //speed var SpeedIndicator:Array = [AS.AS_MOVE, AS.AS_MOVE.AS_MOVE_SUBTAPE] var airSpeeds:Array = [27, 63, 98, 130, 166, 208, 246, 276, 310, 350, 389, 420, 456, 486, 518, 552, 585, 620, 654, 686, 719, 750, 780, 811, 842, 872, 901, 931, 958, 988, 1020, 1047, 1070, 1097, 1121, 1142, 1165, 1177, 1189, 1201, 1212, 1222, 1230, 1227, 1221, 1218, 1210, 1207, 1206, 1204, 1204, 1205, 1206, 1209, 1216, 1217, 1213, 1212, 1214, 1215, 1218, 1220, 1229, 1237, 1244, 1251, 1259, 1265, 1269, 1275, 1281, 1286, 1288, 1292, 1299, 1304, 1309, 1312, 1311, 1312, 1317, 1320, 1321, 1322, 1320, 1319, 1314, 1312, 1309, 1306, 1305, 1302, 1303, 1302, 1297, 1293, 1292, 1289, 1280, 1274, 1268, 1263, 1265, 1264, 1264, 1263, 1259, 1258, 1261, 1263, 1260, 1259, 1260, 1261, 1264, 1267, 1270, 1272, 1273, 1274, 1280, 1287, 1294, 1304, 1317, 1330, 1343, 1358, 1379, 1400, 1420, 1440, 1455, 1473, 1491, 1510, 1531, 1551, 1568, 1585, 1602, 1619, 1636, 1653, 1671, 1688, 1706, 1723, 1737, 1751, 1764, 1777, 1789, 1802, 1817, 1831, 1842, 1854, 1865, 1877, 1891, 1906, 1917, 1929, 1944, 1959, 1970, 1982, 1994, 2007, 2022, 2036, 2046, 2056, 2066, 2076, 2086, 2096, 2106, 2117, 2131, 2147, 2160, 2174, 2188, 2203, 2218, 2234, 2255, 2276, 2292, 2307, 2325, 2345, 2364, 2382, 2397, 2410, 2421, 2432, 2444, 2455, 2462, 2466, 2471, 2475, 2481, 2487, 2493, 2498, 2497, 2495, 2497, 2500, 2502, 2502, 2502, 2502, 2502, 2501, 2499, 2494, 2492, 2491, 2489, 2487, 2486, 2488, 2486, 2481, 2477, 2473, 2470, 2464]; var maxSpeed:int = airSpeeds.length - 1; var currentSpeed:int = 0; var SpeedTimeLine:TimelineMax = new TimelineMax(); function doNextSpeed(){ SpeedTimeLine.insertMultiple(TweenMax.allTo(SpeedIndicator, 0.5, {frame:(airSpeeds[currentSpeed]), ease:Linear.easeNone, onComplete:doNextSpeed})); //increment the value used to get data from airSpeeds array if (currentSpeed < maxSpeed){ currentSpeed++; }else{ trace("speed array finished"); currentSpeed = 0; } } doNextSpeed(); //altitude var altindicator:Array = [AT.AT_MOVE, AT.AT_MOVE.AT_MOVE_SUBTAPE] var altitudes:Array = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 5, 9, 15, 23, 35, 49, 66, 85, 104, 126, 149, 174, 196, 220, 251, 275, 298, 321, 343, 363, 382, 401, 419, 438, 458, 477, 497, 517, 538, 558, 578, 598, 619, 641, 664, 687, 712, 737, 762, 788, 815, 842, 869, 898, 926, 953, 982, 1010, 1040, 1070, 1100, 1130, 1161, 1192, 1224, 1256, 1289, 1322, 1355, 1388, 1422, 1456, 1491, 1525, 1560, 1596, 1632, 1668, 1704, 1739, 1774, 1809, 1842, 1875, 1907, 1938, 1968, 1998, 2027, 2056, 2085, 2114, 2141, 2170, 2198, 2226, 2254, 2282, 2310, 2336, 2358, 2377, 2393, 2407, 2421, 2435, 2446, 2457, 2466, 2471, 2473, 2475, 2476, 2477, 2478, 2479, 2481, 2484, 2489, 2497, 2504, 2509, 2514, 2519, 2523, 2528, 2533, 2538, 2543, 2548, 2554, 2561, 2568, 2576, 2583, 2591, 2598, 2605, 2611, 2619, 2627, 2634, 2643, 2652, 2658, 2668, 2672, 2668, 2664, 2652, 2662, 2671, 2677, 2685, 2692, 2699, 2706, 2710, 2712, 2712, 2709, 2704, 2696, 2685, 2673, 2658, 2642, 2625, 2607, 2573, 2534, 2496, 2462, 2415, 2370, 2328, 2289, 2252, 2219, 2226, 2236, 2238, 2219, 2200, 2183, 2168, 2155, 2145, 2136, 2129, 2130, 2140, 2150, 2158, 2167, 2178, 2172, 2167, 2163, 2178, 2207, 2212, 2225, 2260, 2294, 2328, 2362, 2399, 2425, 2413, 2484, 2530]; var maxAlt:int = altitudes.length - 1; var currentAlt:int = 0; var AltTimeLine:TimelineMax = new TimelineMax(); function doNextAlt(){ AltTimeLine.insertMultiple(TweenMax.allTo(altindicator, 0.5, {frame:(altitudes[currentAlt]), ease:Linear.easeNone, onComplete:doNextAlt})); //increment the value used to get data from airSpeeds array if (currentAlt < maxAlt){ currentAlt++; }else{ trace("Alt array finished"); currentAlt = 0; } } doNextAlt(); //roll var rollindicator:Array = [AH.AH_PITCH.AH_PITCH_ROLL] var roll:Array = [179, 179, 179, 180, 180, 179, 179, 178, 178, 181, 180, 180, 181, 182, 181, 180, 180, 181, 180, 178, 177, 178, 178, 179, 178, 178, 179, 178, 179, 179, 179, 178, 175, 174, 173, 172, 172, 172, 175, 178, 180, 182, 184, 186, 187, 189, 192, 192, 192, 191, 186, 179, 176, 176, 176, 176, 176, 177, 179, 180, 181, 182, 183, 184, 185, 186, 188, 189, 190, 191, 193, 194, 194, 195, 195, 192, 188, 184, 181, 179, 178, 175, 175, 175, 176, 176, 177, 177, 178, 179, 179, 179, 180, 180, 181, 181, 182, 182, 183, 190, 203, 217, 230, 244, 258, 262, 261, 260, 259, 256, 253, 250, 247, 244, 242, 239, 235, 232, 230, 226, 208, 181, 159, 145, 137, 136, 135, 135, 139, 151, 165, 172, 172, 172, 172, 172, 172, 173, 173, 173, 173, 173, 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, 174, 174, 174, 175, 175, 175, 175, 175, 175, 175, 175, 176, 176, 176, 176, 176, 176, 176, 177, 177, 177, 177, 177, 177, 177, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 178, 179, 168, 145, 123, 101, 78, 61, 58, 53, 47, 40, 34, 27, 21, 17, 16, 16, 16, 16, 16, 16, 16, 16, 14, 13, 11, 10, 9, 7, 6, 4, 3, 1, 1, 8, 33, 59, 82]; // Times 8, plus 180 var maxRoll:int = roll.length - 1; var currentroll:int = 0; var RollTimeLine:TimelineMax = new TimelineMax(); function doNextRoll(){ RollTimeLine.insertMultiple(TweenMax.allTo(rollindicator, 0.5, {frame:(roll[currentroll]), ease:Linear.easeNone, onComplete:doNextRoll})); //increment the value used to get data from pitch array if (currentroll < maxRoll){ currentroll++; }else{ trace("Roll array finished"); currentroll = 0; } } doNextRoll(); //pitch var PitchIndicator:Array = [AH.AH_PITCH] //AT_MOVE.AT_MOVE_WINDOW.AT_MOVE_WINDOW_XXX, AT_MOVE.AT_MOVE_WINDOW.AT_MOVE_WINDOW_XX var pitch:Array = [386, 386, 385, 387, 386, 385, 385, 384, 384, 389, 388, 389, 388, 387, 388, 388, 389, 387, 387, 387, 387, 386, 387, 387, 385, 389, 393, 400, 433, 445, 452, 456, 465, 467, 477, 493, 500, 514, 511, 519, 526, 528, 533, 538, 543, 530, 529, 529, 524, 522, 514, 508, 506, 509, 509, 510, 511, 512, 512, 513, 513, 514, 516, 517, 519, 521, 524, 526, 526, 527, 529, 530, 533, 535, 537, 534, 534, 535, 537, 540, 542, 544, 547, 546, 549, 551, 553, 555, 557, 558, 560, 561, 562, 563, 565, 566, 567, 568, 570, 568, 567, 565, 562, 559, 556, 553, 551, 547, 545, 545, 543, 542, 541, 540, 539, 538, 538, 538, 537, 538, 516, 504, 487, 472, 465, 466, 452, 450, 442, 436, 431, 428, 428, 426, 424, 423, 424, 426, 428, 430, 432, 431, 428, 428, 427, 426, 425, 425, 425, 425, 426, 427, 428, 429, 430, 430, 429, 427, 426, 424, 422, 420, 418, 417, 415, 414, 414, 413, 413, 413, 413, 413, 414, 415, 416, 418, 417, 414, 407, 402, 396, 390, 385, 380, 375, 370, 366, 363, 359, 358, 357, 356, 356, 356, 356, 359, 366, 372, 377, 383, 388, 393, 398, 402, 405, 408, 411, 413, 415, 417, 419, 421, 422, 423, 425, 426, 428, 429, 430, 431, 433, 434, 435, 436, 437, 437, 438, 438, 438, 438, 440, 441, 444, 446]; // Times 8, + 400 var maxPitch:int = pitch.length - 1; var currentpitch:int = 0; var PitchTimeLine:TimelineMax = new TimelineMax(); function doNextPitch(){ PitchTimeLine.insertMultiple(TweenMax.allTo(PitchIndicator, 0.5, {frame:(pitch[currentpitch]), ease:Linear.easeNone, onComplete:doNextPitch})); //increment the value used to get data from pitch array if (currentpitch < maxPitch){ currentpitch++; }else{ trace("Pitch array finished"); currentpitch = 0; } } doNextPitch(); Link to comment Share on other sites More sharing options...
Carl Posted July 8, 2012 Share Posted July 8, 2012 When getting null object errors the best thing you can do is to start tracing every object that you are trying to tween trace(AS.AS_MOVE); trace(AS.AS_MOVE.AS_MOVE_SUBTAPE) etc. do any of those report null? also you stated that you removed onComplete:doNextSpeed from all timelines but then you posted code that had: SpeedTimeLine.insertMultiple(TweenMax.allTo(SpeedIndicator, 0.5, {frame:(airSpeeds[currentSpeed]), ease:Linear.easeNone, onComplete:doNextSpeed})); its very difficult for us to troubleshoot a null object error. please verify that all the objects you are trying to tween are accessible. Something is still calling doNextSpeed if you get traces of "speed array finished" Also, inside doNextSpeed put: trace(currentSpeed + " : " maxSpeed) to see why currentSpeed is always > maxSpeed 1 Link to comment Share on other sites More sharing options...
DownburstX Posted July 8, 2012 Author Share Posted July 8, 2012 Thanks for the quick reply. Somehow I don't get errors anymore, however the tween still doesn't work. I isolated that airspeed code into a seperate fla to make it easier and check if that worked. Without any timeline the tweens work perfect and it tweens every 0.5 second to the new speed value from the array. However after adding a TimelineMax (SpeedTimeLine) into the code it only tweens towards the first speed from the array. After this it's not tweening anymore, or maybe continues to tween towards the same value so I'm not seeing anything. Since I want to use 4 different instrument tweens I need 4 different timelines within the same frame. So my current problem is that after adding the TimelineMax (SpeedTimeLine) the airspeed value from the array (airSpeeds) is not updating anymore. So sorry for changing the actual problem, but hopefully you know why it's not refreshing the speed value anymore with a timeline. I'n not permitted to upload the FLA itself, so here are the codes (without and with timeline): AS without timeline: 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. //speed var SpeedIndicator:Array = [ASC_TAPE] var airSpeeds:Array = [27, 63, 98, 130, 166, 208, 246, 276, 310, 350, 389, 420, 456, 486, 518, 552, 585, 620, 654, 686, 719, 750, 780, 811, 842, 872, 901, 931, 958, 988, 1020, 1047, 1070, 1097, 1121, 1142, 1165, 1177, 1189, 1201, 1212, 1222, 1230, 1227, 1221, 1218, 1210, 1207, 1206, 1204, 1204, 1205, 1206, 1209, 1216, 1217, 1213, 1212, 1214, 1215, 1218, 1220, 1229, 1237, 1244, 1251, 1259, 1265, 1269, 1275, 1281, 1286, 1288, 1292, 1299, 1304, 1309, 1312, 1311, 1312, 1317, 1320, 1321, 1322, 1320, 1319, 1314, 1312, 1309, 1306, 1305, 1302, 1303, 1302, 1297, 1293, 1292, 1289, 1280, 1274, 1268, 1263, 1265, 1264, 1264, 1263, 1259, 1258, 1261, 1263, 1260, 1259, 1260, 1261, 1264, 1267, 1270, 1272, 1273, 1274, 1280, 1287, 1294, 1304, 1317, 1330, 1343, 1358, 1379, 1400, 1420, 1440, 1455, 1473, 1491, 1510, 1531, 1551, 1568, 1585, 1602, 1619, 1636, 1653, 1671, 1688, 1706, 1723, 1737, 1751, 1764, 1777, 1789, 1802, 1817, 1831, 1842, 1854, 1865, 1877, 1891, 1906, 1917, 1929, 1944, 1959, 1970, 1982, 1994, 2007, 2022, 2036, 2046, 2056, 2066, 2076, 2086, 2096, 2106, 2117, 2131, 2147, 2160, 2174, 2188, 2203, 2218, 2234, 2255, 2276, 2292, 2307, 2325, 2345, 2364, 2382, 2397, 2410, 2421, 2432, 2444, 2455, 2462, 2466, 2471, 2475, 2481, 2487, 2493, 2498, 2497, 2495, 2497, 2500, 2502, 2502, 2502, 2502, 2502, 2501, 2499, 2494, 2492, 2491, 2489, 2487, 2486, 2488, 2486, 2481, 2477, 2473, 2470, 2464]; var maxSpeed:int = airSpeeds.length - 1; var currentSpeed:int = 0; var SpeedTimeLine:TimelineMax = new TimelineMax(); function doNextSpeed(){ TweenMax.allTo(SpeedIndicator, 0.5, {frame:(airSpeeds[currentSpeed]), ease:Linear.easeNone, onComplete:doNextSpeed}); trace(currentSpeed); trace(maxSpeed) //increment the value used to get data from airSpeeds array if (currentSpeed < maxSpeed){ currentSpeed++; }else{ trace("speed array finished"); currentSpeed = 0; } } doNextSpeed(); AS with timeline 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. //speed var SpeedIndicator:Array = [ASC_TAPE] var airSpeeds:Array = [27, 63, 98, 130, 166, 208, 246, 276, 310, 350, 389, 420, 456, 486, 518, 552, 585, 620, 654, 686, 719, 750, 780, 811, 842, 872, 901, 931, 958, 988, 1020, 1047, 1070, 1097, 1121, 1142, 1165, 1177, 1189, 1201, 1212, 1222, 1230, 1227, 1221, 1218, 1210, 1207, 1206, 1204, 1204, 1205, 1206, 1209, 1216, 1217, 1213, 1212, 1214, 1215, 1218, 1220, 1229, 1237, 1244, 1251, 1259, 1265, 1269, 1275, 1281, 1286, 1288, 1292, 1299, 1304, 1309, 1312, 1311, 1312, 1317, 1320, 1321, 1322, 1320, 1319, 1314, 1312, 1309, 1306, 1305, 1302, 1303, 1302, 1297, 1293, 1292, 1289, 1280, 1274, 1268, 1263, 1265, 1264, 1264, 1263, 1259, 1258, 1261, 1263, 1260, 1259, 1260, 1261, 1264, 1267, 1270, 1272, 1273, 1274, 1280, 1287, 1294, 1304, 1317, 1330, 1343, 1358, 1379, 1400, 1420, 1440, 1455, 1473, 1491, 1510, 1531, 1551, 1568, 1585, 1602, 1619, 1636, 1653, 1671, 1688, 1706, 1723, 1737, 1751, 1764, 1777, 1789, 1802, 1817, 1831, 1842, 1854, 1865, 1877, 1891, 1906, 1917, 1929, 1944, 1959, 1970, 1982, 1994, 2007, 2022, 2036, 2046, 2056, 2066, 2076, 2086, 2096, 2106, 2117, 2131, 2147, 2160, 2174, 2188, 2203, 2218, 2234, 2255, 2276, 2292, 2307, 2325, 2345, 2364, 2382, 2397, 2410, 2421, 2432, 2444, 2455, 2462, 2466, 2471, 2475, 2481, 2487, 2493, 2498, 2497, 2495, 2497, 2500, 2502, 2502, 2502, 2502, 2502, 2501, 2499, 2494, 2492, 2491, 2489, 2487, 2486, 2488, 2486, 2481, 2477, 2473, 2470, 2464]; var maxSpeed:int = airSpeeds.length - 1; var currentSpeed:int = 0; var SpeedTimeLine:TimelineMax = new TimelineMax(); function doNextSpeed(){ SpeedTimeLine.insertMultiple(TweenMax.allTo(SpeedIndicator, 0.5, {frame:(airSpeeds[currentSpeed]), ease:Linear.easeNone, onComplete:doNextSpeed})); trace(currentSpeed); trace(maxSpeed) //increment the value used to get data from airSpeeds array if (currentSpeed < maxSpeed){ currentSpeed++; }else{ trace("speed array finished"); currentSpeed = 0; } } doNextSpeed(); Link to comment Share on other sites More sharing options...
Carl Posted July 8, 2012 Share Posted July 8, 2012 Might have a problem since you are using the same insertMultiple() call over and over. insertMultiple will add multiple tweens to the beginning of the timeline (unless you specify a time parameter). So each time doNextSpeed() runs you are adding more and more tweens (on the same objects) to the beginning of the timeline. most likely those tweens aren't playing because the timeline's playhead is at the end of the timeline. After inserting the new tweens at the beginning you will also have to restart() the timeline (drive the playhead back to the beginning). I think you probably meant to be using appendMultiple() which will add the new tweens to the end of the timeline. 1 Link to comment Share on other sites More sharing options...
DownburstX Posted July 8, 2012 Author Share Posted July 8, 2012 You're completely right, now it works like charm! PS: Once I finished the instrument, is there a place to to share my project source so other people can use my work? (Since I'm not permitted to upload Fla's). Sharing is caring . Without other people's help (like you) I wouldn't be able to do my thesis experiment. Might have a problem since you are using the same insertMultiple() call over and over. insertMultiple will add multiple tweens to the beginning of the timeline (unless you specify a time parameter). So each time doNextSpeed() runs you are adding more and more tweens (on the same objects) to the beginning of the timeline. most likely those tweens aren't playing because the timeline's playhead is at the end of the timeline. After inserting the new tweens at the beginning you will also have to restart() the timeline (drive the playhead back to the beginning). I think you probably meant to be using appendMultiple() which will add the new tweens to the end of the timeline. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now