Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.15 KB | None | 0 0
  1. package;
  2.  
  3. import openfl.Lib;
  4. import openfl.display.*;
  5. import openfl.system.System;
  6. import openfl.events.MouseEvent;
  7.  
  8. import ru.stablex.ui.UIBuilder;
  9. import ru.stablex.ui.widgets.Floating;
  10. import ru.stablex.ui.widgets.Options;
  11. import ru.stablex.ui.events.WidgetEvent;
  12.  
  13. class Main extends openfl.display.Sprite {
  14.     public function new () {
  15.         super();
  16.        
  17.         openfl.Lib.current.stage.addChild(this);
  18.        
  19.         UIBuilder.init();
  20.         var window:Floating = UIBuilder.buildFn("Main.xml")();
  21.        
  22.         var wgtGroupsLst:Options = cast(window.getChild("wgtGroupsLst"), Options);
  23.        
  24.         var options:Array<Array<String>> = new Array<Array<String>>();
  25.        
  26.         for (i in 0...5)
  27.             options.push(['my option $i', 'opt-$i']);
  28.        
  29.         wgtGroupsLst.clearEvent(WidgetEvent.CHANGE);
  30.         wgtGroupsLst.addEventListener(WidgetEvent.CHANGE, onSelectWgtsGroup);
  31.        
  32.         trace('old value: ${wgtGroupsLst.value}');
  33.        
  34.         wgtGroupsLst.options = options;
  35.         wgtGroupsLst.value = wgtGroupsLst.options[0][1];
  36.        
  37.         trace('new value: ${wgtGroupsLst.value}');
  38.        
  39.         window.show();
  40.     }
  41.    
  42.     function onSelectWgtsGroup (e:WidgetEvent)
  43.         trace('value changed to: ${cast(e.widget, Options).value}');
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement