Skip to content

Commit

Permalink
Restrict Loaders to OpenFL 9.5
Browse files Browse the repository at this point in the history
So, I screwed up a bit and released features meant for a later version of OpenFL(9.5) initially in 3.3.0.

We probably need to structure things the same as we do for lime and openfl so that we can avoid merging changes to the master that are meant for later versions. This will prevent boo-boo's like this from happening in the future.
  • Loading branch information
dimensionscape committed Oct 28, 2024
1 parent 2729858 commit 68eeee5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
20 changes: 17 additions & 3 deletions src/swf/SWFLoader.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package swf;

#if (openfl >= "9.5.0")
import openfl.display.DisplayObject;
import openfl.display.IDisplayObjectLoader;
import openfl.display.LoaderInfo;
Expand All @@ -13,13 +14,21 @@ import openfl.system.LoaderContext;
import openfl.utils.ByteArray;
import openfl.utils.Future;
import openfl.utils.Promise;
#end

class SWFLoader implements IDisplayObjectLoader
class SWFLoader #if (openfl >= "9.5.0") implements IDisplayObjectLoader #end
{
public function new() {}

public function new() {
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#end
}

public function load(request:URLRequest, context:LoaderContext, contentLoaderInfo:LoaderInfo):Future<DisplayObject>
{
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#else
if (contentLoaderInfo.contentType != null && contentLoaderInfo.contentType == "application/x-shockwave-flash")
{
var promise = new Promise<DisplayObject>();
Expand All @@ -46,15 +55,20 @@ class SWFLoader implements IDisplayObjectLoader
{
return null;
}
#end
}

public function loadBytes(buffer:ByteArray, context:LoaderContext, contentLoaderInfo:LoaderInfo):Future<DisplayObject>
{
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#else
var swf = new SWF(buffer);
var content:DisplayObject = new swf.runtime.MovieClip(swf.data);
@:privateAccess contentLoaderInfo.width = swf.width;
@:privateAccess contentLoaderInfo.height = swf.height;
@:privateAccess contentLoaderInfo.frameRate = swf.frameRate;
return Future.withValue(content);
#end
}
}
18 changes: 15 additions & 3 deletions src/swf/exporters/animate/AnimateLoader.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package swf.exporters.animate;

#if (openfl >= "9.5.0")
import openfl.utils.Promise;
import openfl.display.DisplayObject;
import openfl.display.IDisplayObjectLoader;
Expand All @@ -14,19 +14,31 @@ import openfl.net.URLRequestMethod;
import openfl.system.LoaderContext;
import openfl.utils.ByteArray;
import openfl.utils.Future;

#end
class AnimateLoader implements IDisplayObjectLoader
{
public function new() {}
public function new() {
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#end
}

public function load(request:URLRequest, context:LoaderContext, contentLoaderInfo:LoaderInfo):Future<DisplayObject>
{
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#else
// TODO
return null;
#end
}

public function loadBytes(buffer:ByteArray, context:LoaderContext, contentLoaderInfo:LoaderInfo):Future<DisplayObject>
{
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#else
return null;
#end
}
}
18 changes: 15 additions & 3 deletions src/swf/exporters/swflite/SWFLiteLoader.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package swf.exporters.swflite;

#if (openfl >= "9.5.0")
import lime.graphics.Image;
import openfl.display.DisplayObject;
import openfl.display.IDisplayObjectLoader;
Expand All @@ -15,14 +15,21 @@ import openfl.utils.ByteArray;
import openfl.utils.Future;
import openfl.utils.Promise;
import swf.exporters.SWFLiteExporter;

#end
@:access(swf.exporters.swflite.SWFLiteLibrary)
class SWFLiteLoader implements IDisplayObjectLoader
{
public function new() {}
public function new() {
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#end
}

public function load(request:URLRequest, context:LoaderContext, contentLoaderInfo:LoaderInfo):Future<DisplayObject>
{
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#else
if (contentLoaderInfo.contentType != null && contentLoaderInfo.contentType == "application/x-shockwave-flash")
{
var promise = new Promise<DisplayObject>();
Expand All @@ -49,10 +56,14 @@ class SWFLiteLoader implements IDisplayObjectLoader
{
return null;
}
#end
}

public function loadBytes(buffer:ByteArray, context:LoaderContext, contentLoaderInfo:LoaderInfo):Future<DisplayObject>
{
#if (openfl < "9.5.0")
openfl.Lib.notImplemented();
#else
// TODO: No intermediate format
var swf = new SWF(buffer);
var exporter = new SWFLiteExporter(swf.data);
Expand Down Expand Up @@ -82,5 +93,6 @@ class SWFLiteLoader implements IDisplayObjectLoader
@:privateAccess contentLoaderInfo.frameRate = swf.frameRate;
@:privateAccess contentLoaderInfo.assetLibrary = library;
return Future.withValue(content);
#end
}
}

0 comments on commit 68eeee5

Please sign in to comment.