I had the exact same question for flexcoders before and I didnt really 
get the answer I was looking for: 
http://tech.groups.yahoo.com/group/flexcoders/message/68264
(Let me know if you can derive something useful from it.)

The example I gave there was an address component being resued in an 
input form requiring Shipping and Billing info. Since this was one 
component, the same ViewHelper was instantiated twice and I get an 
error. You simply cannot reuse your address component for the two forms 
if the address component uses the off-the-shelf ViewHelper class.

(I noticed that instantiating the ViewHelper in mx:Script works, but 
then the class doesnt get registered to the view, not sure yet if this 
matters)

I've tried several different things and my conclusion is that Cairngorm 
probably (and ViewHelper definitely) isn't designed for reuse in 
multiple instances. To me this is strange because I thought the whole 
point of a ViewHelper is to separate the code from the presentation to 
make the code reusable? I want the same ViewHelper class to manage the 
operational aspect of my component so I can apply it to any presenation 
(topBarAddressInputForm, leftbarAddressInputForm, 
contentAddressInputForm), no?

Finally, I am under the impression that I will have to create my own 
ViewHelper-like class to separate the code from the MXML, or be very 
careful to manage/subclass the resuse of instances (possibly with a 
ViewLocater).
 
The cool thing is that Cairngorm has a functional class that I can copy 
and paste to do this. And maybe that's the real answer.

Shannon


Reply via email to