No - script can only call public methods. But if you define a function in a
script block, it is effectively private to the page you define it in:
<my:MyWindow>
<bxml:script>
// This function is "private" to the document
function loginButtonPressed() {
// Perform login
}
</bxml:script>
<PushButton buttonData="Login"
ButtonPressListeners.buttonPressed="loginButtonPressed()"/>
</my:MyWindow>
On Nov 19, 2010, at 10:31 AM, ocean ocean wrote:
> Greg,
>
> So script elements can call private methods on the class they were defined in?
>
> On Fri, Nov 19, 2010 at 9:24 AM, Greg Brown <[email protected]> wrote:
> > <my:MyWindow bxml:id="myWindow">
> > <!-- Calls script function -->
> > <PushButton buttonData="Login"
> > ButtonPressListeners.buttonPressed="loginButtonPressed()"/>
> >
> > <!-- Calls login() method on root object -->
> > <PushButton buttonData="Login"
> > ButtonPressListeners.buttonPressed="myWindow.login()"/>
> > </my:MyWindow>
> >
> > The downside is that it is not possible to call private methods this way -
> > however, it could be argued that exposing higher-level operations like
> > "login" via public methods promotes better design anyways.
>
> Note that, in the script case, the "loginButtonPressed()" function is
> effectively private to the page in which it is declared, so this approach
> does not break encapsulation.
>
> G
>
>