> ---------- "Steven Sacks" wrote:
> The most obvious and simple solution to me:
> Duplicate the movieclip in your library and assign the duplicate the second
> class.

I wish I can use this way...

This is an interface element that is "opened" by user.
And depending on situation in which it was opened, one of two symbols
in the library is choosen. Usually that's all.

But sometimes there's a need to change these two symbols w/o "closing"
the mentione interface element.
This ia how I came to "re-assigning class" idea :-).

However, now I tend to try "alternative solution" from below: combine
two classes into one and modify methods depending on parameters
(element "type" in this case).
Will inform you if I succeed with this.

  

-- 
Best regards,
 GregoryN                        
================================
http://GOusable.com
Flash components development.
Usability services.

> ---------- "Steven Sacks" wrote:
> The most obvious and simple solution to me:
> Duplicate the movieclip in your library and assign the duplicate the second
> class.
> 
> -Steven
> 
>> -----Original Message-----
>> From: [EMAIL PROTECTED] 
>> [mailto:[EMAIL PROTECTED] On Behalf 
>> Of GregoryN
>> Sent: Monday, April 17, 2006 8:52 PM
>> To: Flashcoders mailing list
>> Subject: Re: [Flashcoders] good OOP way to re-assign class to clip
>> 
>> Well, let's say I have two classes:
>> 
>> // ============ code ==============
>> class MyClass1 extends MovieClip{
>>      function MyClass1(){}
>>      //... some stuff
>>      
>>      function showMyInfo(){
>>        trace("I am "+this+",  class is MyClass1");
>>      }
>> }
>> 
>> class MyClass2 extends MovieClip{
>>      function MyClass2(){}
>>      //... some stuff
>>      
>>      function showMyInfo(){
>>        trace("I am "+this+",  class is MyClass2");
>>      }
>> }
>> // ============ code ends ==============
>> 
>> I have a mc symbol in the library associated with MyClass1.
>> Thus, if I attach it using attachMovie(), and then call showMyInfo
>> it'll output "... ,  class is MyClass1", right?
>> 
>> Now imagine that for some reason at some point I'll need the same clip
>> to be associated with MyClass2, while keep all properties etc
>> collected while being an instance of MyClass1. BTW, these two classes
>> are quite similar, but have several differencies.
>> 
>> As I wrote before, so far just one way comes to my mind.
>> It's about making an "instantiate()" method in MyClass2 to 
>> re-write all
>> props/methods of the target clip with ones of MyClip2 (similar to
>> EventDispatcher).
>> 
>> 
>> Another possible solution is to combine two classes into one, and make
>> methods working depending on parameters.
>> In fact, the problem here is that in 90% cases I'll need the clip to
>> carry only methods of one class, and in 10% there will be a need to
>> "swap" classes (or use parameter-depended methods).
>> 
>>   
>> 
>> -- 
>> Best regards,
>>  GregoryN                        
>> ================================
>> http://GOusable.com
>> Flash components development.
>> Usability services.
>> 
>> > ---------- "David Rorex" wrote:
>> > In my opinion, there is no "good OOP way" of changing the 
>> class of an
>> > object (be it movieclip or otherwsie). You might want to see if you
>> > can handle it in a different way, normally you should never 
>> change the
>> > class of an object.
>> > 
>> > Why exactly do you want to change the class?

_______________________________________________
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