Tips
Notes
- This development document is intended for the hscript or haxe there are basic developers
- If you don't know any of them yet, please learn. This document uses many basic usages and does not explain too much
Look me
Notes
- In this Hscript because something irresistible causes a problem, you put an object of a custom class in array, and that object inherits a class, then the object will be cast to the class you inherited (the parent class), so you can't use the custom functions and variables in the object.
If you have a custom like this class
HScript
package some;
class YouObject extends FlxSprite
{
public function new()
{
super();
}
public function knock()
{
trace("who's that knocking ?");
}
}
Error Example
HScript
package blabla;
import some.YouObject;
class YouNextClass
{
var oneArray:Array = [];
public function new()
{
var youObj = new YouObject();
add(youObj);
youObj.knock(); // who's that knocking ?
oneArray.push(youObj);
oneArray[0].knock(); // Error: Function not found 'knock'
/*
Because when you use the index of array directly as an object and call the function of this object directly,
this YouObject was converted to his parent class for some reason FlxSprite,
because there is no such thing in the parent class function knock()
So he reported it wrong
*/
}
}
Notes
- If you don't want him to force a subclass to be a parent, add the following metadata to the location where you store the objects in array.
Correct example
HScript
package blabla;
import some.YouObject;
class YouNextClass
{
var oneArray:Array = [];
public function new()
{
var youObj = new YouObject();
youObj.knock(); // who's that knocking ?
oneArray.push(youObj);
@:unpass_standard //Put it where you need it.
oneArray[0].knock(); // who's that knocking ?
}
}