Quantcast
Channel: Adobe Community : Popular Discussions - Using Flash Builder
Viewing all articles
Browse latest Browse all 70427

Object oriented programming

$
0
0

I am unable to pass data from one view to another using objects.

 

I have 2 views named FirstView.mxml and SecondView.mxml.

I have 1 actionscript file named Pass.as

 

Any help is much appreciated.

 

 

Pass.as

 

package components

{

       public class Pass

       {

 

            [Bindable]

            public var first:String;

            public var second:String;

 

            public function Pass()

            {

            }

 

            public function setFirst(first:String):void

            {

            this.first = first;

            }

 

            public function setSecond(second:String):void

            {

            this.second = second;

            }

 

            public function getFirst():String

            {

            return first;

            }

 

            public function getSecond():String

            {

            return second;

            }

 

            public function getAll():String

            {

            return first + " " + second;

            }

 

       }

}

 

 

FirstView.mxml

 

 

<?xml version="1.0" encoding="utf-8"?>

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                           xmlns:s="library://ns.adobe.com/flex/spark"

                           title="FirstView" 

                               xmlns:components="components.*">

<fx:Script>

  <![CDATA[

 

                 import components.Pass;

 

                 [Bindable]

                 public var pass:Pass;

 

                 protected function handleClick(event:MouseEvent):void

                 {

 

                 pass = new Pass();

 

                 pass.setSecond(inputbox2.text);

                 pass.setFirst(inputbox1.text);

 

                 navigator.pushView(SecondView);

 

                 }

 

  ]]>

  </fx:Script>

 

  <fx:Declarations>

  <!-- Place non-visual elements (e.g., services, value objects) here -->

  </fx:Declarations>

 

  <s:Label text="Enter your student identification number" x="10" y="10">

  </s:Label>

 

  <s:TextInput id="inputbox1" x="10" y="33">

  </s:TextInput>

 

  <s:TextInput id="inputbox2" x="10" y="145">

  </s:TextInput>

 

  <s:Button label="Search" click="handleClick(event)" x="10" y="362">

  </s:Button>

</s:View>

 

 

SecondView.mxml

 

<?xml version="1.0" encoding="utf-8"?>

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                  xmlns:s="library://ns.adobe.com/flex/spark"

                  title="SecondView"

                  xmlns:components="components.*">

 

  <fx:Script>

  <![CDATA[

 

                 import components.Pass;

 

                 [Bindable]

                 public var passData:Pass = new Pass();

 

                 protected function handleClick(event:MouseEvent):void

                 {

 

                 label3.text = passData.getAll();

 

                 }

 

  ]]>

  </fx:Script>

 

 

  <fx:Declarations>

  <!-- Place non-visual elements (e.g., services, value objects) here -->

  </fx:Declarations>

 

 

  <s:Label text="{passData.getFirst()}" x="10" y="45">

  </s:Label>

 

  <s:Label text="{passData.getSecond()}" x="10" y="145">

  </s:Label>

 

  <s:Label id="label3" x="10" y="245">

  </s:Label>

 

 

  <s:Button label="Search" click="handleClick(event)" x="10" y="362">

  </s:Button>

 

 

</s:View>


Viewing all articles
Browse latest Browse all 70427

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>