flash actionscript:
Hi there!
Question 1:
I use member access control a lot in C++ and I try to do so in Flash as well.
But there seems to be a problem:
Suppose we have a simple class:
class memberAccessTest{
public var pub:Number;
private var priv:Number;
}
and we create an instance of it in a fla file:
var test:memberAccessTest = new memberAccessTest();
test.priv = 5; // generates compiler error
test.pub = 6; // OK
Now this is ok - but lets see what happens if the user forgets to strictly
type the instance:
var test2 = new memberAccessTest();
test2.pub = 5; // OK
test2. priv = 6; // also OK?!?!?
Now as a develover you can declare private and public members (it is not good
users to have access to some internals of a class), but you CANNOT force the
user to strictly type the instances of your class... is there workaround?
Question 2:
In Flash MX 2004 Pro help files (and in the online help too) in the artice
http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/ wwhelp.htm?context=Flash_MX_2004&file=00003105.html it is said that when you
extend the UIObject class you should declare the dispatchEvent function before
you call it like this:
private var dispatchEvent:Function;
Now this seems not to be right - I created multiple test classes and even when
using strict data typing EVERYWHERE the compiler didn't return any error when
this function was not declared in my class definition. Any ideas on this one?
And should methods that are inherited from a superclass be declared again in
the derivative class in order to be used? As far as my experiments go - they
should not...
Thank you in advance...