8 Replies Latest reply on Sep 24, 2009 2:22 AM by hitesh.rawat

    .as not reading .mxml

    hitesh.rawat Level 1

      HI all,

       

      I created a small program with flex.It plays the .swf files and accepts comment.

       

      It worked. However then i thought of clearing all the mess. So, i decided to seperate the action script code into a .as file and importing it to the .mxml file.

       

      Now, i my .mxml file reads the .as file and class declared inside it because it suggests the class name and package i created. However, the action script code is showing error in every line where i'm using the mxml components like buttons, panel etc.

       

      Somebody suggest.

       

      Thanks

      H.R.

        • 1. Re: .as not reading .mxml
          _Natasha_ Level 4

          Hi,

           

          don't clear description.

          Post your code.

           

          As a remark:

          Do your .as class extends .mxml class? Only this way you can use controls from mxml. If it's just an include, you only can call functions from .as with all parameters you need.

          • 2. Re: .as not reading .mxml
            hitesh.rawat Level 1

            No my .as class  does not extend the .mxml class.

             

            Do i have to code it that way to use the mxml component??????

             

            And i'm creating a new class, so not using Include.

             

            Here's the code

             

             

            .mxml code

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   horizontalAlign="left">
               
            <mx:Script>
                <![CDATA[
                   
                    import myapp.Myclass;
                   
                    var abc:Myclass = new Myclass();
                   
                ]]>
            </mx:Script>
               

             

               
                
                <!-- Connecting XML -->
               
               
                <mx:XML id="swfList" source="swf.xml" xmlns=""/>
               
            what ever ............

            ..........................
               

             

            </mx:Application>

             

            ------------------------------------------------------------------------------------------ ------------------------------

             

            .as code

             

             

             

            package myapp
            {
               
                import flash.events.Event;
               
                import mx.controls.Alert;
               
               
                public class Myclass
                {
                   
                   
                    what ever code........................

                    ...............................................

                }
            }

            • 3. Re: .as not reading .mxml
              _Natasha_ Level 4

              Post a code where you get a error in as

              • 4. Re: .as not reading .mxml
                hitesh.rawat Level 1

                package myapp
                {
                   
                    import flash.events.Event;
                   
                    import mx.controls.Alert;
                   
                   
                    public class Myclass extends main
                    {
                       
                       
                         var loader:Loader = new Loader();    // error in the line (error code is 1180 and 1046 in all 3 lines)
                         var mc:MovieClip = new MovieClip;
                // error in the line
                         var saving:String;
                         var uicomponent:UIComponent = new UIComponent();
                // error in the line
                        
                        whatever code..........


                    }

                 

                }

                 

                 

                It is not even letting me declare variables.

                • 5. Re: .as not reading .mxml
                  _Natasha_ Level 4

                  package myapp
                  {
                      import flash.display.Loader;

                  import flash.display.MovieClip;
                  import mx.core.UIComponent;
                      import flash.events.Event;
                     
                      import mx.controls.Alert;
                     
                     
                      public class Myclass extends main
                      {
                         
                         
                           var loader:Loader = new Loader();    // error in the line (error code is 1180 and 1046 in all 3 lines)
                           var mc:MovieClip = new MovieClip
                  (); // error in the line
                           var saving:String;
                           var uicomponent:UIComponent = new UIComponent();
                  // error in the line
                          
                          whatever code..........


                      }

                   

                  }

                  • 6. Re: .as not reading .mxml
                    hitesh.rawat Level 1

                    hey, this was simple.......i didn't knew i have import all packages.......as earlier under <mx.Script> tag, it wasn't required.

                     

                    Also, now its giving me errors in .mxml code ...... where ever i called a function of the action script code.......???

                    • 7. Re: .as not reading .mxml
                      _Natasha_ Level 4

                      Example of this code?

                       

                      You can use functions... like this:

                       

                      <mx:Button label="Load" click="abc.method_name()"/>

                      • 8. Re: .as not reading .mxml
                        hitesh.rawat Level 1

                        i did that.....it gave me error 1195

                         

                        I'm searching for the info. regarding that.....

                         

                        thanks