I re-read your question and the answer is no you can not.
The reason is becuase Flex is event driven.
What you can do is add to the Application tag flag of:
creationComplete="init()"
and use inside the class:
public function init():void{
pageRO = new RemoteObject();
pageService = PageService.getInstance();
}
--- In [email protected], "rumpleminzeflickr"
<[EMAIL PROTECTED]> wrote:
>
> They are declared in the format
>
> public var pageService:PageService;
>
>
> --- In [email protected], "helihobby" <helihobby@> wrote:
> >
> > I think you forgot to add var unless you define a private var at
the
> > top.
> >
> >
> > --- In [email protected], "rumpleminzeflickr"
> > <rumpleminze@> wrote:
> > >
> > > Hi,
> > >
> > > This maybe a really dumb question, but why I can't I create new
> > > objects or even assign a null object a value in the class
itself?
> > >
> > > It works fine if I do it in a function. Just trying to
understand
> > i'm
> > > sure there is a good reason.
> > >
> > > Many thanks,
> > >
> > >
> > >
> > >
> > > public class MyClass
> > > {
> > >
> > > // doesn't work here
> > > pageRO = new RemoteObject();
> > > pageService = PageService.getInstance();
> > >
> > >
> > > public function Foo():void{
> > >
> > > // works here
> > > pageRO = new RemoteObject();
> > > pageService = PageService.getInstance();
> > >
> > > }
> > > }
> > >
> >
>