1 Reply Latest reply on Sep 26, 2013 3:17 AM by Craberoid

    Flex4 mxml data binding "public" issue

    屏幕aaaa

      I'm using flex builder4, then i wrote a mxml sample, but it can't compile successfully.


      MXML:

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

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

      <mx:Script source="test.as"/>

      <mx:ControlBar id="ctlbar" horizontalAlign="right" width="100%"

      paddingRight="{maxFontSize}" paddingTop="0" paddingBottom="0">

      <mx:Button id="cancelBtn" label="Cancel" minWidth="11"/>

      </mx:ControlBar>

      </mx:Application>


      test.as:

      [Bindable]

      public var maxFontSize:Number = 115;


      I want to use "maxFontSize" as data binding, but it can't compile properly if i use flex sdk4.10, but if i use flex sdk3.5, it will compile successfully. Also if i change "public" to "internal", it will compile successfully even though use sdk4.10. But why this happened? Who knows that? Thanks.

        • 1. Re: Flex4 mxml data binding "public" issue
          Craberoid Level 1

          Hello.

          Adobe recommends to use spark components instead of mx in flex 4.x.

          So you can write like this:

           

          <?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:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

                    <fx:Script source="test.as" />

                    <mx:ControlBar id="ctlbar" horizontalAlign="right" width="100%"

                                                     paddingRight="{maxFontSize}" paddingTop="0" paddingBottom="0">

                              <mx:Button id="cancelBtn" label="Cancel" minWidth="11"/>

                    </mx:ControlBar>

          </s:Application>

           

          Or you can change namespaces and rewrite code like this (if you want to use mx:Application):

           

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

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

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

                    <fx:Script source="test.as"/>

                    <mx:ControlBar id="ctlbar" horizontalAlign="right" width="100%"

                                                     paddingRight="{maxFontSize}" paddingTop="0" paddingBottom="0">

                              <mx:Button id="cancelBtn" label="Cancel" minWidth="11"/>

                    </mx:ControlBar>

          </mx:Application>