Flash AS3 Tutorials Center | Interesting Flash Animation Tutorials | Valuing Flash Animation Tutorials | Flash ActionScript and Animation Home

AS3 Beginner Tutorials | AS3 Basic Lessons | AS3 Valuing Courses | AS3 Components Tutorials | AS3 and PHP Interaction Tutorials
AS3 Practical Tutorials | AS3 Animation Techniques | AS3 Transition Effects Tutorials | AS3 Download Upload Files | AS3 Particle Systems
Communication Between Flash Movies with AS3 | AS3 and JavaScript interaction | AS3 Matrix Transformation | AS3 Physics Simulation Tutorials

Actionscript Function with Multiple Arguments

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

In previous ActionScript function tutorials, a single value was sent to the function when called. Actually multiple values can be sent to ActionScript functions.

In this tutorial, three values will send into the function for processing when called. And the three argument parameters in the function will act as variables for what corresponding values that sent into the function. The scenerio is illustrated in the following diagram:

ActionScript function with multiple parameters

Flash ActionScript Codes:

// Create a custom function
// The name of function is moveBall
// The function has three parameters
// xLoc, xScale and yScale
// - The data type of the parameters are all Number in this example
// Actually xLoc, xScale and yScale act as variables that has a whatever values send to the function
// In this example:
// xLoc = 300
// xScale = 3
// yScale = 2

function moveBall (xLoc:Number, xScale:Number, yScale:Number):void {
// The codes below will be executed when being called or run

// The x-location of ball_mc will be moved by by an amount (value) sent to the function
// i.e. ball_mc.x += 300;
// The scale of ball_mc will be increased by 2 in horizontal diection
// The scale of ball_mc will be increased by 3 in vertical direction

ball_mc.x += xLoc;
ball_mc.scaleX = xScale;
ball_mc.scaleY = yScale;


// Run or call the function with the function name (moveBall)
// Three value (300, 3, 2) will send to the function to process
moveBall (300, 3, 2);

Download Flash Source File:

Flash Source File functions-with-multiple-argument-parameters.fla


This is the end of ActionScript Functions with multiple parameters.