public
Description: Github flash badge
Homepage: http://spinach.andascarygoat.com/tags/badjo
Clone URL: git://github.com/zmack/badjo.git
Search Repo:
Gravatar is get !
zmack (author)
Sat May 03 08:17:04 -0700 2008
commit  82f4b90a3d58e194eda814c0bbcec0529e7b0515
tree    b82ad28a06a6b9228b2947497556f25274c95456
parent  1ba0fd6565c9e72e00453ad412b8539eddc24550
...
1
 
2
3
4
 
5
6
7
 
 
8
9
10
11
12
13
...
43
44
45
46
 
47
48
49
...
64
65
66
67
 
68
69
70
...
88
89
90
91
92
93
94
...
96
97
98
 
 
 
 
 
 
 
99
100
101
...
1
2
3
4
5
6
7
8
9
10
11
12
 
 
13
14
15
...
45
46
47
 
48
49
50
51
...
66
67
68
 
69
70
71
72
...
90
91
92
 
93
94
95
...
97
98
99
100
101
102
103
104
105
106
107
108
109
0
@@ -1,13 +1,15 @@
0
 package {
0
+ import flash.display.Loader;
0
   import flash.display.Sprite;
0
   import flash.display.DisplayObject;
0
   import flash.display.LoaderInfo;
0
+ import flash.net.URLRequest;
0
   import skins.GithubBadgeSkin;
0
   import dataexchange.*;
0
   import com.adobe.serialization.json.JSON;
0
+ import com.adobe.crypto.MD5;
0
+ import flash.external.ExternalInterface;
0
 
0
- import flash.external.ExternalInterface;
0
-
0
   /*
0
   Data looks pretty much like this:
0
 
0
@@ -43,7 +45,7 @@
0
 
0
       _gw = new Gateway();
0
       
0
- this.requestData(user);
0
+ this.requestData(user || 'zmack');
0
     }
0
 
0
     private function addExternalInterface():void {
0
@@ -64,7 +66,7 @@
0
       if ( _pl != null ) _pl.parent.removeChild(_pl);
0
       _pl = new ProjectList()
0
 
0
- _pl.setHeader({image: SpriteWrapper(new GithubBadgeSkin.DefaultAvatar()), text: user.name });
0
+ _pl.setHeader({image: SpriteWrapper(loadAvatar('http://www.gravatar.com/avatar/' + MD5.hash(user.email) + '?s=40')), text: user.name });
0
       user.repositories.forEach( function(repo:Object, index:uint, arr:Array):void {
0
         _pl.addButton({image: SpriteWrapper(new GithubBadgeSkin.PublicProject()), text: repo.name });
0
       });
0
@@ -88,7 +90,6 @@
0
       } else {
0
         displayError();
0
       }
0
- trace(e.data);
0
     }
0
 
0
     private function SpriteWrapper(d:DisplayObject):Sprite {
0
@@ -96,6 +97,13 @@
0
       s.addChild(d);
0
 
0
       return s;
0
+ }
0
+
0
+ private function loadAvatar(url:String):DisplayObject {
0
+ var request:URLRequest = new URLRequest(url);
0
+ var loader:Loader = new Loader();
0
+ loader.load(request);
0
+ return loader;
0
     }
0
   }
0
 }
...
4
5
6
 
7
8
9
10
11
...
50
51
52
53
 
54
55
56
57
58
 
59
60
61
 
 
62
63
64
...
4
5
6
7
8
9
10
11
12
...
51
52
53
 
54
55
56
57
58
 
59
60
 
 
61
62
63
64
65
0
@@ -4,6 +4,7 @@
0
   import flash.text.StyleSheet;
0
   
0
   public class ProjectList extends Sprite {
0
+ public const AVATAR_SIZE:uint = 40;
0
     public var backgroundColor:uint;
0
     public var listWidth:Number;
0
     public var lateralPadding:Number = 5;
0
0
0
@@ -50,15 +51,15 @@
0
 
0
     public function setHeader(options:Object):void {
0
       this._headerText = this.createTextField();
0
- this._headerText.height = options.image.height;
0
+ this._headerText.height = AVATAR_SIZE;
0
       addChild(options.image);
0
       addChild(this._headerText);
0
 
0
       this._headerText.htmlText = '<h1>' + options.text + '<h1>';
0
- this._headerText.x = options.image.width + this.lateralPadding*2;
0
+ this._headerText.x = AVATAR_SIZE + this.lateralPadding*2;
0
       this._headerText.y = this.bottomPadding;
0
- this._headerText.width = this.listWidth - options.image.width - this.lateralPadding*2;
0
- this._maximum_y = options.image.height + this.bottomPadding;
0
+ this._headerText.width = this.listWidth - AVATAR_SIZE - this.lateralPadding*2;
0
+ this._maximum_y = AVATAR_SIZE + this.bottomPadding;
0
       options.image.y = this.bottomPadding;
0
       options.image.x = this.lateralPadding;
0
       

Comments

    No one has commented yet.