Type checking (and checking whether methods/properties are exist or
private/public) is performed at compile-time only in AS2 and only when
the type is exactly specified (and the specified class is not dynamic
or Object, which is a general type). At run-time there is no checking,
since AS2 is nothing more than a wrapper around AS1, and the
ActionScript VM doesn't care about such things (only AVM2 for AS3 in
Flash Player 9). You declared your decorateInstance as Object instead
of Menu, so the compiler won't check for methods/properties and access
modifiers. Try this one:

class MenuItem extends MovieClip {
  private var decorateInstance: Menu;
  ...
}

And probably you do not specify class type in the other place, too:

var mcItem: MenuItem;
...
mcItem = MenuItem(attachMovie("MenuItem","MenuItem" + getNextHighestDepth(), 
getNextHighestDepth(), {_x: x, decorateInstance: this, ident: i});

You don't have to add "this" in AS2 classes and the number to string
conversion is performed automatically, when one of the + operator's
arguments is a string.

  Attila

PK> Hi there,
PK> 
PK> i have class Menu.
PK> 
PK> In this class i attach some movie clips -> 
PK> 
PK> this.mcItem = 
this.attachMovie("MenuItem","MenuItem"+this.getNextHighestDepth().toString(),this.getNextHighestDepth(),{_x:x,decorateInstance:this,ident:i});
PK> 
Class MenuItem >>
PK> 
PK> 
PK> class MenuItem extends MovieClip
PK> {
PK> .....
PK> ....
PK> ....
PK>     private var decorateInstance:Object;
PK> ....
PK> ....
PK> ...
PK> 
PK> And later in class MenuItem, in some mouse 'onRelease' event handler, i`m 
calling method in Menu class through decorateInstance:
PK> 
PK> this.decorateInstance.someMethod(args....);
PK> 
PK> 'someMethod' in Menu class is private (i only wanted to try it) and all 
working OK. 
PK> Why it is possible (accessibility of private method from another class)?
PK> 
PK> thanks
PK> 
PK> Pavel


_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to