1 Reply Latest reply on Aug 22, 2006 12:39 PM by ntsiii

    Access to a component from ViewStack

    Freeseb
      Hi

      I've created an application using viewstack calling components as contents. But I do not find the way to adress objects from one stack to another. If putting all the code inside the main mxml fileI can do it easily but if calling just components from viewstack not anymore despite creationpolicy is set to all. Here is the code, I would like to access the input2.text (Athletes view) from button1(competitions view)

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" height="422">
      <mx:ApplicationControlBar x="0" y="0" width="838">
      <mx:ToggleButtonBar
      height="100%"
      dataProvider="{viewStack}"
      styleName="storeButtonBar"/>
      </mx:ApplicationControlBar>

      <mx:ViewStack x="0" y="39" id="viewStack" width="838" height="226" creationPolicy="all">
      <Calendar label="Calendar" width="100%" height="100%" showEffect="WipeDown" hideEffect="WipeUp" />
      <Competitions label="Competitions" width="100%" height="100%" showEffect="WipeDown" hideEffect="WipeUp" />
      <Athletes label="Athletes" width="100%" height="100%" showEffect="WipeDown" hideEffect="WipeUp" />

      </mx:ViewStack>
      <mx:TextInput x="22" y="290" id="aa"/>

      </mx:Application>

      Competitions.mxml
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="400" height="300">
      <mx:Button x="156" y="125" label="Button" click="{seb.text='it works'}"/>
      </mx:Canvas>

      Athletes.mxml
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="400" height="300">
      <mx:TextInput id="seb" x="22" y="49" />
      </mx:Canvas>
        • 1. Re: Access to a component from ViewStack
          ntsiii Level 3
          Try:
          import mx.core.Application;

          put an id="comp" on the Competitions component tag.

          Application.application.comp.seb.text='it works'

          This might not be "best practice", but should work. Other possibilities include passing a reference to "Athletes" directly into "Competitions".

          Tracy