Google   Web www.flash-here.com
 

Looking for Flash Downloads / Tutorials, but can't find it here?

Give us suggestions and we will try to make it up for you!


We got 1000 visits per day! Contact us to exchange link with us!

Flash Tutorial - Scrolling Effect



In our news ticker tool, text links are scrolled from the bottom to the top (and loop around after reaching to the top). The idea behind is very simple; just keep moving the movie clip (that holds the text links) up and up... We used the following actionscripts to achieve the scrolling effect.

 

var g_interval = 300;
var g_step = 1;
var g_iid = -1;
var m; // this is the movie clip we created to hold the text links

function start_scroll()
{
  if(g_iid != -1)
    clearInterval(g_iid);
  g_iid = setInterval(scrolling, g_interval);
}

function scrolling()
{
  var y = m._y;
  y -= g_step;
  if(y + m._height < 0) {
    m._y = Stage.height;
  } else {
    m._y = y;
  }
}

function stop_scroll()
{
  clearInterval(g_iid);
}

start_scroll();

 

In the example, we created a movie clip "m" to hold the text links (the corresponding code/steps were omitted here). The movie clip is initially placed below the bottom of the stage area.

There are a couple of functions that we've defined:

start_scroll: we used the "setInterval" api to set the time interval to re-position the movie clip m. In this case, for every 300 ms (the value of g_interval), the "scrolling" function will be called.

scrolling: this function will move the movie clip m up by 1 pixel (the value of g_step) until it reach the top of the stage. Then it will re-position the clip to the bottom of the stage.

stop_scroll: this function use "clearInterval" to stop the scrolling. In the above code, we haven't make any call to "stop_scroll", but in case you need to start/stop scrolling (as in our news ticker tool), you will find this function useful.

 

< Tutorials Index - Post suggestions >