Book a Demo

Author Topic: ActionScript 3  (Read 6692 times)

tathata

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
ActionScript 3
« on: April 04, 2006, 11:46:10 am »
Just downloaded the latest patch for EA 6.1 (789).  According to the change list it says it has ActionScript 3 support but when I try to generate code I end up with only ActionScript 2 code.  Also when I try to import ActionScript 3 code I get the following parse error: Unexpected symbol: interface

I did go into Tools > Options > Source Code Engineering > ActionScript and changed "Default Version" to 3.0.

Since AS3 support is so new it doesn't look like the docs have been updated.  Is there something else I am missing?  I would really love to test this out!

Thanks,
Lance

tathata

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: ActionScript 3
« Reply #1 on: April 04, 2006, 12:53:45 pm »
Well, I found a new help file one the web site.  Didn't notice that this isn't included with the patch files.

AS3 is listed in the new docs along with some specifics about it.

For some reason my code is still coming out as:

interface IProjectPhase
{
    function get id(): String;
   
    function get name(): String;
}//end IProjectPhase

Where I would expect it to be:

package com.md.tt3.vo
{
    public interface IProjectPhase
    {
         function get id(): String;
   
         function get name(): String;
    }//end IProjectPhase
}


I set the namespace root but still no package statement.

I guess the package statement might not be necissary and I will try to compile the code shortly and see if the compiler complains.  Also it probably isn't important that the interface statement has an access level specified as the language doesn't allow you to have private classes or interfaces.  The above code I was expecting would have been the code the Flex Builder2 Beta2 would have output which may change in the future anyway ;-)

However it is important to note that the code I expected will not import into EA properly because it gets hung up on the public access level being set on the interface.  However the Flex2 compiler currently doesn't have a problem with it and the Flex2 builder actually puts it in there when you create a new interface file.

If I run into any further problems I will post an update.

Thanks,
Lance
« Last Edit: April 04, 2006, 12:56:49 pm by tathata »

tathata

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: ActionScript 3
« Reply #2 on: April 04, 2006, 02:37:18 pm »
Ok, after some more testing the package statement followed by the full namespace is required.  Does anyone have a suggestion how to get this to show up when generating code?  Again I do have a Namespace root set up already but still no namespace being output.

Also we need to have access modifiers before all "class" or "interface" statements.  My understanding is that all interfaces and classes in AS3 can only be marked public but even so the compiler says it can't find my interface unless you put the public access modifier before the interface declaration.

I have modified my base code export template to convert the classScope property in the Class Declaration script so it now puts the proper scope before these.  However after doing this EA can no longer import them! :-(

Thanks,
Lance

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: ActionScript 3
« Reply #3 on: April 04, 2006, 04:13:40 pm »
Well, I tried to replicate your problem, but I got the following.

Code: [Select]
package com.md.tt3.vo
{
/**
* @author Simon McNeilly
* @version 1.0
* @created 05-Apr-2006 8:09:40 AM
*/
interface IProjectPhase
{
   public function get id(): String;

   public function get name(): String;

}//end IProjectPhase

}

The package appears to generate correctly, so you probably have the namespace set incorrectly.  What package did you set as a namespace root?  It should be the package above 'com' (at a guess I would say 'Class Model') and none of the packages below that point.  Having 'vo' set as a namespace root would result in the ouput you are seeing.

For more information on how namespaces (in the normal sense, not actionscript 3 sense) are handled in EA please see http://www.sparxsystems.com.au/EAUserGuide/index.html?namespaces.htm.

I can confirm that the scope on the interface is missing, we'll add that in our next release.

tathata

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: ActionScript 3
« Reply #4 on: April 04, 2006, 04:33:29 pm »
Quote
For more information on how namespaces (in the normal sense, not actionscript 3 sense) are handled in EA please see http://www.sparxsystems.com.au/EAUserGuide/index.html?namespaces.htm.


I think I just got it working.  I was setting the Namespace root on the package above 'com' but when I generate code by right clicking on the class it doesn't output the package and namespace.  However if I generage code from from the package level it does output the package and namespace just fine.

So this just seems to be my misunderstanding of how to use the program properly.

Quote
I can confirm that the scope on the interface is missing, we'll add that in our next release.


Sounds great!  Over all it is working very well :-D

Thanks,
Lance

tathata

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: ActionScript 3 (Another Parse Problem)
« Reply #5 on: April 04, 2006, 05:01:06 pm »
Just found another parse problem.  The following line of code produces a "Unexpected symbol: *" when you try to import it.

In AS3 the * tells the compiler that you ment to leave the property untyped and to accept any type you pass to it.  Becuase AS3 doesn't have method overloading this is necessary.

protected function setProperty(property:String, newValue:*):void
{
//....
}

Thanks,
Lance


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: ActionScript 3
« Reply #6 on: April 04, 2006, 07:05:39 pm »
Well, it's not actually necessary.  There was already a syntax for doing that.

protected function setProperty(property:String, newValue):void
{
//....
}

We'll update the parser with that though.

tathata

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: ActionScript 3 (Another one)
« Reply #7 on: April 05, 2006, 09:35:50 am »
Your right they both produce the same results.  The * isn't necessary but undoubtably going to be used.

One last request.  Could we get the "... (rest)" parameter added too?  Again this isn't necessary as you can already get at each functions parameters through the arguments variable however this again is something new to AS3 as another way of writting the function parameters.  I have a feeling I am going to run into this sooner or later when I try to import someone elses code :-/

Heres an example:
public function traceArgArray(x: int, ... args):void {
    for (var i:uint = 0; i < args.length; i++) {
       trace (args);
   }
}

Thanks much!!
Lance

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: ActionScript 3
« Reply #8 on: April 05, 2006, 03:13:45 pm »
Yes, I'm adding that.

Also being added are prototype fields (public prototype var myValue:String;), and literal functions (public var myOp:Function = function() {};).

What isn't going to be added (at least not yet) is the difference between default scopes between versions.  (Public is default in 2.0, while internal is default in 3.0)

Simon

Edited to remove smilies.
« Last Edit: April 05, 2006, 03:14:32 pm by simonm »

Dejan

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: ActionScript 3
« Reply #9 on: April 27, 2006, 02:45:50 pm »
I’ve noticed that you are missing scope declaration for Classes and Interfaces. In particular code template “Class Declaration” is missing the line:
%CONVERT_SCOPE(classScope)%
just  before writing a element type (class or interface).
Generated code should look like this:
package somepackage
{
  public class SomeClass
 {
      ...
  }
}

This is causing parse problem on reverse sync too.
Also I’m experiencing error while reversing classes placed within default package.
i.e.
package
{
  class SomeClass
 {
      ...
  }
}

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: ActionScript 3
« Reply #10 on: April 27, 2006, 03:25:18 pm »
Yes, the class scope was reported earlier in this thread.

The default package hasn't been added yet, but we'll see if it can be added for the next release.