Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions DataUtils.hx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import com.stencyl.graphics.G;
import com.stencyl.Engine;
import com.stencyl.models.Sound;
import nme.display.BitmapData;
import com.stencyl.utils.Assets;

import openfl.display.BitmapData;

class DataUtils {

public static function getTextData(file:String):String {
file = "assets/data/" + file;
#if (flash || js)
var text:String = nme.Assets.getText(file);
var text:String = Assets.getText(file);
#else
var text:String = FileSave.getText(file);
#end
Expand All @@ -22,7 +24,7 @@ class DataUtils {
public static function getImageData(file:String):BitmapData {
file = "assets/data/" + file;
#if (flash || js)
var image:BitmapData = nme.Assets.getBitmapData(file);
var image:BitmapData = Assets.getBitmapData(file);
#else
var image:BitmapData = FileSave.getImage(file);
#end
Expand Down Expand Up @@ -87,11 +89,11 @@ class DataUtils {
ext = ".mp3";
#end
var file:String = "assets/data/" + filename + ext;
var nmeSound:flash.media.Sound = nme.Assets.getSound(file);
return soundToStencyl(nmeSound, filename, ext);
var openflSound:openfl.media.Sound = Assets.getSound(file);
return soundToStencyl(openflSound, filename, ext);
}

public static function soundToStencyl(sound:flash.media.Sound, filename:String, ext:String):com.stencyl.models.Sound {
public static function soundToStencyl(sound:openfl.media.Sound, filename:String, ext:String):com.stencyl.models.Sound {
var stencylSound = new com.stencyl.models.Sound(-1, filename, true, false, 0.0, 1.0, ext #if (stencyl >= "4.0.0"), -1 #end);
stencylSound.streaming = false;
stencylSound.src = sound;
Expand Down
13 changes: 7 additions & 6 deletions FileSave.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import com.stencyl.behavior.Script;
import com.stencyl.behavior.TimedTask;
import com.stencyl.models.Font;
import com.stencyl.graphics.G;
import com.stencyl.utils.Assets;
import com.stencyl.utils.Utils;

import nme.display.BitmapData;
import nme.utils.ByteArray;
import haxe.io.Bytes;
import openfl.Assets;

import openfl.display.BitmapData;
import openfl.utils.ByteArray;

#if (openfl >= "4.0.0")
import openfl.geom.Rectangle;
Expand All @@ -22,7 +23,7 @@ import sys.io.*;
#if (openfl >= "4.0.0")
import lime.system.System.*;
#else
import nme.utils.SystemPath.*;
import openfl.utils.SystemPath.*;
#end

#end
Expand All @@ -46,7 +47,7 @@ class FileSave {
if (FileSystem.exists(path2)) {
content = File.getContent(path2);
} else {
content = nme.Assets.getText(path);
content = Assets.getText(path);
if (content == null) {
trace("ERROR: File does not exist at: " + path);
content = "";
Expand Down Expand Up @@ -86,7 +87,7 @@ class FileSave {
image = BitmapData.loadFromHaxeBytes(File.getBytes(path2));
#end
} else {
image = nme.Assets.getBitmapData(path);
image = Assets.getBitmapData(path);
}
if (image == null) {
trace("ERROR: File does not exist at: " + path);
Expand Down
8 changes: 7 additions & 1 deletion PlaySWF.hx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import haxe.Timer;

import com.stencyl.Engine;
import com.stencyl.utils.Assets;

import openfl.display.Loader;
import openfl.display.MovieClip;
import openfl.events.Event;
import openfl.utils.ByteArray;

#if flash
import flash.display.AVM1Movie;
#end

class PlaySWF {

Expand Down Expand Up @@ -33,7 +39,7 @@ class PlaySWF {
filepath = "assets/data/" + filename;

try {
bytes = openfl.Assets.getBytes(filepath);
bytes = Assets.getBytes(filepath);
} catch (e:Dynamic) {
trace("Could not find " + filename);
whenLoaded(false);
Expand Down