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 Return Value

Please update flash player to view this Flash ActionScript tutorial!

Flash Tutorial Content:

Sometimes ActionScript function required to return value back to the codes. Remember that you should always specify the type of value the function is supposed to return. The following diagram illustrate how value is returned from the function to the codes.

ActionScript function with returned value tutorial

Flash ActionScript Codes:

// Create a custom function
// The name of function is moveBall
// The function will not return a value
// The return data type is Number
function moveBall ():Number {
// The codes below will be executed when being called or run
// The ball will be moved 300 pixels to the right
ball_mc.x += 300;

// The value (x location of the ball_mc) is returned back to the code
// The data type of this returned value is Number
return ball_mc.x;


// Run or call the function with the function name (moveBall)
// The function returned the value (x location of the ball_mc)
// back to the code
// Therefore moveball () will have the value (x location of the ball_mc)
output_txt.text = "The ball had been moved to x-location: " + moveBall();

Download Flash Source File:

Flash Source File functions-with-return-value.fla


More values can be returned with the above ActionScript Function example.