1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <s:Panel xmlns:
fx=
"http://ns.adobe.com/mxml/2009"
3 xmlns:
s=
"library://ns.adobe.com/flex/spark"
4 xmlns:
mx=
"library://ns.adobe.com/flex/halo"
5 title=
"Creature Viewer (WIP)" width=
"100%">
8 import flashx.textLayout.conversion.ConversionType;
9 import flashx.textLayout.conversion.TextConverter;
10 import mx.collections.ArrayCollection;
11 import org.sevenchan.AdventureController;
12 import org.sevenchan.dongs.bodyparts.IBodyPart;
13 import org.sevenchan.dongs.creature.Player;
14 import spark.components.DataGroup;
15 import flash.utils.describeType;
17 public var player:Player = null;
18 private var currentCreature:Creature = null;
19 public function init(ply:Player):void {
21 cmbCreature.dataProvider = new ArrayCollection();
22 for each(var creatureName:XML in describeType(CreatureRegistry)..accessor.@name) {
23 (cmbCreature.dataProvider as ArrayCollection).addItem(creatureName.toXMLString());
25 var dat:XML = describeType(CreatureRegistry);
26 trace(
"[frmCreatureViewer]",dat);
30 private function creatureChanged():void {
31 currentCreature = CreatureRegistry[(String(cmbCreature.selectedItem))]
32 currentCreature.initialGenderSetup();
33 cmdEncounter.enabled = currentCreature.onEncounter(null);
34 txtDescr.text = currentCreature.getDescription();
35 txtDescr.text +=
"<br /><b>_strength:</b> " + currentCreature._strength;
36 txtDescr.text +=
"<br /><b>_speed:</b> " + currentCreature._speed;
37 txtDescr.text +=
"<br /><b>_intellect:</b> " + currentCreature._intellect;
38 txtDescr.text +=
"<br /><b>_lust:</b> " + currentCreature._lust;
39 txtDescr.text +=
"<br /><b>_sensitivity:</b> " + currentCreature._sensitivity;
40 txtDescr.text +=
"<br /><b>_HP:</b> " + currentCreature._HP;
41 txtDescr.text +=
"<br /><b>_XP:</b> " + currentCreature._XP;
42 txtDescr.text +=
"<br /><b>_mana:</b> " + currentCreature._mana;
43 txtDescr.text +=
"<br /><b>_gold:</b> " + currentCreature._gold;
44 txtDescr.textFlow=TextConverter.importToFlow(txtDescr.text, TextConverter.TEXT_FIELD_HTML_FORMAT);
47 private function onFight():void {
49 player.main.startCombat(null,currentCreature);
51 private function onTransform():void {
53 player.changeTo(currentCreature);
55 private function onEncounter():void {
57 currentCreature.onEncounter(player);
59 private function lolclose():void {
60 player.main.showCreatureViewer(false);
63 private function append(message:String):void {
64 var oldText:String = TextConverter.export(txtDescr.textFlow, TextConverter.TEXT_FIELD_HTML_FORMAT, ConversionType.STRING_TYPE) as String;
65 txtDescr.textFlow = TextConverter.importToFlow(oldText + message, TextConverter.TEXT_FIELD_HTML_FORMAT);
69 <s:VGroup width=
"100%">
70 <s:DropDownList prompt=
"Creature" id=
"cmbCreature" change=
"creatureChanged()" width=
"100%">
72 <s:TextArea id=
"txtDescr" width=
"100%" height=
"50%">Select a creature
</s:TextArea>
73 <s:HGroup width=
"100%">
74 <s:Button id=
"cmdFight" label=
"Fight" click=
"onFight()" width=
"33%" />
75 <s:Button id=
"cmdEncounter" label=
"Encounter" click=
"onEncounter()" width=
"33%" />
76 <s:Button id=
"cmdTransform" label=
"Change Into" click=
"onTransform()" width=
"33%" />
78 <s:Button label=
"Close" click=
"lolclose()" width=
"90%"></s:Button>