Skip to content

Instantly share code, notes, and snippets.

@larsiusprime
Created April 3, 2016 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save larsiusprime/e60dd455f19d709c36936480b075a29d to your computer and use it in GitHub Desktop.
Save larsiusprime/e60dd455f19d709c36936480b075a29d to your computer and use it in GitHub Desktop.
silly OpenFL 3-window 3DS mockup
Put this image under "assets":
http://imgur.com/wFG4Tgc
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="CustomBuild" />
<movie input="" />
<movie path="project.xml" />
<movie fps="30" />
<movie width="800" />
<movie height="600" />
<movie version="1" />
<movie minorVersion="0" />
<movie platform="Lime" />
<movie background="#FFFFFF" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="T:\git\openfl" />
<class path="T:\git\lime" />
<class path="C:\HaxeToolkit\haxe\lib\actuate\1,8,6" />
<class path="Source" />
<class path="T:\git\openfl\extern" />
<class path="Export\html5\haxe" />
</classpaths>
<!-- Build options -->
<build>
<option directives="openfl=3.6.0&#xA;lime=2.9.0&#xA;actuate=1.8.6&#xA;openfl-next&#xA;tools=2.9.0&#xA;no-compilation&#xA;openfl-html5&#xA;canvas&#xA;lime-html5&#xA;html5&#xA;web&#xA;html5&#xA;display" />
<option flashStrict="False" />
<option noInlineOnDebug="False" />
<option mainClass="ApplicationMain" />
<option enabledebug="False" />
<option additional="--remap flash:openfl&#xA;--macro allowPackage(&quot;flash&quot;)" />
</build>
<!-- haxelib libraries -->
<haxelib>
<!-- example: <library name="..." /> -->
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<!-- example: <compile path="..." /> -->
</compileTargets>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<hidden path="obj" />
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand>"$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb</preBuildCommand>
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>
/***GOES in source/ directory***/
package;
import motion.Actuate;
import openfl.display.Stage;
import lime.app.Application;
import lime.app.Config.WindowConfig;
import lime.system.System;
import lime.ui.Window;
import openfl.display.Bitmap;
import openfl.display.BitmapData;
import openfl.display.Sprite;
import openfl.Assets;
import openfl.events.Event;
import openfl.geom.Point;
import openfl.Lib;
import openfl.utils.Timer;
class Main extends Sprite {
public static var app:Application;
public function new () {
super ();
app = Lib.application;
var bitmap = new Bitmap (Assets.getBitmapData ("assets/3ds.png"));
addChild (bitmap);
bitmap.x = (stage.stageWidth - bitmap.width) / 2;
bitmap.y = (stage.stageHeight - bitmap.height) / 2;
topWindow = app.windows[1];
bottomWindow = app.windows[2];
app.windows[0].onMove.add(onMainWindowMove);
app.windows[0].onClose.add(onWindowClose);
app.windows[1].onClose.add(onWindowClose);
app.windows[2].onClose.add(onWindowClose);
app.windows[0].onFocusIn.add(onWindowFocus);
app.windows[1].onFocusIn.add(onWindowFocus);
app.windows[2].onFocusIn.add(onWindowFocus);
onMainWindowMove(app.windows[0].x, app.windows[0].y);
stage.addEventListener(Event.ENTER_FRAME, onEnter, false, 0, true);
}
private function onEnter(event:Event):Void
{
if (raisedThisFrame > 0)
{
raisedThisFrame -= 1;
}
}
private var topWindow:Window;
private var bottomWindow:Window;
private var topPt:Point = new Point(161, 79);
private var bottomPt:Point = new Point(201, 413);
private var raisedThisFrame:Int = 0;
private function onWindowFocus():Void
{
if (raisedThisFrame == 0)
{
app.windows[0].raise();
topWindow.raise();
bottomWindow.raise();
raisedThisFrame = 10;
}
}
private function onMainWindowMove(X:Float, Y:Float):Void
{
topWindow.x = Std.int(X + topPt.x);
topWindow.y = Std.int(Y + topPt.y);
topWindow.move(topWindow.x, topWindow.y);
topWindow.raise();
bottomWindow.x = Std.int(X + bottomPt.x);
bottomWindow.y = Std.int(Y + bottomPt.y);
bottomWindow.move(bottomWindow.x, bottomWindow.y);
bottomWindow.raise();
}
private function onWindowClose():Void
{
app.windows[0].close();
topWindow.close();
bottomWindow.close();
System.exit(0);
}
}
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="Displaying a Bitmap" package="org.openfl.samples.displayingabitmap" version="1.0.0" company="OpenFL" />
<window width="720" height="720" resizable="false" id="0" />
<window width="400" height="240" resizable="false" background="0xFF0000" id="1" borderless="true"/>
<window width="320" height="240" resizable="false" background="0x0000FF" id="2" borderless="true"/>
<app main="Main" path="Export" file="DisplayingABitmap" />
<source path="Source" />
<haxelib name="openfl" />
<haxelib name="actuate"/>
<assets path="Assets" rename="assets" />
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment