开发者

Default variables with multiple developers

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?!


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.


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


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