tags:

views:

582

answers:

5

I am getting a value in a MXML... now i need to pass it to another MXML to invoke an event... how can i do it.

A: 

It can be done like this Test.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
     <![CDATA[
      public var a:String;

     ]]>
    </mx:Script>
</mx:Application>

Test2.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    <mx:Script>
     <![CDATA[
      public var a1:String;
      public var te1:Test=new Test();
      public function init():void{
      a1=te1.a;
      }
     ]]>
    </mx:Script>
</mx:Application>

this is not right i think but it may serve your purpose

Rahul Garg
+1  A: 

Assuming one MXML component is the child of the other, you should be using binding to pass data around.

Richard Szalay
+1  A: 

You could dispatch an event containing the string value from the source component to be received by the destination component.

adamcodes
+1  A: 

You need to explain more about how your two mxml components relate to each other... parent/child? two siblings within a parent? That will determine the best approach. Of course, your components should not really be "wired into each other" if possible, which is where frameworks such as Mate come in, but that is probably way beyond where you're at just now.

A: 

i want to pass values from one mxml page to other.......can anyone give me a soln?

saran
You need to create an custom event class and then pass the value through it to another mxml and recieve or hear that event there.