Thanks for the example.But I still have some questions.
1)Is viewHelper used to segregate as code from mxml?
2)Its not used in any of examples provided for Cairngorm 2 nor is it 
part of any discussion about cairngorm 2 architecture.Is it an 
optional feature retained from cairngorm 0.99?
3)If I dont have any need to manipulate the mxml file from other 
files(which you have mentioned below), should I still go ahead and 
create a viewHelper for each view? 

--- In flexcoders@yahoogroups.com, e baggg <[EMAIL PROTECTED]> wrote:
>
> //mainScreen.mxml
> <?xml version="1.0" encoding="utf-8"?>
> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"; width="100%" 
height="100%"         
>     xmlns:viewHelper="com.myapp.view.*" verticalGap="0"> 
>     <viewHelper:MainScreenViewHelper id="mainScreenViewHelper" />
>       <mx:Label id="mylabel" text="Hello World"/>
>     </mx:VBox>
> 
> //MainScreenViewHelper
> package com.myapp.view
> {
>     import org.nevis.cairngorm.view.ViewHelper;
>     import com.communify.model.ModelLocator;
>     
>     /**
>      * Gives a handle to main.mxml and its subcomponents
>      */ 
>     public class MainScreenViewHelper extends ViewHelper{
>         private var model:ModelLocator = ModelLocator.getInstance
();
>         public function MainScreenViewHelper(){
>             super();
>         }
>        
>         public function updateLabel(updatedString : String):void{
>             Label(view.mylabel).text = updatedString;
>         }
>         
>     }
> }
> 
> So, the line of code "<viewHelper:MainScreenViewHelper 
id="mainScreenViewHelper" />" instantiates the ViewHelper class and 
registers it with the singleton class ViewLocator. This means that 
any class or mxml file can access the components of the 
MainScreen.mxml by calling:
> 
> var viewHelper : MainScreenViewHelper = MainScreenViewHelper
(ViewLocator.getInstance().getViewHelper("mainScreenViewHelper"));
> viewHelper.updateLabel(otherTextField.text);
>               
> ---------------------------------
> Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  
Great rates starting at 1ยข/min.
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to