3 Replies Latest reply on Mar 5, 2008 7:00 PM by ntsiii


    SiHoop Level 1
      I'm trying to pass a variable to a ViewStack container. The following files work fine now, but I would to change it to pass the variable myVar2 to component1. So, the Label tag in component1 would be something like:
      <mx:Label text="{myVar2}"/>

      Of course, when I try this I get an error because myVar2 is undefined in the file component1.

      So, is it possible to pass a variable from one file to another?


      <?xml version="1.0"?>
      <mx:Application creationComplete="init()" xmlns:comp="components.*" xmlns:mx=" http://www.adobe.com/2006/mxml">
      private var myVar1:String
      private var myVar2:String
      private function init():void{
      </mx:Script><mx:Panel title="ViewStack">
      <mx:Button id="Panel1" label="Panel 1"
      <mx:Button id="Panel2" label="Panel 2"
      <mx:Button id="Panel3" label="Panel 3"
      <mx:ViewStack id="myViewStack">
      <mx:Canvas id="linkPanel1" label="Search" width="200" height="30">
      <mx:Label text="Initial text"/>
      <comp:component1 id="linkPanel2" />
      <mx:Canvas id="linkPanel3" label="Search" width="200" height="30">
      <mx:Label text="{myVar1}"/>

      File 2: components/component1.mxml
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:Canvas width="200" height="30">
      <mx:Label text="Panel 2 content"/>

      Thank you.