-
I've dabled in Java and c++, both allow for multiple constructor functions. I'm trying to create a class in MX with multiple constructor functions using the same principles but it doesn't seem to be working. Does anyone know if MX supports multiple constructor functions? The following is the scripting you would use in C++, and is what I tried using in MX:
function myClass(){
this.a = "";
this.b = "";
}
function myClass( A ){
this.a = A;
this.b = "";
}
function myClass( A,B ){
this.a = A;
this.b = B;
}
-
it's called overloading, and yes I believe that you can overload functions in MX so long as each function is unique (in parameters). your example should be fine. However, the following would not. Note, I am assuming that the functions are declared in the same scope...
function testme(){
}
function testme(){
}
this would not work
HTH, and have a happy 4th!
-
RE:RE
If you look at the script example, my functions are unique (in parameters). However, MX refuses to call the appropriate constructor when instanciating the objects.
-
hmm....
you're absolutely right. I apologize for that. When I responded I had not actually tried it in flash. I responded with an "off the top of my head" answer. It does seem strange that flash would not allow overloading. If I come up with a way to do it I will certainly let you know
Happy 4th!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|