Thanks for explanations for override and normal. I will try later.
@Stephane, @IanHarrigan1982 and @player_03 Thanks for support If my whole completed frameworks like MinimalComps for Haxe I promise that I will add Menu and MenuItem ( look like Ghostwire AspireUI )
Because I really wait for good userinterface like Haxe-UI but Haxe-UI is incompatible to Away3D So sad because I want components for my map editor like so close AwayBuilder
How does component work if I use “top”, “left”, “right” and “bottom” like Flex SDK Components?
If my frameworks release than I will give you free because you support my code to fix and find good solutions. that is why I want give you big thanks for support.
Good supporters: @player_03, @Stephane , @restorer and @IanHarrigan1982!
Do not worry - I want release my whole completed framework than you get free components.
Why does it happen?
I have tried why do you not say truth. But i create Label than it happens hide???
package net.sourceskyboxer.components;
import openfl.display.DisplayObjectContainer;
import openfl.display.Sprite;
import openfl.events.Event;
import openfl.events.EventDispatcher;
/**
* ...
* @author Jens Eckervogt
*/
@:event(name = "resize", type = "openfl.events.Event")
@:event(name = "draw", type = "openfl.events.Event")
class Component extends Sprite
{
private var _width:Float = 0;
private var _height:Float = 0;
private var _tag:Int = -1;
private var _enabled:Bool = true;
public static var DRAW:String = "draw";
/**
* @param parent
* @param xpos
* @param ypos
*/
public function new(parent:DisplayObjectContainer = null, xpos:Float = 0, ypos:Float = 0)
{
super();
setMove(xpos, ypos);
openflInit();
if (parent != null)
{
parent.addChild(this);
}
if (xpos != 0)
{
xpos = 0;
}
if (ypos != 0)
{
ypos = 0;
}
}
private function openflInit():Void
{
addChildren();
invalidate();
}
private function addChildren():Void
{
}
private function invalidate():Void
{
draw();
addEventListener(Event.ENTER_FRAME, onInvalidate);
}
/**
*
* @param xpos
* @param ypos
*/
public function setMove(xpos:Float, ypos:Float):Void
{
x = Math.round(xpos);
y = Math.round(ypos);
}
/**
*
* @param w
* @param h
*/
public function setSize(w:Float, h:Float):Void
{
_width = w;
_height = h;
dispatchEvent(new Event(Event.RESIZE));
invalidate();
}
public function draw():Void
{
this.dispatchEvent(new Event(Component.DRAW));
}
private function onInvalidate(evt:Event):Void
{
removeEventListener(Event.ENTER_FRAME, onInvalidate);
draw();
}
/**
* getters and setters
*/
// WIDTH
#if flash @:getter(width) #else override #end
public function get_width():Float
{
return _width;
}
#if flash @:setter(width) #else override #end
public function set_width(_f:Float): #if flash Void #else Float #end
{
#if !flash return _f = _width; #end
invalidate();
this.dispatchEvent(new Event(Event.RESIZE));
}
// HEIGHT
#if flash @:getter(height) #else override #end
public function get_height():Float
{
return _height;
}
#if flash @:setter(height) #else override #end
public function set_height(_f:Float): #if flash Void #else Float #end
{
#if !flash return _f = _height; #end
invalidate();
this.dispatchEvent(new Event(Event.RESIZE));
}
// Y
#if flash @:getter(y) #else override #end
public function get_y():Float
{
return #if flash super.y; #else super.get_y(); #end
}
#if flash @:setter(y) #else override #end
public function set_y(_f:Float): #if flash Void #else Float #end
{
#if flash super.y = _f; #else super.set_y(_f); #end
#if !flash return _f; #end
}
// X
#if flash @:getter(x) #else override #end
public function get_x():Float
{
return #if flash super.x; #else super.get_x(); #end
}
#if flash @:setter(x) #else override #end
public function set_x(_f:Float): #if flash Void #else Float #end
{
#if flash super.x = _f; #else super.set_x(_f); #end
#if !flash return _f; #end
}
public var tag(get, set):Int;
private function set_tag(value:Int):Int
{
return value = _tag;
}
private function get_tag():Int
{
return _tag;
}
public var enabled(get, set):Bool;
private function set_enabled(value:Bool):Bool
{
return value = _enabled;
mouseEnabled = mouseChildren = _enabled;
tabEnabled = value;
alpha = _enabled ? 1.0 : 0.5;
}
private function get_enabled():Bool
{
return _enabled;
}
/**public var ssbTop(get, set):Float;
private function get_ssbTop():Float
{
return this.y;
}
private function set_ssbTop(value:Float):Float
{
return value = this.y;
}
public var ssbLeft(get, set):Float;
private function get_ssbLeft():Float
{
return this.x;
}
private function set_ssbLeft(value:Float):Float
{
return value = this.x;
}**/
}
And I create Label:
package net.sourceskyboxer.components;
import openfl.display.DisplayObjectContainer;
import openfl.text.TextField;
import openfl.text.TextFormat;
import openfl.text.TextFieldAutoSize;
import openfl.events.Event;
import openfl.events.EventDispatcher;
/**
* ...
* @author Jens Eckervogt
*/
@:event(name = "draw", type = "openfl.events.Event")
class Label extends Component
{
private var _autoSize:Bool = true;
private var _text:String = "";
private var _tf:TextField;
/**
*
* @param parent
* @param xpos
* @param ypos
* @param text
*/
public function new(parent:DisplayObjectContainer=null, xpos:Float=0, ypos:Float=0, text:String = "")
{
this._text = text;
super(parent, xpos, ypos);
}
override private function openflInit():Void
{
super.openflInit();
mouseEnabled = false;
mouseChildren = false;
}
override private function addChildren():Void
{
_height = 24;
_tf = new TextField();
_tf.height = _height;
_tf.embedFonts = Style.embedFonts;
_tf.selectable = false;
_tf.mouseEnabled = false;
_tf.defaultTextFormat = new TextFormat(Style.fontName, Style.fontSize, Style.LABEL_TEXT);
_tf.text = _text;
addChild(_tf);
draw();
}
override function draw():Void
{
super.draw();
_tf.text = _text;
if(_autoSize)
{
_tf.autoSize = TextFieldAutoSize.LEFT;
_width = _tf.width;
this.dispatchEvent(new Event(Event.RESIZE));
}
else
{
_tf.autoSize = TextFieldAutoSize.NONE;
_tf.width = _width;
}
_height = _tf.height = 18;
}
public var text(get, set):String;
private function set_text(t:String):String
{
return t = _text;
if(_text == null) _text = "";
invalidate();
}
private function get_text():String
{
return _text;
}
public var autoSize(get, set):Bool;
private function set_autoSize(b:Bool):Bool
{
return b = _autoSize;
}
private function get_autoSize():Bool
{
return _autoSize;
}
public var textfield(default, null):TextField;
private function get_textField():TextField
{
return _tf;
}
}
And try Main:
package;
import openfl.display.Sprite;
import net.sourceskyboxer.components.Label;
/**
* ...
* @author Jens Eckervogt
*/
class Main extends Sprite
{
public function new()
{
super();
var lbl:Label = new Label(this, 40, 40, "Hello World!");
addChild(lbl);
}
}
I try build “openfl test flash” = Nothing see label…
HTML working! Windows/CPP working! Neko working!
What does it happen with your improvement???
Why not in Flash??? Please explain me! I can not understand that why do you use bad return set_x(_f); I don’t know that.