Search Tutorials
The Actionscript 2 FileConstructorYou 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
onOver(m_Object,c_nColor);
onPrss(s_Url,s_Window,m_Object);
onOut(m_Object,c_oColor);
}
}
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|