Flex Zugriff auf Variablen aus einem Bauteil in ein anderes

Ich haben eine Haupt-Anwendung, hat eine int-variable deklariert. Ich möchte den Zugriff auf diese variable in einer anderen Komponente, die in ein anderes Paket. Wie kann ich dies tun?

Main.mxml (Standard-Paket)

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                               preinitialize = "foo()">
    <fx:Script>
            <![CDATA[
                         public var value1:int;
                         public function foo():void {
                            value1 = 5;
                         }

                ]]>
        </fx:Script>

    <\s:Application>

Comp.mxml-Komponenten-Paket)

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
         xmlns:s="library://ns.adobe.com/flex/spark" 
         xmlns:mx="library://ns.adobe.com/flex/mx"
                 creationcomplete = "foo2()">
           <fx:Script>
                <![CDATA[
                            public function foo2(): void{
                             //------> access value1 from Main.mxml here.
                            }

                    ]]>
            </fx:Script>

</s:Group>
InformationsquelleAutor H P | 2010-07-18
Schreibe einen Kommentar