Solved

Restart actionscript movie

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to Display MP4 Video 5 307
How to put actionscript code for a button? 6 118
black magic design 1 125
Actionscript in Flash 3 47
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…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

896 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

15 Experts available now in Live!

Get 1:1 Help Now