2 Replies Latest reply on Feb 9, 2012 3:16 PM by isurf35

    Flex Library Project - including ActionScript code in a MXML file

    isurf35

      I'm new to flex so I apologize if this is common knowledge.

       

      Within Flash Builder 4.5 I have created a "Flex Project". I created a folder named "components", and created two files in that folder. 1) Page.mxml, 2) PageAs.as. Within the Page.mxml file I included the PageAs.as file using the <fx:Script source="PageAs.as" /> script tag.

       

       

      I save and run it. All works great. No errors.

       

       

      Now I create a "Flex Library Project", I create a folder named "components", and create two files in that folder. 1) Page.mxml, 2) PageAs.as. Before I have a chance to include the PageAs.as file in my Page.mxml file I receive the following error.

       

                     "A file found in a source-path must have an externally visible definition. If a definition in the file is meant to be externally visible, please put the definition in a package."

       

      I'm a little confused here. I created two different projects but created two identical file structures in each project. Why did it work fine in the "Flex Project" but not in the "Flex Library Project", and is there any way to fix the error?

       

       

      Page.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"
      
                <fx:Script source="Page.designer.as" />
       </s:Group> 
      

       

      PageAS.as

       

      import mx.events.*
       
      function unusedFunction():void
      {
            
      }