         }
     }
 }
+
+import flash.text.TextField;
+import flash.text.TextFormat;
+
+class InternetFreedomBadge {
+    
+    private var ui:rtmfpcat;
+    
+    private var _num_proxy_pairs:uint;
+    private var _total_proxy_pairs:uint;
+    
+    [Embed(source="badge.png")]
+    private var BadgeImage:Class;
+    private var tot_client_count_tf:TextField;
+    private var tot_client_count_fmt:TextFormat;
+    private var cur_client_count_tf:TextField;
+    private var cur_client_count_fmt:TextFormat;
+    
+    public function InternetFreedomBadge(ui:rtmfpcat)
+    {
+        this.ui = ui;
+        _num_proxy_pairs = 0;
+        _total_proxy_pairs = 0;
+        
+        /* Setup client counter for badge. */
+        tot_client_count_fmt = new TextFormat();
+        tot_client_count_fmt.color = 0xFFFFFF;
+        tot_client_count_fmt.align = "center";
+        tot_client_count_fmt.font = "courier-new";
+        tot_client_count_fmt.bold = true;
+        tot_client_count_fmt.size = 10;
+        tot_client_count_tf = new TextField();
+        tot_client_count_tf.width = 20;
+        tot_client_count_tf.height = 17;
+        tot_client_count_tf.background = false;
+        tot_client_count_tf.defaultTextFormat = tot_client_count_fmt;
+        tot_client_count_tf.x=47;
+        tot_client_count_tf.y=0;
+
+        cur_client_count_fmt = new TextFormat();
+        cur_client_count_fmt.color = 0xFFFFFF;
+        cur_client_count_fmt.align = "center";
+        cur_client_count_fmt.font = "courier-new";
+        cur_client_count_fmt.bold = true;
+        cur_client_count_fmt.size = 10;
+        cur_client_count_tf = new TextField();
+        cur_client_count_tf.width = 20;
+        cur_client_count_tf.height = 17;
+        cur_client_count_tf.background = false;
+        cur_client_count_tf.defaultTextFormat = cur_client_count_fmt;
+        cur_client_count_tf.x=47;
+        cur_client_count_tf.y=6;
+
+        /* Update the client counter on badge. */
+        update_client_count();
+    }
+    
+    public function display():void
+    {
+        ui.addChild(new BadgeImage());
+        /* Tried unsuccessfully to add counter to badge. */
+        /* For now, need two addChilds :( */
+        ui.addChild(tot_client_count_tf);
+        ui.addChild(cur_client_count_tf);
+    }
+    
+    public function get num_proxy_pairs():uint
+    {
+        return _num_proxy_pairs;
+    }
+    
+    public function set num_proxy_pairs(amount:uint):void
+    {
+        _num_proxy_pairs = amount;
+        update_client_count();
+    }
+    
+    public function get total_proxy_pairs():uint
+    {
+        return _total_proxy_pairs;
+    }
+    
+    public function set total_proxy_pairs(amount:uint):void
+    {
+        _total_proxy_pairs = amount;
+        /* note: doesn't update, so be sure to update this
+           before you update num_proxy_pairs! */
+    }
+    
+    private function update_client_count():void
+    {
+        /* Update total client count. */
+        if (String(total_proxy_pairs).length == 1)
+            tot_client_count_tf.text = "0" + String(total_proxy_pairs);
+        else
+            tot_client_count_tf.text = String(total_proxy_pairs);
+
+        /* Update current client count. */
+        cur_client_count_tf.text = "";
+        for(var i:Number = 0; i < num_proxy_pairs; i++)
+            cur_client_count_tf.appendText(".");
+    }
+}

                if (!proxy_mode) {
                    start_proxy_pair();
                    s_c.send_hello(e.peer);
                }
                p_p.connect(e.peer, e.stream);
            });

            p_p.addEventListener(Event.CLOSE, function (e:Event):void {
                puts("ProxyPair: connection closed.");
                p_p = null;
                if (proxy_mode && !debug_mode && badge != null) {
                    badge.num_proxy_pairs++;
                }
                establish_facilitator_connection();
            });
            p_p.listen(s_c.local_stream_name);
