Did I encounter an error while packing the air?

PS C:\Users\Administrator\Desktop\game> lime test air
Warning : (WDeprecated) -swf-header has been deprecated, use -D swf-header instead
starling/core/Starling.hx:688: [Starling] Context ready. Display Driver: DirectX9 (Standard Extended)
starling/assets/AssetManager.hx:1071: [AssetManager] Enqueuing ‘bg.png’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding texture ‘bg’
starling/assets/AssetManager.hx:1071: [AssetManager] Enqueuing ‘map.jpg’
starling/assets/AssetManager.hx:1071: [AssetManager] Enqueuing ‘ros.png’
starling/assets/AssetManager.hx:1071: [AssetManager] Enqueuing ‘ros.xml’
starling/assets/AssetManager.hx:1071: [AssetManager] Enqueuing ‘ww.png’
starling/assets/AssetManager.hx:1071: [AssetManager] Enqueuing ‘ww.xml’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding xml ‘ros’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding texture ‘map’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding texture ‘ros’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding texture ‘ww’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding xml ‘ww’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding textureAtlas ‘ros’
starling/assets/AssetManager.hx:1071: [AssetManager] Adding textureAtlas ‘ww’
ReferenceError: Error #1069
PS C:\Users\Administrator\Desktop\game>

This is almost certainly an exception thrown by your AIR app at run-time.

If you’d like to confirm, try running lime build air instead of lime test air. That will build your app only, without running it.

Have you tried testing via HashLink or Neko, to see if a more useful error is thrown?

If I’m not mistaken, Error #1069 indicates it’s trying to access a property or method that wasn’t what it expected.

lime test hl
lime test neko

I have a class called ‘extends Sprite’ and I have a public function in it. However, when I execute it externally, I encounter an error because ‘Sprite’ is a sealed class and cannot read my public function

I have successfully called the function using both of the following methods

1

if (Reflect.hasField(dis, "init")) {
            Reflect.callMethod(dis, Reflect.field(dis, "init"), [team, x, y]);
        }

2

untyped dis.init(team, x, y);

Later on, I used an interface

interface IRole {
	function init(team:Int, x:Int, y:Int):Void;
}

package;

import openfl.geom.Point;
import nape.geom.Vec2;
import starling.events.EnterFrameEvent;
import starling.events.Event;
import starling.display.Sprite;

class Role1 extends Roles implements IRole {
	public function new(teams:Int) {
		super();
		// this.addEventListener(Event.ADDED_TO_STAGE, init);
	}

	public function init(t:Int, ix:Int, iy:Int):Void {
		vy = -1;
		lastThisY = 0;
		speed = 100;
		jump_boo = false;
		tk_boo = false;

		team = t;
		this.x = ix;
		this.y = iy;

		mc = new Anim();
		mc.addAnimation("wait", Load.getInstance().ass.getTextures("wait_"), 7);
		mc.addAnimation("move", Load.getInstance().ass.getTextures("move_"), 7);
		this.addChild(mc);

		mc.gotoAndPlay("wait", 0);
...
cast(dis, IRole).init(team, x, y);
package;

import nape.phys.Body;
import starling.display.Sprite;

class Roles extends Sprite {
	public var mc:Anim;
	public var speed:Float;
	public var team:Int;
	public var jump_boo:Bool;
	public var tk_boo:Bool;
	public var vy:Float;
	public var lastThisY:Float;

	public var role_body:Body;
	public var mc_body:Body;
	public var hit_body:Body;

	public function new() {
		super();
	}
}

I’m not quite sure what you mean by “when I execute it externally”.

Extending Sprite for your own classes is quite normal.

I’d generally suggest trying to avoid reflection, as it can be problematic.

From the Haxe documentation:

Reflection can be a powerful tool, but it is important to understand why it can also cause problems. As an example, several functions expect a String argument and try to resolve it to a type or field…

01

02

(post deleted by author)

package;

import starling.display.Sprite;

class De extends Sprite {
	public function new() {
		super();
	}

	public function init():Void {
		trace(666);
	}
}

There are many map classes and character classes in the game, and I have written specialized functions to instance maps and characters. I cannot write the specific type of class in the function because there are too many classes, so now I have implemented the same interface for the classes

public final role:Dictionary<String, Dynamic> = new Dictionary();
public var map:Sprite;
public var player:Sprite;

public function new_map(lei:Int, x:Int = 0, y:Int = 0):Sprite {
		var news:Class<Dynamic> = null;
		switch (lei) {
			case 1:
				news = Map1;
		}
		if (map == null) {
			map = Type.createInstance(news, []);
		}
		if (map != null && map.stage == null) {
			map.x = x;
			map.y = y;
			this.addChild(map);
		}
		return map;
	}

	public function new_role(name:String, lei:String, team:Int, x:Int = 0, y:Int = 0):Sprite {
		var news:Class<Dynamic> = null;
		var dis:Sprite = null;
		switch (lei) {
			case "Role1":
				news = Role1;
		}
		if (role[name] == null) {
			dis = Type.createInstance(news, [team]);
			role[name] = dis;
			if (team == 1) {
				player = dis;
			};
		}
		map.addChild(dis);
		cast(dis, IRole).init(team, x, y);
		return role[name];
	}