views:

95

answers:

5

This may be a weird question, but I'm wondering if there's any way to efficiently (perhaps using namespaces?) have different default variables in a class per developer in an actionscript project. I ask because we're currently working on a series of Flash games: 24 in total. Each is loaded by a shell container. The shell receives a flash var for which game to load. In our development environment (Flash/FlashDevelop), there are no flashvars, so a constant in the AS defines which game to load when there's no flashvar:

/** Game to load during debugging if the game param is not set via flashvars. */
public static const DEFAULT_GAME:String = "gameName";

So each developer changes this to the game they are working on. However, when commiting changes to the repository (svn), the developer would have to change this back or undo changes, and each dev has to change this to their game when someone else changes it.

Wondering if there's a way to specify default params similar to Flashvars in the Flash IDE or a user-specific file so that the code can remain untouched with hacky debug vars. I know in Flex you can set the flashvars in the html template, and then each developer could have their own publish folder and svn:ignore that. Perhaps just have each developer create a non-commited XML file that defines their user params? I donno, any ideas?!

+5  A: 

Developer-specific config files tend to work.

Have a "default" configuration in the repository with .default or .sample or something appended to the filename, and when a developer checks it out for the first time, they copy that file, remove the extension, and customize it as much as they want without affecting anyone else.

Is there a better way? Probably. But I haven't found it.

Anon.
+1 have a developer-specific file that is ignored by SVN. Nice and easy.
Pekka
+2  A: 

Store the data in a Local Shared Object and then each developer can have their own defaults without any hacky stuff. Create a form that is only accessible locally and use it to view/edit the defaults. Store the data in a LSO. On app start, check for FlashVars, and if not present, check for the LSO.

Sam
Nice solution! Will try that as well.
Typeoneerror
I think this would be a great AIR application!
Typeoneerror
A: 

There are a couple of solutions. A good one from a programming standpoint would be to have a separate Static class called "LocalConfig.as".

In your original .as file. There would be (pseudo code):

import common.LocalConfig;
...
public static const DEFAULT_GAME:String = LocalConfig.gameName;
...

}

Let's use a Static class to make it easier (pseudo code):

// Static class:
 package
{
    public class LocalConfig
    {
        public static var gameName:String = "Game1";


        public function LocalConfig()
        {}
    }
}

Next step, You check it into your common/LocalConfig folder of your project in Source Control.Then, set this in your local machines to ignore from checking out so it doesn't exist on your local user machine.

Lastly, you wanna put that into your programmer's local "global include/common/" folder isolated from the Source Control process.

EDIT:

Deleted my Singleton class reference. Using Static class is sufficient.

JONYC
Not sure why you think the class need to be a Singleton, and makes sense for the property to be static, but I would recomend it for the class.
TandemAdam
You are right. Singleton doesn't make sense in this case when the variable is constant
JONYC
+1  A: 

Well you could do that with FDT:

check "Open URI after compliation" (debug configuration panel)

and set URI :

bin/main.swf?test="this is a test"&test2="this is a test"

this will act as a flashVar.

OXMO456
Oh, that would be pretty nice. I guess it'd have to be compiled in FDT and not Flash, huh? Where is this debug config panel?
Typeoneerror
Ah nevermind. I thought FDT was something else. Don't have that. That's a nice feature though. Flex has a similar feature as well.
Typeoneerror
+2  A: 

Hello !

You could use conditional compilation inside the FLASH IDE.

Here is an exemple of code :

package{

    import flash.display.Sprite;

    public class Main extends Sprite {

        CONFIG::USER_A
        private static const PATH:String="user_a_path";
        CONFIG::USER_B
        private static const PATH:String="user_b_path";

        public function Main(){
            trace("current path >",PATH);
        }       

    }

}

Then add 2 constants inside the flash IDE compilation options :

CONFIG::USER_A
CONFIG::USER_B

And set value false or true for user switching

More info here

OXMO456
Really?! Wow, I had no idea. If this works, you're a winner.
Typeoneerror
Yes it works fine : )I have added in the answer a link to the adobe help related to the conditional compilation
OXMO456
Ah, CS4! Sadly we're using CS3 still at work. Great tip though. I think that's the best solution for what I asked, so you win.
Typeoneerror