How to cause a delay with setTimeout?

  • rxylab
  • Born
  • Born
  • rxylab
  • Posts: 2

Post 3+ Months Ago

Hi there

Ok, so I'm designing my website and I'm fairly new to actionscript. I have a menu that I'm trying to design where I want certain menus to retract one after another at the moment they all retract at the same time. How would I integrate the setTimeout function? The file is attatched if you want to see what I'm trying to make.

The way I'm unsuccessfully adding the code at the moment is like:

Code: [ Select ]
import mx.transitions.Tween;
import mx.transitions.easing.*;
 
var startX:Number = mixesmenu_mc._x;
var startX1:Number = hidden_box02._x;
 
var myTween:Tween;
 
mixes_btn.onRollOver = function  () {
    if (mixesmenu_mc._x < 0) {
        new Tween(mixesmenu_mc,"_x",Regular.easeOut,startX,startX+107,0.2,true);
    }
}
 
prod_btn.onRollOver = function  () {
    if (mixesmenu_mc._x > 0) {
        setTimeout (new Tween(mixesmenu_mc,"_x",Regular.easeOut,startX+107,startX,0.2,true),200);
        mixesmenu_mc._x = startX
    if (mixesmenu_mc._x < 0) {
        new Tween(hidden_box02,"_x",Regular.easeOut,startX1+15,startX1,0.1,true);
    }
    }
}
 
this.mixesmenu_mc.dubstepmixes_btn.onRollOver = function  () {
    if (mixesmenu_mc._x > 0) {
        myTween = new Tween(hidden_box02,"_x",Regular.easeOut,startX1,startX1+10,0.3,true);
   
    }
}
  1. import mx.transitions.Tween;
  2. import mx.transitions.easing.*;
  3.  
  4. var startX:Number = mixesmenu_mc._x;
  5. var startX1:Number = hidden_box02._x;
  6.  
  7. var myTween:Tween;
  8.  
  9. mixes_btn.onRollOver = function  () {
  10.     if (mixesmenu_mc._x < 0) {
  11.         new Tween(mixesmenu_mc,"_x",Regular.easeOut,startX,startX+107,0.2,true);
  12.     }
  13. }
  14.  
  15. prod_btn.onRollOver = function  () {
  16.     if (mixesmenu_mc._x > 0) {
  17.         setTimeout (new Tween(mixesmenu_mc,"_x",Regular.easeOut,startX+107,startX,0.2,true),200);
  18.         mixesmenu_mc._x = startX
  19.     if (mixesmenu_mc._x < 0) {
  20.         new Tween(hidden_box02,"_x",Regular.easeOut,startX1+15,startX1,0.1,true);
  21.     }
  22.     }
  23. }
  24.  
  25. this.mixesmenu_mc.dubstepmixes_btn.onRollOver = function  () {
  26.     if (mixesmenu_mc._x > 0) {
  27.         myTween = new Tween(hidden_box02,"_x",Regular.easeOut,startX1,startX1+10,0.3,true);
  28.    
  29.     }
  30. }



I've highlighted where I attempted to use setTimout. I want the submenu to wait for the little line to retract back in, then the submenu to retract. It'll be easier to understand when looking at the file I suppose. Sorry if the coding is messy, it is my first try to write coding in one frame.

Cheers, Amo
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

try setInterval() instead. Look it up in the actionscript help.
  • rxylab
  • Born
  • Born
  • rxylab
  • Posts: 2

Post 3+ Months Ago

I tried understanding the help, and I really don't have a clue but I think it would be :

setInterval (myTween2, 2000)

Where I define myTween2 as a variable at the start of the code. But this isn't working for me.
  • graphixboy
  • Control + Z
  • Mastermind
  • User avatar
  • Posts: 1828
  • Loc: In the Great White North

Post 3+ Months Ago

nope...

Code: [ Select ]
var intervalName = setInterval(FunctionToRunEveryXMiliseconds, timetorepeat);


Here's a tutorial.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 18 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.