• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Object oriented programming

New Here ,
Oct 20, 2014 Oct 20, 2014

Copy link to clipboard

Copied

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>

Views

231

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2014 Oct 21, 2014

Copy link to clipboard

Copied

LATEST

this has been solved. Click on the link to view the solution

Object oriented programming

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines