From c8d3ac1db7c1a02dea47d0daa643522563dedc6f Mon Sep 17 00:00:00 2001 From: shmyga Date: Tue, 15 Apr 2014 14:32:10 +0400 Subject: [PATCH] - --- haxework/gui/GroupView.hx | 4 ++-- haxework/gui/GuiBuilder.hx | 10 +++++----- haxework/gui/MovieView.hx | 25 ++++++++++++++++++++++--- haxework/gui/View.hx | 6 ++++-- haxework/gui/skin/ButtonColorSkin.hx | 4 ++-- haxework/net/callback/Callback.hx | 2 +- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/haxework/gui/GroupView.hx b/haxework/gui/GroupView.hx index 8b91c91..60a1d82 100755 --- a/haxework/gui/GroupView.hx +++ b/haxework/gui/GroupView.hx @@ -54,7 +54,7 @@ class GroupView extends SpriteView implements IGroupView { public function addView(view:IView):IView { views.push(view); viewsById.set(view.id, view); - content.addChild(view.content); + if (view.content != null) content.addChild(view.content); view.parent = this; invalidate(); return view; @@ -73,7 +73,7 @@ class GroupView extends SpriteView implements IGroupView { view.parent = null; viewsById.remove(view.id); views.remove(view); - content.removeChild(view.content); + if (view.content != null) content.removeChild(view.content); invalidate(); return view; } diff --git a/haxework/gui/GuiBuilder.hx b/haxework/gui/GuiBuilder.hx index 189329a..e9fac0a 100755 --- a/haxework/gui/GuiBuilder.hx +++ b/haxework/gui/GuiBuilder.hx @@ -68,11 +68,11 @@ class GuiB { } private static function instance(type:String):Dynamic { - var clazz:Class = Type.resolveClass(type); - if (clazz == null) throw new TypeError("Class \"" + type + "\" not found"); - var instance:Dynamic = Type.createInstance(clazz, []); - return instance; - } + var clazz:Class = Type.resolveClass(type); + if (clazz == null) throw new TypeError("Class \"" + type + "\" not found"); + var instance:Dynamic = Type.createInstance(clazz, []); + return instance; + } } class GuiF { diff --git a/haxework/gui/MovieView.hx b/haxework/gui/MovieView.hx index 21899f1..ab32b89 100755 --- a/haxework/gui/MovieView.hx +++ b/haxework/gui/MovieView.hx @@ -1,10 +1,13 @@ package haxework.gui; +import haxework.net.SwfLoader; import flash.display.MovieClip; +//ToDo: sprite wrapper? class MovieView extends View { public var movie(get, set):MovieClip; + public var movieUrl(default, set):String; public function new(?movie:MovieClip) { super(movie); @@ -21,6 +24,7 @@ class MovieView extends View { parent.content.removeChild(content); } content = value; + content.visible = visible; if (parent != null) { parent.content.addChildAt(content, index); } @@ -28,11 +32,26 @@ class MovieView extends View { return content; } + private function set_movieUrl(value:String):String { + movieUrl = value; + new SwfLoader().GET(movieUrl) + .success(function(data:MovieClip):Void { + movie = data; + }); + return movieUrl; + } + override public function update():Void { - if (contentSize && movie != null) { - width = movie.loaderInfo.width; - height = movie.loaderInfo.height; + if (contentSize && content != null) { + width = content.loaderInfo.width; + height = content.loaderInfo.height; } super.update(); + if (!contentSize && content != null) { + var s:Float = Math.min(width / content.loaderInfo.width, height / content.loaderInfo.height); + content.scaleX = content.scaleY = s; + content.x = (width - content.loaderInfo.width * s) / 2; + content.y = (height - content.loaderInfo.height * s) / 2; + } } } \ No newline at end of file diff --git a/haxework/gui/View.hx b/haxework/gui/View.hx index e91b0ea..8326714 100755 --- a/haxework/gui/View.hx +++ b/haxework/gui/View.hx @@ -86,8 +86,10 @@ class View implements IView { } public function update():Void { - content.x = x; - content.y = y; + if (content != null) { + content.x = x; + content.y = y; + } var skin:ISkin> = currentSkin(); if (contentSize && skin != null && Std.is(skin, ISize)) { var size:ISize = cast(skin, ISize); diff --git a/haxework/gui/skin/ButtonColorSkin.hx b/haxework/gui/skin/ButtonColorSkin.hx index eb6323d..580a18b 100755 --- a/haxework/gui/skin/ButtonColorSkin.hx +++ b/haxework/gui/skin/ButtonColorSkin.hx @@ -9,8 +9,8 @@ class ButtonColorSkin implements ISkin { public var color(default, set_color):Int; public var alpha(default, default):Float; + public var disable(default, default):Int; private var colors:Map; - private var disable:Int; public function new(?color:Int = 0xffffff, ?alpha:Float = 1.0) { this.color = color; @@ -22,7 +22,7 @@ class ButtonColorSkin implements ISkin { colors.set(ButtonState.UP, value); colors.set(ButtonState.DOWN, ColorUtils.diff(value, -64)); colors.set(ButtonState.OVER, ColorUtils.diff(value, 64)); - disable = ColorUtils.multiply(value, 0.6); + //disable = ColorUtils.multiply(value, 0.6); return value; } diff --git a/haxework/net/callback/Callback.hx b/haxework/net/callback/Callback.hx index 7af9a76..56a16e9 100755 --- a/haxework/net/callback/Callback.hx +++ b/haxework/net/callback/Callback.hx @@ -56,7 +56,7 @@ class Callback implements ICallback { public function glue(callback:ICallback):ICallback { this._success = callback.callSuccess; this._fail = callback.callFail; - callback.dispose(); + //callback.dispose(); //ToDo: return this; }