First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Joachim Schnier | Website:

The Actionscript 2 File


You will find this explanation in the Flash Help menu about constructors: (use the help menu as often as you can)

Constructors are functions that you use to define the properties and methods of a class.

The constructor has the same name as the class, in our case "uButton1". Before the function name we use the word "public". We don´t actually have to add it because by default the constructor is public. In contrast to public is "private". These reserved words can only be used in .as files and not in the actionscript panel. These words allow or deny access of other classes to the class function where it is used. The constructor function has to be public in this case since none of the functions can be otherwise accessed. Also do not use "static, dynamic or Void" in the constructor.

We now enter the subfunctions of our classfunction, which are what happens when we rollover, rollout or press the movieclip in our movie and thus converts the movieclip into a button. We enter of course the necessary parameters.

class scripts.uButton1 {
//defining all variables
	var s_Url: String;
	var s_Window: String;
	var m_Object: MovieClip;
	var c_nColor: Color;
	var c_oColor: Color;
	var o_Color: Object;
	//creating the constructor
	public function uButton1(s_Url,s_Window,m_Object,c_nColor,c_oColor) {
		//subfunctions with parameters

» Level Intermediate

Added: 2003-10-30
Rating: 5.12 Votes: 68
(10 being the highest)
» Author
The author is a basic scientist working in cancer research.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.