Permalink
Browse files

feature complete

  • Loading branch information...
1 parent b4c255b commit c36e1037c664b5759ddcd652594da5d79e676e5f @spotco committed May 12, 2012
View
Binary file not shown.
View
Binary file not shown.
View
@@ -48,6 +48,8 @@ package {
}
}
+ public static var DEFAULT_TXT:String = "Enter search";
+
}
}
View
@@ -5,6 +5,7 @@ package
import flash.geom.Rectangle;
import flash.text.AntiAliasType;
import flash.text.TextField;
+ import flash.net.*;
public class FloatButtonLabel extends Sprite {
@@ -16,13 +17,26 @@ package
public function FloatButtonLabel(j:JsonEntry) {
this.json_data = j;
- this.text = make_text(j.rel+" "+j.arg2, 40);
+
+ var title;
+ if (j.rel && j.arg2) {
+ title = j.rel + " " + j.arg2;
+ } else {
+ title = j.title;
+ }
+
+ var sc = 1;
+ if ( j.keyword.length > 20) {
+ sc = Math.max((40 - (j.keyword.length - 20)) / 40, 0.3);
+ }
+ this.text = make_text(j.keyword, sc * 65);
this.text.textColor = 0x161616;
this.addChild(this.text);
this.addEventListener(MouseEvent.CLICK, function() {
//MouseWindow.create_tooltip(json_data.arg1 + " " + json_data.rel + " " + json_data.arg2, json_data.content,"");
- MouseWindow.create_tooltip(json_data.title, json_data.content,"");
+ trace(json_data.url);
+ MouseWindow.create_tooltip(json_data.title, json_data.content,json_data.url);
});
Common.add_mouse_over(this);
this.addEventListener(MouseEvent.MOUSE_OVER, function() { mouseover = true; } );
@@ -38,7 +52,6 @@ package
public function update() {
if (this.mouseover) {
- trace("mov");
this.scaleX = 1;
this.scaleY = 1;
this.alpha = 1.0;
@@ -92,7 +105,7 @@ package
ntx.selectable = false;
ntx.defaultTextFormat = Common.getTextFormat(priority);
ntx.setTextFormat(Common.getTextFormat(priority));
- ntx.width = ntx.textWidth+10;
+ ntx.width = ntx.textWidth+30;
ntx.height = ntx.textHeight+10;
ntx.x = -ntx.width / 2;
ntx.y = -ntx.height / 2;
View
@@ -11,29 +11,34 @@ package {
public var date:String;
public var content:String;
+ public var keyword:String;
+
public var confidence:Number;
- public function JsonEntry(o:Object) {
- //var first = data[0];
- //trace(first["arg1"]);
- //trace(first["rel"]);
- //trace(first["arg2"]);
- //trace(first["confidence"]);
- //
- //var first_info = first["info"];
- //trace(first_info["title"]);
- //trace(first_info["content"]);
-
- this.arg1 = o["arg1"];
- this.rel = o["rel"];
- this.arg2 = o["arg2"];
- this.confidence = Number(o["confidence"]);
+ public function JsonEntry(o:Object, alt:Boolean = false) {
- o = o["info"];
- this.title = o["title"];
- this.url = o["info"];
- this.date = o["date"];
- this.content = o["content"];
+ if (alt) {
+
+ this.keyword = o["keyword"];
+ var op = o["info"][0];
+ this.title = op["title"];
+ this.url = op["url"];
+ this.content = op["content"];
+ return;
+ } else {
+
+ this.arg1 = o["arg1"];
+ this.rel = o["rel"];
+ this.arg2 = o["arg2"];
+ this.confidence = Number(o["confidence"]);
+
+ o = o["info"];
+ this.title = o["title"];
+ this.keyword = o["title"];
+ this.url = o["url"];
+ this.date = o["date"];
+ this.content = o["content"];
+ }
if (arg1 == null) {
arg1 = "";
View
@@ -3,7 +3,7 @@ package {
import flash.events.Event;
import flash.text.Font;
- [SWF(backgroundColor = "#222222", frameRate = "60", width = "900", height = "600")]
+ [SWF(backgroundColor = "#555555", frameRate = "60", width = "900", height = "600")]
public class Main extends Sprite {
View
@@ -5,6 +5,7 @@ package
import flash.text.TextField;
import flash.ui.Mouse;
import flash.display.*;
+ import flash.net.*;
public class MouseWindow extends Sprite {
public static var globalTooltip:MouseWindow;
@@ -13,18 +14,18 @@ package
globalTooltip = this;
}
- public static function create_tooltip(header:String, body:String, misc:String) {
+ public static function create_tooltip(header:String, body:String, url:String) {
while (globalTooltip.numChildren != 0) {
globalTooltip.removeChildAt(0);
}
globalTooltip.visible = true;
- globalTooltip.addChild(create_textbox(header, body, misc));
+ globalTooltip.addChild(create_textbox(header, body, url));
}
- private static function create_textbox(header:String, body:String, misc:String):Sprite {
+ private static function create_textbox(header:String, body:String, url:String):Sprite {
var header_text:TextField = FloatButtonLabel.make_text(header, 30);
var body_text:TextField = FloatButtonLabel.make_text(body, 15);
- var misc_text:TextField = FloatButtonLabel.make_text(misc, 15);
+ //var misc_text:TextField = FloatButtonLabel.make_text(misc, 15);
header_text.selectable = true;
@@ -50,6 +51,8 @@ package
bodysp.x = Common.WID - bodysp.width;
bodysp.y = Common.HEI - (body_text.y + body_text.textHeight + 10);
+ body_text.width = Math.max(body_text.textWidth, header_text.textWidth);
+
var closebutton:Sprite = new Sprite;
closebutton.addChild(new PinButton.CROIX_IMG as Bitmap);
closebutton.addEventListener(MouseEvent.CLICK, function() {
@@ -68,6 +71,12 @@ package
bodysp.addEventListener(MouseEvent.MOUSE_OUT, function() {
bodysp.alpha = 0.8;
});
+
+ Common.add_mouse_over(header_text);
+ header_text.addEventListener(MouseEvent.CLICK, function() {
+ flash.net.navigateToURL(new URLRequest(url));
+ });
+
return bodysp;
}
View
@@ -4,6 +4,7 @@ package {
import flash.events.MouseEvent;
import flash.events.TextEvent;
import flash.geom.Rectangle;
+ import flash.text.ime.CompositionAttributeRange;
import flash.text.TextField;
import flash.text.AntiAliasType;
import flash.text.TextField;
@@ -28,7 +29,16 @@ package {
private var kill:Number = -1;
public function PinButton(v:Vector.<JsonEntry>) {
-
+ if (v.length > 0) {
+ var t:TextField = FloatButtonLabel.make_text(v[0].arg1+"...", 30);
+ t.y = -270;
+ t.textColor = 0xFFFFFF;
+ this.addChild(t);
+ } else {
+ var t:TextField = FloatButtonLabel.make_text("No results found", 30);
+ t.x = -85;
+ this.addChild(t);
+ }
this.addChild(testdraw);
this.x = 900 / 2 + Math.random()*100-50;
@@ -43,7 +53,6 @@ package {
this.scaleX = 0;
this.scaleY = 0;
- //label_text_list = ["MSG1MSG1MSG1MSG1", "MSG2MSG2MSG2MSG2", "MSG3MSG3MSG3MSG3", "MSG4MSG4MSG4MSG4", "MSG3MSG3MSG3MSG3", "MSG4MSG4MSG4MSG4", "MSG3MSG3MSG3MSG3", "MSG4MSG4MSG4MSG4"];
label_text_list = v;
closebutton.addChild(new CROIX_IMG as Bitmap);
@@ -61,42 +70,19 @@ package {
private var label_text_list:Vector.<JsonEntry>;
private function add_text_label() {
- var fbl:FloatButtonLabel = new FloatButtonLabel(label_text_list.pop());
+ var fbl:FloatButtonLabel = new FloatButtonLabel(label_text_list.shift());
floatlabels.push(fbl);
this.addChild(fbl);
fbl.update_scale();
}
- //private function make_text_cloud(sts:Array) {
- //for (var i = sts.length-1; i >= 0; i--) {
- //var fbl:FloatButtonLabel = new FloatButtonLabel(sts[i], 40);
- //floatlabels.push(fbl);
- //this.addChild(fbl);
- //
- //fbl.x = Math.random() * 200 - 100;
- //fbl.y = Math.random() * 200 - 100;
- //
- //fbl.graphics.beginFill(0xFF0000);
- //fbl.graphics.drawCircle( -fbl.x, -fbl.y, 5);
- //
- //fbl.update_scale();
- //}
- //}
-
private function update_labels() {
- //testdraw.graphics.clear();
- //testdraw.graphics.beginFill(0x00FF00);
-
for each (var i:FloatButtonLabel in floatlabels) {
var r:Rectangle = i.get_bounding_rect();
-
- //testdraw.graphics.drawRect(r.x-r.width/2, r.y-r.height/2, r.width, r.height);
-
i.update();
i.move_repel(floatlabels);
}
- //testdraw.graphics.endFill();
}
public function move_repel(a:Array) {
Oops, something went wrong.

0 comments on commit c36e103

Please sign in to comment.