Yes it works !! Thanks a lot.

What is the problem with creating object variables outside the constructor ?

As far as I remember from my C++ time , java & c++ were allowing you to do
that so I thought AS2 would.

Thanks again, and thanks to the other people that gave me extra information.
That is well appreciated.





Patrick Jean
Directeur de projets internet
Monac'OH Data Mercantour
http://www.monacoh.com

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of eric dolecki
Sent: Tuesday, March 21, 2006 11:34 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] AS Files question

would this work?

import SequencerOBJ;
class ComOBJ extends LoadVars {
        private var myTest:SequencerOBJ;
                public function ComOBJ() {
myTest=new SequencerOBJ("It works");
                 }
}


On 3/21/06, Patrick Jean <[EMAIL PROTECTED]> wrote:
>
> I get the idea, but it doesn't seem to work on my side. Maybe I declared
> something wrong.
>
> The class I want to access from my 2nd AS file is that one :
>
> ------------------------------------
> class SequencerOBJ {
>                 public function SequencerOBJ(aTest:String) {
>                 trace("SEQUENCER WORKS = " + aTest);
>         }
> }
> -------------------------------------
>
> So in my 2nd Class , I put :
>
> -------------------------------------
> import SequencerOBJ;
>
> class ComOBJ extends LoadVars {
>
>         private var myTest:SequencerOBJ=new SequencerOBJ("It works");
>
>                 public function ComOBJ() {
>
>                 }
> }
> -------------------------------------
>
> Finally, in my FLA , I have :
>
> import ComOBJ;
> _global.myComOBJ = new ComOBJ();
>
>
> And when I compile I get an error saying :
>
> **Error** C:\!PROJECTS\Resweb\ComOBJ.as:
> Line 6: A class's instance variables may only be initialized to
> compile-time
> constant expressions.
> private var myTest:SequencerOBJ=new SequencerOBJ("It works");
>
> -------------------------------------
>
> Did I screw up on the syntax or something ?
>
> Thanks a lot
>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of elibol
> Sent: Tuesday, March 21, 2006 11:14 AM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] AS Files question
>
> There is, import class B within class A, having multiple imports of the
> same
> class won't cause the compiler to compile the same class more than once.
>
> import B;
>
> class A {
>
> function A(){
> var bInstance = new B();
> }
>
> }
>
> you can also do something like this:
>
> import B;
>
> class A {
>
> private var _bInstance:B;
>
> function A(bInstanceArg:B){
> _bInstance = bInstance;
> }
>
> }
>
> hope this helps,
>
> M.
> On 3/21/06, Patrick Jean <[EMAIL PROTECTED]> wrote:
> >
> > Greetings. I'm pretty new to the external AS files concept and I have a
> > quick question.
> >
> >
> >
> > I made a first external class, let's call it "Class A"
> >
> >
> >
> > I also created a second external class. Let's call it "Class B"
> >
> >
> >
> > If I want to properly reference Class B from within the Class A  AS file
> ,
> > what is the best way to do it ?
> >
> >
> >
> > Do I just have to import class B before class A within my FLA ? That
> > sounds
> > not very efficient. So I assume there's a way to make classe B
> accessible
> > by
> > class A from within the AS file.
> >
> >
> >
> >                         Thanks a lot.
> >
> >
> >
> >
> >
> > Patrick Jean
> >
> > Directeur de projets internet
> >
> > Monac'OH Data Mercantour
> >
> > http://www.monacoh.com
> >
> >
> >
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > 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
> >
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> 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
>
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> 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
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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

_______________________________________________
Flashcoders@chattyfig.figleaf.com
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