?
Solved

Delay

Posted on 2003-03-24
12
Medium Priority
?
309 Views
Last Modified: 2010-04-03
Can anyone tell me if there is a way to delay the script such as this:

onClipEvent (load) {
     play();
     delay (50 seconds, true)
     stop();
}

im looking for a code and not an answer to this specific problem I want to use it alot, any help would be appreciated.
0
Comment
Question by:grantunwin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
12 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 8198181
there is no code in Flash to do this directly, but there are at least three work-a-rounds for creating a timed delay...

1. use a looping movieclip that increments a variable, and when the variable reaches a specific number, an action happens.

2. using the getTimer(); code and doing a bunch of complicated actionscript

3. call a javascript function on the html page that uses setTimeout() for a delay and pass the variable back into the movie...


I personally use the first solution, because it is simple and works perfectly for what I what...  


I am not sure why Macromedia did not include a setTimeout() function in MX, because it would be used constantly, and would get rid of this headache...

you would think a timeline based application would have a delay() function for simple coding purposes...  


rp

0
 
LVL 5

Expert Comment

by:stef4s
ID: 8201346
can I send u a fla?
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 8204446
Yes I do agree with you rascalpants , I was wondering the same thing lately why Macromedia did not added setTimeout to their library. But They did Add 'setInterval'. I did not do any research on setInterval but I am sure it has somthing to do with time Delay's.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
stef4s earned 80 total points
ID: 8208460
here is a solution

create a movie call it timer

frame 1 of timer mc.


var sDelay = 0;
var startTime = 0;
var callBackfn = "";
this._visible = false;
stop();

function StartTimer(milliseconds, callBack)
{
//     trace("start")
     sDelay = milliseconds;
     callBackfn = eval(callBack);
     startTime = getTimer();
     gotoAndPlay(2);
}


function checkTime()
{
//     trace(getTimer() - startTime + " " + sDelay)
     if (getTimer() - startTime >= sDelay)
     {
          callBackfn();
          gotoAndStop(1);
     }
}



frame 2:

checkTime()


frame 3:

checkTime()
gotoAndPlay(2);


place it on a timeline.

on the timeline:
timer must stretch from frame 1 to 2 (to allow the movie to load correctly)

frame 2:

stop();
timer.StartTimer(5000,"_root.endTimer");
function endTimer(){
     trace("end");
}

0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8210530
you sure gave a lot for 20 points stef4s...

you must need to get your monthly 3,000  :)



rp
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 8211149
And I think grantunwin was looking for a simple and easy solution as well for 20 Points :)
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8213831
I guess I value my time a little more...

call me a Points Snob :)


grantunwin, you got a steal...


rp
0
 
LVL 5

Expert Comment

by:stef4s
ID: 8217476
its not about points for me.

And pasting code into a text window is easy enough
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 8218028
yeah, I guess if you already have the code written then it is pretty simple...
0
 
LVL 5

Expert Comment

by:stef4s
ID: 8237890
grantunwin have you tried the solution?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

800 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