2 Replies Latest reply on Jan 8, 2010 9:01 AM by lkenney2

    1120: Undefined property, but why?

    lkenney2 Level 1

      Could someone please tell me why I can't affect the x and y coordinates of the button?

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx: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" minWidth="1024" minHeight="768" width="768">

      <fx:Script>
        <![CDATA[

         btnStoryListen.x = 10;
         btnStoryListen.y = 10;
        
        ]]>
      </fx:Script>


      <mx:TabNavigator width="600" height="400" id="tabNav">
       
        <s:NavigatorContent label="Start Page" width="100%" height="100%" id="tbMain">
        </s:NavigatorContent>
        <s:NavigatorContent label="Story" width="100%" height="100%" color="#FFFFFF" fontFamily="Alba Super" id="tbStory">
         <mx:Button id="btnStoryListen" styleName="StoryListen" enabled="true" />
        </s:NavigatorContent>
       
      </mx:TabNavigator>

      <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
      </fx:Declarations>

      </mx:Application>

        • 1. Re: 1120: Undefined property, but why?
          Peter deHaan Level 4

          The code in the <fx:Script> block is run before the Button is created. The best way around it is to wrap that code in a function and then call it in the initialize or creationComplete event handler for the button (or application). Something like this:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx: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="1024" minHeight="768"
                          width="768">
              
              <fx:Script>
                  <![CDATA[
                      private function button_init():void {
                          btnStoryListen.x = 10;
                          btnStoryListen.y = 10;
                      }
                  ]]>
              </fx:Script>
              
              <mx:TabNavigator width="600" height="400" id="tabNav">
                  <s:NavigatorContent label="Start Page" width="100%" height="100%" id="tbMain">
                  </s:NavigatorContent>
                  <s:NavigatorContent label="Story" width="100%" height="100%" color="#FFFFFF" fontFamily="Alba Super" id="tbStory">
                      <mx:Button id="btnStoryListen" styleName="StoryListen" enabled="true" initialize="button_init();" />
                  </s:NavigatorContent>
              </mx:TabNavigator>
              
          </mx:Application>
           
          

           

          Peter

          • 2. Re: 1120: Undefined property, but why?
            lkenney2 Level 1

            Thanks. I had the right funtino set up eariler, but I forgot all about the

            initialize command.