2 Replies Latest reply on Aug 18, 2009 2:44 PM by DHTVP

    1120 Error with ID calls

    DHTVP

      Ive been doing Flex apps for a bit now and never came across this issue before...

       

      I have an MXML with something like:

       

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

      <mx:Canvas id="helloworld" />

       

      when i try to access the Canvas "helloworld" via ID from helloworld.as, I get a 1120 error.

       

      something simple such as:

      helloworld.visible = false;

       

      doesn't work!

       

      and this happened suddenly...other references to components in the MXML work fine, but some just dont reference.  ive closed Flex Builder, opened back up, 3.3 SDK...even started a new AS file called helloworld2.as and re-typed (not even copy/paste) the code, and still the same issue...also tried different ID names, but no luck.

       

      any thoughts advice?

      thanks!

        • 1. Re: 1120 Error with ID calls
          Gregory Lafrance Level 6

          This works. Are you sure you don't have helloworld.visible = false; outside a function? You can't do that outside a function anyway.

           

          If this post answers your question or helps, please mark it as such.

           

          ---------- helloworld.as ----------
          private function testfunc():void{
            testme.visible = false;     
          }
          
          ---------- mainapp.mxml ----------
          <?xml version="1.0"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="init();">
            <mx:Script source="as/helloworld.as" />
            <mx:Script>
              <![CDATA[
                private function init():void{
                  helloworld.visible = false;     
                }
              ]]>
            </mx:Script>
          <mx:Canvas id="helloworld" />
          <mx:Canvas id="testme" />
          </mx:Application>
          

          • 2. Re: 1120 Error with ID calls
            DHTVP Level 1

            thanks for the responses...unfortunately i have it exactly as you do in your example and it does not work.

            i have been using Flex for a while now, so it is definitely not a beginner mistake I'm making or anything...seems more like a bug to me.

             

            here is something else I noticed, when I create a new .as file and paste the code in from the .as file that wasn't working, save it under a new name, it works, but when i again try to add another function to this new .as file with reference to an id in the MXML, it errors out again with the 1120 Error.

             

            i have even tried starting a brand new project, rebuilding everything...same issue again....very strange.

             

            any other thoughts?