Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 408
  • Last Modified:

Restart actionscript movie

Hello

I have been building an actionscript2 movie and as i'm a novice i've got a bit stuck, I'm using setTime to bring in elements of the movie and when the last element has entered I need the movie to start again, it's all done in frame 1. Any help would be great!! I've attached my script.
stop();

import mx.transitions.Tween;
import mx.transitions.easing.*;

setTimeout(this, "movieenter1", 0000);
setTimeout(this, "cog1enter", 1000);
setTimeout(this, "cog2enter", 1000);
setTimeout(this, "cog3enter", 1000);
setTimeout(this, "current_text", 2000);
setTimeout(this, "current_text_exit", 19000);
setTimeout(this, "sim_text", 9000);
setTimeout(this, "crm_text", 11000);
setTimeout(this, "comp_text", 13000);
setTimeout(this, "sim_text_exit", 17000);
setTimeout(this, "crm_text_exit", 17000);
setTimeout(this, "comp_text_exit", 17000);
setTimeout(this, "bar_movie", 8000);
setTimeout(this, "bar_movie_exit", 19000);
setTimeout(this, "bar2_movie", 20000);


function movieenter1() {
        easeType = mx.transitions.easing.Back.easeOut;
        var begin = 120;
        var end = 55;
        var time = .8;
        var mc = movie1;
        barTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);
		barTween = new mx.transitions.Tween(mc, "_alpha", Regular.easeOut, 10, 100, 8, true);
		var xScaleT:Tween = new Tween(mc, "_xscale", Strong.easeOut, 105, 110, 30, true); 
		var yScaleT:Tween = new Tween(mc, "_yscale", Strong.easeOut, 105, 110, 30, true);
}

function bar_movie() {
var xPosT:Tween = new Tween(barmovie, "_x", Regular.easeOut, 2, Stage.width / 2, 1, true);
var xScaleT:Tween = new Tween(barmovie, "_xscale", Strong.easeOut, 0, 130, 3, true); 
var yScaleT:Tween = new Tween(barmovie, "_yscale", Strong.easeOut, 0, 230, 3, true);
}
function bar_movie_exit() {
var xPosT:Tween = new Tween(barmovie, "_x", Regular.easeOut, 2, Stage.width / 2, 1, true);
var xScaleT:Tween = new Tween(barmovie, "_xscale", Strong.easeOut, 130, 0, 3, true); 
var yScaleT:Tween = new Tween(barmovie, "_yscale", Strong.easeOut, 230, 0, 3, true);
}
function bar2_movie() {
easeType = mx.transitions.easing.Back.easeOut;
        var begin = -120;
        var end = 58;
        var time = .8;
        var mc = bar2movie;
        barTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);

		}

function current_text() {
        easeType = mx.transitions.easing.Back.easeOut;
        var begin = 200;
        var end = 126;
        var time = .8;
        var mc = current;
        barTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);
