Unfortunately I don't know how to add rooms to the static list dynamically, but here is my hardcoded example. Just change the bit with the addItem's to whatever you want or need.
In order to use this class, you MUST have the AS3 "List" component in your library.
- Code: Select all
package sample.ui{
import flash.display.Sprite
import flash.display.Stage
import flash.events.Event
import flash.text.TextFormatAlign
import fl.controls.List
import flash.events.MouseEvent
import flash.events.KeyboardEvent
import sample.ui.components.*
import sample.ui.components.scroll.*
import playerio.*;
public class RoomList extends Box{
private var base:Box
private var input:List
private var _callback:Function
function RoomList(stage:Stage, mytext:String, value:String, callback:Function, cli:Client){
_callback = callback
fill(0xffffff,.8).add(
new Box().minSize(300,110).fill(0x0,.5,10).margin(10,10,10,10).add(
new Box().minSize(300,190).fill(0xFFFFFF,1,10).margin(0,0,0,0).add(
new Box().margin(10).add(
new Label(mytext, 20)
)
).add(
new Box().margin(43,20,NaN,20).add(
new Box().margin(2,0,0,3).minSize(20,25).fill(0x666666,0,5).border(1,0xffffff,1).add(
input = new List()
)
)
).add(
new Box().margin(155).add(
new TextButton("Join Channel",accept)
)
)
)
)
input.height = 100;
//Edit below to change static rooms
input.addItem({label:"Channel 1",data:"Channel 1"});
input.addItem({label:"Channel 2",data:"Channel 2"});
input.addItem({label:"Channel 3",data:"Channel 3"});
input.addItem({label:"Channel 4",data:"Channel 4"});
input.addItem({label:"Channel 5",data:"Channel 5"});
input.addItem({label:"Channel 6",data:"Channel 6"});
input.addItem({label:"Channel 7",data:"Channel 7"});
input.selectedIndex = 0;
stage.addChild(this);
stage.addEventListener(Event.RESIZE, handleResize)
handleResize()
}
function accept():void{
if(input.selectedItem.data != ""){
stage.removeEventListener(Event.RESIZE, handleResize)
stage.removeChild(this);
_callback(input.selectedItem.label)
}
}
private function handleResize(e:Event = null){
this.width = stage.stageWidth
this.height = stage.stageHeight
}
}
}
It doesn't match perfectly with the UI, but it is a very close fit. Enjoy, I hope you find this useful.