2 Replies Latest reply on Sep 18, 2007 1:42 AM by msabljic

    Beginner OOP question in Flex

    msabljic Level 1
      I was wondering, why does the following code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      import flash.display.Sprite;

      public class Test extends Sprite{
      public function Test(){
      trace ("Test");

      Results with "1037:Packages cannot be nested" error during compilation. What i am trying to do is write a class with constructor and later some methods i can use in mxml for different component event actions. I know i am missing something, but not sure what. Can someone please help me with this?

      thanks in advance
        • 1. Beginner OOP question in Flex
          Karl_Sigiscar_1971 Level 3

          You should do one of two things:

          - Either you create a new .AS file for your class, specify a package and write a constructor for it.

          package com.bc.views.components {

          public class bcColorPicker {

          // Constructor

          public function bcColorPicker():void



          - Or you create a new .MXML file, in that case, you DO NOT indicate the package and you DO NOT need a constructor. The package of the MXML file being where it's located. If you want to instantiate your MXML file from another MXML file, the XML namespace (xmlns) you would specify would be what you would specify as a package for a class, e.g xmlns:bc="com.bc.views.components.* as opposed to package com.bc.views.components.
          • 2. Re: Beginner OOP question in Flex
            msabljic Level 1
            Thank you very much for your answer, it makes sense to me now :)