var xPosT:Tween = new Tween(current, "_x", Elastic.easeOut, 0, Stage.width / 2, 3, true);
var xScaleT:Tween = new Tween(current, "_xscale", Strong.easeOut, 0, 40, 20, true); 
var yScaleT:Tween = new Tween(current, "_yscale", Strong.easeOut, 0, 40, 20, true);
}
function current_text_exit() {
	var mc = current;
		barTween = new mx.transitions.Tween(mc, "_alpha", Regular.easeOut, 100, 0, 3, true);
     
}
function sim_text() {
	
 easeType = mx.transitions.easing.Back.easeOut;
        var begin = 200;
        var end = 85;
        var time = .8;
        var mc = simtext;
        barTween = new mx.transitions.Tween(mc, "_x", easeType, begin, end, time, true);
		barTween = new mx.transitions.Tween(mc, "_alpha", Strong.easeOut, 0, 100, 4, true);

}
function sim_text_exit() {
        var mc = simtext;
		barTween = new mx.transitions.Tween(mc, "_alpha", Regular.easeOut, 100, 0, 3, true);
		var xScaleT:Tween = new Tween(mc, "_xscale", Regular.easeOut, 100, 300, 2, true); 
		var yScaleT:Tween = new Tween(mc, "_yscale", Regular.easeOut, 100, 300, 2, true);
}
function crm_text() {
	
 easeType = mx.transitions.easing.Back.easeOut;
        var begin = 200;
        var end = 75;
        var time = .8;
        var mc2 = crmtext;
        barTween = new mx.transitions.Tween(mc2, "_x", easeType, begin, end, time, true);

}
function crm_text_exit() {
	
        var mc2 = crmtext;
		barTween = new mx.transitions.Tween(mc2, "_alpha", Regular.easeOut, 100, 0, 3, true);
		var xScaleT:Tween = new Tween(mc2, "_xscale", Regular.easeOut, 100, 300, 2, true); 
		var yScaleT:Tween = new Tween(mc2, "_yscale", Regular.easeOut, 100, 300, 2, true);
}
function comp_text() {
	
 easeType = mx.transitions.easing.Back.easeOut;
        var begin = 200;
        var end = 57;
        var time = .8;
        var mc3 = comptext;
        barTween = new mx.transitions.Tween(mc3, "_x", easeType, begin, end, time, true);

}
function comp_text_exit() {
		var mc3 = comptext;
		barTween = new mx.transitions.Tween(mc3, "_alpha", Regular.easeOut, 100, 0, 3, true);
		var xScaleT:Tween = new Tween(mc3, "_xscale", Regular.easeOut, 100, 300, 2, true); 
		var yScaleT:Tween = new Tween(mc3, "_yscale", Regular.easeOut, 100, 300, 2, true);
}



	
	function cog1enter() {
        easeType = mx.transitions.easing.Back.easeOut;
        var begin = 60;
        var end = 60;
        var time = .8;
        var mc1 = cog1;
        barTween = new mx.transitions.Tween(mc1, "_x", easeType, begin, end, time, true);
		barTween = new mx.transitions.Tween(mc1, "_alpha", Regular.easeOut, 0, 40, 8, true);
		var RotateT:Tween = new Tween(mc1, "_rotation", Strong.easeOut, 0, 720, 30, true); 
		var xScaleT:Tween = new Tween(mc1, "_xscale", Strong.easeOut, 100, 110, 30, true); 
var yScaleT:Tween = new Tween(mc1, "_yscale", Strong.easeOut, 100, 110, 30, true);
}
	function cog2enter() {
        easeType = mx.transitions.easing.Back.easeOut;
        var begin = 45;
        var end = 45;
        var time = .8;
        var mc2 = cog2;
        barTween = new mx.transitions.Tween(mc2, "_x", easeType, begin, end, time, true);
		barTween = new mx.transitions.Tween(mc2, "_alpha", Regular.easeOut, 0, 50, 8, true);
		var RotateT:Tween = new Tween(mc2, "_rotation", Strong.easeOut, 0, 1220, 50, true); 
		var xScaleT:Tween = new Tween(mc2, "_xscale", Strong.easeOut, 100, 110, 30, true); 
var yScaleT:Tween = new Tween(mc2, "_yscale", Strong.easeOut, 100, 110, 30, true);
}
	function cog3enter() {
        easeType = mx.transitions.easing.Back.easeOut;
        var begin = 85;
        var end = 85;
        var time = .8;
        var mc3 = cog3;
        barTween = new mx.transitions.Tween(mc3, "_x", easeType, begin, end, time, true);
		barTween = new mx.transitions.Tween(mc3, "_alpha", Regular.easeOut, 0, 40, 8, true);
		var RotateT:Tween = new Tween(mc3, "_rotation", Strong.easeOut, 0, 360, 50, true); 
		var xScaleT:Tween = new Tween(mc3, "_xscale", Strong.easeOut, 100, 110, 30, true); 
var yScaleT:Tween = new Tween(mc3, "_yscale", Strong.easeOut, 100, 110, 30, true);
}

Open in new window

0
Skycapt
Asked:
Skycapt
  • 2
  • 2
1 Solution
 
Antonio EstradaTech Leader / Senior Web DeveloperCommented:
Haven't tried this, 'cause creating the environment could prove to be tough (if you attach your fla this would be easier), but this might be the solution. This creates an interesting loop that should work, but otherwise we might have to try a different approach (like, not using setTimeout at all).

<code>

-V
stop();

import mx.transitions.Tween;
import mx.transitions.easing.*;

setTimeouts();

function setTimeouts():Void {
  setTimeout(this, "movieenter1", 0000);
  setTimeout(this, "cog1enter", 1000);
  setTimeout(this, "cog2enter", 1000);
  setTimeout(this, "cog3enter", 1000);
  setTimeout(this, "current_text", 2000);
  setTimeout(this, "current_text_exit", 19000);
  setTimeout(this, "sim_text", 9000);
  setTimeout(this, "crm_text", 11000);
  setTimeout(this, "comp_text", 13000);
  setTimeout(this, "sim_text_exit", 17000);
  setTimeout(this, "crm_text_exit", 17000);
  setTimeout(this, "comp_text_exit", 17000);
  setTimeout(this, "bar_movie", 8000);
  setTimeout(this, "bar_movie_exit", 19000);
  setTimeout(this, "bar2_movie", 20000);
  setTimeout(this, "setTimeouts", 25000);
}

function movieenter1() {
//... etc, all the other stuff follows

Open in new window

0
 
SkycaptAuthor Commented:
Hi Vulturous, thanks for the help.

I see what your trying to do with the loop, It does restart the animation however not all the functions seem to restart and it overlaps in an odd way. I think if there was a way to reset all the functions as it finished then your solution would work.

I've added my flash file for you. Still a bit raw i'm afraid
120-600-sky.fla
0
 
SkycaptAuthor Commented:
okay, all I did was to reset any animation functions such as alpha or scale back to the original state before the animation played again, that way when it restarted everything was in the right order. then it played correctly, probably not the best way around it but it works.
0
 
Antonio EstradaTech Leader / Senior Web DeveloperCommented:
I assumed something like that could happen, that's why I needed the fla :P

Anyway, glad you got it sorted, I'll keep monitoring this question just in case you need anything else.

-V
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now