Solved

Restart actionscript movie

Posted on 2010-09-13
4
392 Views
Last Modified: 2012-05-10
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
Comment
Question by:Skycapt
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 total points
ID: 33669246
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
 
LVL 1

Author Comment

by:Skycapt
ID: 33669975
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
 
LVL 1

Author Closing Comment

by:Skycapt
ID: 33673219
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
 
LVL 18

Expert Comment

by:Antonio Estrada
ID: 33673892
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

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question