One more question, advice on organization

David B's Avatar

David B

27 Oct, 2011 01:42 PM

Again, coming to an existing very small Flex project without any Flex experience, and working with Gradle for the first time, so I apologize if where I'm coming from is a woefully uninformed place. =)

The small code base is all intermingled in a single directory. .as, .mxml, etc. Currently the flex code is being built with ant. It makes a full compc pass over the directory to generate a .swc, then a full mxmlc to generate the .swf while referencing the .swc. This works great.

Having trouble getting this to work with Gradle while using your examples as a guide. Within the code I've got a Main.mxml which uses a MainApp.as (xmlns:p="com.components.MainApp" + parent p:MainApp tag).

Whenever I run type=swf over the code, I'm told MainApp.as isn't available. Specifically "Unable to locate specified base class 'com.components.MainApp' for component class 'Main'." I assume this is because the .swc needs to be created first? Your examples seem to have the swf created last. I've tried breaking Main.as out into another directory/subproject and building it as a .swc and have the client depend on it. The problem is MainApp uses a MainEventHandler.as, which has methods that replace the viewer with different chart views on item click. So Main.mxml ==> MainApp.as ==> MainEventHandler ==> back to other client code. Bit circular, but I don't know enough to know if this is common with Flex.

So without knowing any better, my big question is..is there a way to run and generate a .swc over the same subproject? So I could run swc over the project, then go back and run swf? Or is there a better way? Code it better? =)

  1. Support Staff 1 Posted by Yennick Trevels on 27 Oct, 2011 02:09 PM

    Yennick Trevels's Avatar

    It all depends on the situation.
    When it's a small project that will stay small, then it's probably easier to keep it all in one project and only have one build.gradle file (which will have a type='swf'), no need to generate a seperate swc in that case.
    When it's a project that is/will become large then you should separate the code into several subprojects. e.g. one which contains the services, one which contains general utility classes, one which contains your domain models etc.
    In that case you'll need a build.gradle file for each project.

    There is no way (as far as I know) to run multiple gradle builds in a single subproject. Even when it would be possible I wouldn't do it since it cleaner to have seperate projects.

    To answer your question regarding the MainApp.as, if that class is in the srcDir (src/main/actionscript by default) then GradleFx should be able to find it and compile it in the swf. So if your project is going to stay very small then I would keep it as one project, with one build.gradle file which has a type='swf' property, and all your classes under %yourProjectRoot%/src/main/actionscript. Then it won't create a seperate swc but just one swf which will contain everything.

    If you can't get it running with this advice, then let me know ;)

  2. Support Staff 2 Posted by Yennick Trevels on 06 Nov, 2011 06:46 AM

    Yennick Trevels's Avatar

    Did this advice help you?

  3. Yennick Trevels closed this discussion on 27 Jan, 2012 12:33 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac