4 Replies Latest reply on Nov 3, 2009 11:35 AM by CoreyRLucier

    fx:Declarations tag

    tork314 Level 1

      I would like to place a group into some sort of a library to reuse it later, however it will need to have externally visible parameter.

      Script tag is not allowed inside fx:Component and it says that it cannot resolve component to a component implementation:

       

       

      <mx:Canvas

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

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

      xmlns:mx="library://ns.adobe.com/flex/halo"

      xmlns:fc="http://ns.adobe.com/flashcatalyst/2009"

      xmlns:d="http://ns.adobe.com/fxg/2008/dt"

      horizontalScrollPolicy="off"

      verticalScrollPolicy="off"

      xmlns:graphics="assets.graphics.*">

      <fx:Declarations>

      <fx:Component className="AnswerWindow">

      <s:Group >

      </s:Group>

      </fx:Component>

      </fx:Declarations>

      ....

       

        • 1. Re: fx:Declarations tag
          CoreyRLucier Adobe Employee

          Does this help? (Note use of Library and Definition).

           

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

           

          <!--
          This app works as expected if the list's data provider is specified in state1
          (or in no state), but not if it's specified in "stateGroups" G.

           

          -->

           

          <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/halo">

           

              <fx:Library>
                  <fx:Definition name="myThing">
                      <s:Group>
                          <fx:Script>
                              <![CDATA[
                                  private function blah():void
                                  {
                                      trace('button pressed');
                                  }
                              ]]>
                          </fx:Script>
                          <s:Button click='blah();'/>
                      </s:Group>
                  </fx:Definition>
              </fx:Library>
             
              <fx:myThing/>
             
          </s:Application>

          1 person found this helpful
          • 2. Re: fx:Declarations tag
            tork314 Level 1

            yes, i fixed it to the right namespace, and it worked, however:

             

            <fx:Library>

            <fx:Definition name="AnswerWindow">

            <s:Group x="320" y="123" width="191" height="85" >

            <fx:Script>

            <![CDATA[

            [Bindable]

            public var content:String;

            ]]>

            </fx:Script>

                 <s:RichText styleName="panelTitle" textAlign="center" horizontalCenter="0" verticalCenter="12" content="{content}" />

             

            </s:Group>

            </fx:Definition>

            </fx:Library>

             

             

            <fx:AnswerWindow excludeFrom="default">

            <s:content>

            <s:p fontSize="15" fontFamily="HelveticaRomanEmbedded"><s:span >After CBC performed:</s:span></s:p><s:p  fontSize="14"><s:span>Hemoglobin (Hb)=9.5 g/dL</s:span></s:p><s:p fontSize="27" color="#79161d"><s:span>Anemic</s:span></s:p>

            </s:content>

            </fx:AnswerWindow>

             

             

            content has to belong to spark namespace, because there are no things such <fx:span> or <fx:p> otherwise it wouldn't resolve it.

            Do you know how to transpose these namespaces?

            • 3. Re: fx:Declarations tag
              tork314 Level 1

              Worked. Sorry.

              the content variable is boxed so it has to be of Object type (=

              • 4. Re: fx:Declarations tag
                CoreyRLucier Adobe Employee

                FWIW, this works for me too (with and without an fx:Script block):

                 

                <?xml version="1.0" encoding="utf-8"?>
                <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                               xmlns:s="library://ns.adobe.com/flex/spark"
                               xmlns:local="*"
                               xmlns:mx="library://ns.adobe.com/flex/halo">
                   
                    <fx:Declarations>
                        <fx:Component className="Circ">
                            <s:Ellipse width="50" height="50">
                                <s:fill>
                                    <s:SolidColor color="red" />
                                </s:fill>
                            </s:Ellipse>
                        </fx:Component>
                    </fx:Declarations>
                   
                    <local:Circ/>
                   
                </s:Application>