Solved

Restart actionscript movie

Posted on 2010-09-13
4
382 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now