0 Replies Latest reply on Mar 3, 2009 3:40 PM by lreadl

    switching from CS4 to flex

    lreadl Level 1
      I have a game I've written in AS3 class files. I've been compiling with CS4. The first frame of the main timeline has one line of code that calls a static method on a class, and passes it "this" (the main timeline). This is all the code the .fla contains; the .as files do everything. However, there are visual assets in the library of the .fla that the code needs to instantiate. Some of these assets are linked to class files, and some are not. In other words, say I have LinkedClass.as linked to library symbol, and another library symbol which is being exported for actionscript with no corresponding .as file, so the NonLinkedClass is automatically generated when the .fla is compiled. My static method contains both "new LinkedClass()" and "new NonLinkedClass()".

      I've set up an actionscript project in flex with one new class that I didn't have before when I was using CS4. In the constructor for this class, all I have is the same line of code I had on the first frame of the main timeline before, the static method that gets passed "this". (Does "this" still refer to the main timeline? In other words, is the class I'm compiling in my actionscript project in flex becoming the main class of a swf?)

      1. Is this even the right way to go about doing this? I'm pretty lost here. I've gone through tutorials having to do with MXML, but I'm not sure what relation they bear, if any, to what I want to do. How do I make something that compiled in CS4 compile in flex? (Keeping in mind, I have custom classes linked to library symbols, and also library symbol with no custom class, for which classes are defined automatically when CS4 compiles.)

      2. When I tried to compile the flex project, I got an error for NonLinkedClass, so I used CS4 to compile a .swc and added that .swc to the library for the flex project, and then I no longer got the error for NonLinkedClass. However, I continue to get errors for LinkedClass. LinkedClass has variables defined in the .as file, and display objects are assigned to those variables because I've put display object instances inside the library symbol LinkedClass is linked to and named them after the variables. This works fine when I compile with CS4, but with flex, these variables are coming up null. I tried adding this code to LinkedClass.as

      [Embed(source="pathToMyGameSwf/game.swf", symbol="LinkedClass")]

      but I get an error

      "An Embed variable must not have an existing value."

      Am I anywhere near the right track? Is there a tutorial for this problem specifically, that is, trying to port a project from CS4 to flex?