Skip to content

playvue/DOFlashPunk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

DO(DisplayObject)FlashPunk

A modified FlashPunk framework allowing a DisplayObject (like root) to be used in place of the Flash stage object.

FlashPunk was created by ChevyRay. Playvue Games LLC, nor Erik Jansson (CaffeineViking) claim any ownership of any kind to this awesome framework.

FlashPunk and HaxePunk both use the stage to add event listeners and to do other DisplayObject related stuff. But, many API’s and websites use underlying mechanisms that require control of the stage (or other things).

That puts FlashPunk and HaxePunk at a huge disadvantage, making games/programs built in them unusable (or hard to use at the very least) in a lot of very high profile websites (Playvue, Newgrounds, Kongregate, etc.) and their corresponding API’s.

Therefore, it might be smart to have a version of these awesome engines to run via the root (or other DisplayObjects) instead. Lucky for us, FlashPunk and HaxePunk are very nicely coded engines that are easily modifiable without completely breaking the entire engine. Even so, it was surprisingly easy:

First, lets modify FP.as (FlashPunk) or HXP.hx (HaxePunk). The gist here is to change the static stage variable type from Stage to DisplayObject. So basically:

public static var stage:Stage; -----> public static var stage:DisplayObject;

Now over to Engine.as (FlashPunk) or Engine.hx (HaxePunk). Here we remove anything that requires Stage specific (not DisplayObject, remember, Stage inherits DisplayObject) methods (stuff like align and scale). Here are the things I changed:

  1. Remove the onStage addEventListener and removeEventListener and also the method called onStage, but copying the remaining code to the end of the Engines constructor.
  2. remove the setStageProperties method and any calls it is making in the Engine (this is the really evil part of the code that depends on the Stage object methods).
  3. change FP.stage = stage to FP.stage = tdisplayObject.
  4. Now, on the constructor of Engines, we add another parameter. You guessed it (or not): tdisplayObject:DisplayObject. So, the constructor params of Engine now looks like this:
    Engine(tdisplayObject:DisplayObject, width:uint, height:uint, frameRate:Number = 60, fixed:Boolean = false)

Done! That was surprisingly easy, huh?

Cheers!

@CaffeineViking

About

A modified FlashPunk framework allowing a DisplayObject (like root) to be used in place of the Flash stage object.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published