You can assign values to private and/or public variables of the class
using the 4th argument of attachMovie. Just read the API
documentation:
public attachMovie(id:String, name:String, depth:Number,
[initObject:Object]) : MovieClip
initObject can be predefined or used on the fly, which looks like:
_root.attachMovie(libraryID, instanceName, depth, {myString: "Hello
World", _x: 20});
This is not the same as using params in the constructor, but these
variables are set before the constructor is called, so you can use the
values within the constructor, which is nearly the same and works fine
for me.
hth,
Matthias
2007/5/2, sebastian chedal <[EMAIL PROTECTED]>:
> If it is a movie clip you want to instantiate then you have to use:
> _root.attachMovie(libraryID, instanceName, depth);
> The class associated with it will construct and the onLoad event will
> trigger if it is being listened to.
this indeed works, but then i can't pass any values to the constructor.
Is there any way to attachMovie and at the same time pass values to it?
I supose I can always refer to it afterwards on the time line and call a
custom function... but it would be nice to use the constructor's
functionality.
I had hoped I could generate new instances just by calling a constructor
instead of attaching it to something; but i guess logically i it needs to be
attached to be "on the timeline". Correct me if I am wrong.
Thanks!
Seb.
On 5/1/07, O. Fouad <[EMAIL PROTECTED]> wrote:
>
> are u executing the class post view?
>
> On 5/1/07, Andy Herrman <[EMAIL PROTECTED]> wrote:
> >
> > Or have the function return it, which is what it seems like would be
> > the right thing for that method.
> >
> > -Andy
> >
> > On 5/1/07, Ron Wheeler <[EMAIL PROTECTED]> wrote:
> > > I am not sure if you are showing all the code but in your code
> fragment,
> > > newPost is a local variable that will be destroyed as soon as
> createPost
> > > ends. A short and brutal life.
> > >
> > > It needs to be a class property and you will want to have a getter to
> > > access it.
> > >
> > > Ron
> > >
> > > sebastian chedal wrote:
> > > > Hello Flashcoders,
> > > >
> > > > Sorry to bother you with another simple AS2 questions, I'm making
> good
> > > > progress but I am stumped with one simple thing.
> > > >
> > > > I have one class/object that I want to use to generate copies
> > > > [instances] of
> > > > another class.
> > > >
> > > > The second class is an object in the library with an ID and an
> > assosiated
> > > > *.as file [in the linkage panel].
> > > >
> > > > The code is:
> > > > =========
> > > >
> > > > //PostModel.as
> > > >
> > > > import com.blabla.PostView;
> > > >
> > > > class com.blabla.PostModel {
> > > >
> > > > public function createPost (__id) {
> > > > var newPost = new PostView (__id);
> > > > }
> > > > }
> > > >
> > > > =========
> > > >
> > > > When I run this code, the class doesn't construct an instance...
> > > >
> > > > What am I missing? If I need to call the Library Identifyer instead,
> > how
> > > > would I do that?
> > > >
> > > > I don't want to attach the PostView to the PostModel class, I just
> > > > want to
> > > > create instances of them and attach them to _root [or some other MC
> in
> > > > the
> > > > timeline].
> > > >
> > > > Thanks!!
> > > >
> > > > Seb.
> > > > _______________________________________________
> > > > [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
> > > >
> > > >
> > > _______________________________________________
> > > [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
> > >
> > _______________________________________________
> > [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
> >
>
>
>
> --
> O.Fouad - Digital Emotions
> _______________________________________________
> [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
>
_______________________________________________
[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
_______________________________________________
[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