• home
  • forum
  • my
  • kt
  • download
  • Making a timer in Flash actionscript

    Author: 2007-06-06 14:43:03 From:

    In this tutorial I will show you how to make a timer that trickers a speciffic function in Macromedia Flash actionscript.

    1.
    In this tutorial I will make a timer that trickers a function, the function will do a simple random movie clip movement on the x and y axis.

    So start by making a simple graphic on the stage, right click and convert it to a movie clip as shown below.
    Now in the properties panel name the new movie clip "ball" or what ever you want.

    Photoshop Tutorial thumb picture



    2.
    Click somewhere on the stage and go to the actionscript panel and type in the following code.

    var DoRandom = function() {
    _root.ball._x = random(200);
    }

    var intervalID = setInterval(DoRandom, 1000);
    ---------------------------------------------------------

    The function container is, in here we put the code that will be trickered by the timer

    var DoRandom = function() {

    {

    The code that will be trickered is just one line of code that tells the movie clip to move to a random place on the x axis between 200 px.

    _root.ball._x = random(200);

    The last line of code will be placed after the } and this is the timer, it says to repeat the code every second.

    var intervalID = setInterval(DoRandom, 1000);

    The reason why I said random(200) is because my stage was 200 px wide, so you can change the number if you want.
    And if you change the _x to _y then it will move randomly on the y axis instead.

    3.
    Make some more graphics and add some changes in the function as shown below.

    Photoshop Tutorial thumb picture

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      3D (20)
      Math Physics (14)
      3rd Party (5)
      Navigation (60)
      Actionscripting (26)
      Optimization (16)
      Animation (32)
      Projector (9)
      Audio (46)
      Special Effects (112)
      Backend (25)
      Text Effects (65)
      Drawing (18)
      Tips and Techniques (41)
      Dynamic Content (25)
      Tricks (6)
      Games (66)
      Utilities (19)
      Getting Started (71)
      Video (10)
      Interactivity (21)
      Web Design (22)

    New

    Hot