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: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
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: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.