0 Replies Latest reply on Oct 13, 2010 11:10 PM by YuHsin4221123

    declaring a component

    YuHsin4221123

      is it possible to do that? right now i'm doing one search method on my component. trying to link it to another component. it goes like this

       

      search.mxml

       

      <?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" width="800" height="400" contentBackgroundAlpha="0.0" xmlns:component="component.*">
          <s:layout>
              <s:BasicLayout/>
          </s:layout>
         
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
              <component:searchResult id="searchpage" searchedTerm="{searchTextInput.text}">
              </component:searchResult>

          </fx:Declarations>
          <fx:Script>
              <![CDATA[
                  import mx.core.FlexGlobals;
                  private function changeState():void {
                  FlexGlobals.topLevelApplication.currentState = "SearchResult";       
                  searchpage.searchTerm.text = searchpage.getResult();
                  }
              ]]>
          </fx:Script>
         
          <s:TextInput width="572" id="searchTextInput"  x="49" y="83"/>
         
          <s:Button label="Search this!" id="searchButton"  click="changeState()" x="652" y="84"/>
      </s:Group>

       

      searchresult.mxml

       

      <?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" width="900" height="800">
          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
         
          <fx:Script>
              <![CDATA[
                  [Bindable]
                  public var searchedTerm:String;
                  //public var searchCriteria:String;
                  public function getResult():String
                  {
                      return "you searched for" +searchedTerm;
                  }
              ]]>
          </fx:Script>
          <s:Label x="6" y="13" text="You've searched for:" fontSize="18"/>
          <s:Label x="173" y="13" fontSize="18" id="searchTerm" color="#FF0000"/>
         
      </s:Group>

       

      i tried this method but doesn't works.