• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. Functions > Passing Information to Functions

9.3. Passing Information to Functions

In the last section, we created a function that executed a simple trace( ) statement—not exactly the most compelling specimen of the function species. Here's a more interesting function that moves a movie clip instance, named ball, a short distance. Follow these steps to create it in your own movie:

  1. Create a new empty Flash movie.

  2. Create a new movie clip symbol, named ballSymbol, that contains a circle shape.

  3. Place an instance of ballSymbol on Layer 1.

  4. Name the ballSymbol instance ball.

  5. On frame 1 of Layer 1 of the main movie timeline, attach the following code:

    // Store a portable reference to the main timeline.
    _global.mainTimeline = this;
       
    function moveBall () {
      mainTimeline.ball._x += 10;
      mainTimeline.ball._y += 10;
    }


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint