A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: class AS3

  1. #1
    Member
    Join Date
    Feb 2010
    Posts
    79

    class AS3

    Actionscript Code:
    class Example
    {
      var methodExpression = function() {
          trace("hello");
          }
      function methodStatement() {}
    }

    var myEx:Example = new Example();
    myEx.methodExpression();
    myEx.methodStatement();

    I just put the above script in the frame. I could't get the trace output. Its showing error that "1131: Classes must not be nested." What's the solution for this error. It should be there in *.as file? I got this script from flash help guide. If it should be in *.as file means they should mention package also know. pls help me guys.....

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Yes, packages and classes must be in .as files rather than on the timeline.

    Leaving out the package statement is common when posting code, as it's fairly boilerplate if the class is in the default package. You still need it in your actual file.

  3. #3
    Member
    Join Date
    Feb 2010
    Posts
    79
    Got it. Thank u so much...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center