A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Only one projector instances

  1. #1
    Junior Member
    Join Date
    Nov 2001
    Posts
    3

    Only one projector instances

    Is there a way to stop multiple instances of my application from running ?

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    No, but you can quit if you see another instance is already running, Use a LocalConnection object. Check out Sonke Rohde's web site for an example of how to do this with Flex. It's just AS3 code so it will work just as well in Flash.

    If you really want to prevent the app from starting you'll have to use a third party swf2exe tool. My product, SWF Studio, has support for this that you can enable with a checkbox (see checkbox #15 in the link).

    Other swf2exe tools simply show you how to use a LocalConnection to do this but then you see the app start and disappear. With SWF Studio the app is shut down before it appears. As a bonus, the command line passed to the second instance can automatically be transferred to the running app. That's useful if you make a file association with your EXE because the file you double click on is passed to the running instance.

    The method SWF Studio uses guarantees that two instances of your app can't be started. The LocalConnection solution fails if the local connection fails, which happens a lot - it's not the most robust solution - just the only one if you stick with Flash by itself.
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  3. #3
    Junior Member
    Join Date
    Nov 2001
    Posts
    3
    Thanks alot.
    But could not get SWF Studio to go fullscreen like the flash projector. My fullscreen code looks like this :

    var screenRect:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
    stage.fullScreenSourceRect = screenRect;
    stage.displayState = StageDisplayState.FULL_SCREEN;

    Can i do the same with SWF studio, and get the same performance ?

  4. #4
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    You can only go fullscreen like this in response to a user input event like a keystroke or mouse click.

    If you REALLY need to do it without the user then you can fake it with SWF Studio by generating a fake keystroke or mouse event and having some code in your application to handle the event and go fullscreen.

    Here's an example. Just drop this in a new FLA and it will start in fullscreen mode.

    Code:
    ssCore.init();
    ssDefaults.synchronousCommands = true;
    
    if (stage)
       init();
    else
       addEventListener(Event.ADDED_TO_STAGE, init);
    	
    function init(e:Event):void
    {
       stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
       ssCore.Keyboard.sendKey({hwnd:ssGlobals.ssHWND, key:ssKey.VK_RIGHT});
    }
    
    function onKeyHandler(e:KeyboardEvent):void
    {
       stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyHandler);
       var r:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
       stage.fullScreenSourceRect = r;
       stage.displayState = StageDisplayState.FULL_SCREEN; 	
    }
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  5. #5
    Junior Member
    Join Date
    Nov 2001
    Posts
    3
    Awsome stuff ! Thanks again..
    And yes we need our game to directly in fullscreen, its a kids game. The last thing we are look for is way to do a CD/DVD check. A way to insure that our dvd is in the drive, as a very minimal copy protection..
    But again thanks alot, will give it a go tomorrow..

  6. #6
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The last thing we are look for is way to do a CD/DVD check. A way to insure that our dvd is in the drive, as a very minimal copy protection..
    Have a look at Avoiding Windows "Drive Not Ready" Errors. The title may not suggest it, but the included example shows how to enumerate all the drives on a system and get their labels. You can use this to check (a) that the label is correct and (b) that it is really a CD. It's not fool-proof but, as you said, just very minimal copy protection.

    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  7. #7
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Sorry, one other function you might want to call is FileSys.driveType which will tell you whether you're looking at a "CDROM" or something else.

    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center