Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package  {
  2.    
  3.     import flash.display.MovieClip;
  4.     import flash.events.MouseEvent;
  5.     import flash.utils.getDefinitionByName;
  6.     import flash.events.Event;
  7.    
  8.     import scaleform.click.events.*;
  9.    
  10.     public class WinConditionSelector extends MovieClip {
  11.         // element details filled out by game engine
  12.         public var gameAPI:Object;
  13.         public var globals:Object;
  14.         public var elementName:String;
  15.        
  16.         public var settings:Object = {
  17.             "time": true,
  18.             "kill": false,
  19.             "timeAmount": 1,
  20.             "killAmount": 1
  21.         };
  22.        
  23.         public function WinConditionSelector() { }
  24.        
  25.         // called by the game engine when this .swf has finished loading
  26.         public function onLoaded():void {
  27.             gameAPI.SubscribeToGameEvent("sheeptag_show_wincond_select", this.display);
  28.         }
  29.        
  30.         public function display(data:Object):void {
  31.             trace("PEW");
  32.             this.replaceWithValveComponent(_root.bgBox, "bg_overlayBox", true);
  33.             var timeCheck = this.replaceWithValveComponent(_root.timeCheckbox, "DotaCheckBoxDota");
  34.             timeCheck.addEventListener(Event.SELECT, function(evt:Event):void {
  35.                 trace(evt);
  36.             })
  37.             var killCheck = this.replaceWithValveComponent(_root.killCheckbox, "DotaCheckBoxDota");
  38.             this.replaceWithValveComponent(_root.timeSlider, "Slider_New", true);
  39.             this.replaceWithValveComponent(_root.killSlider, "Slider_New", true);
  40.             var confirm = this.replaceWithValveComponent(_root.confirmBtn, "chrome_button_primary", true);
  41.             confirm.label = "#sheeptag_btn_confirm";
  42.             confirm.enabled = true;
  43.            
  44.             visible = true;
  45.         }
  46.        
  47.         // called by the game engine after onLoaded and whenever the screen size is changed
  48.         public function onScreenSizeChanged():void {
  49.             // By default, your 1024x768 swf is scaled to fit the vertical resolution of the game
  50.             //   and centered in the middle of the screen.
  51.             // You can override the scaling and positioning here if you need to.
  52.             // stage.stageWidth and stage.stageHeight will contain the full screen size.
  53.         }
  54.        
  55.         /*Parameters:
  56.             mc - The movieclip to replace
  57.             type - The name of the class you want to replace with
  58.             keepDimensions - Resize from default dimensions to the dimensions of mc (optional, false by default)
  59.         */
  60.         public function replaceWithValveComponent(mc:MovieClip, type:String, keepDimensions:Boolean = false) : MovieClip {
  61.             var parent = mc.parent;
  62.             var oldx = mc.x;
  63.             var oldy = mc.y;
  64.             var oldwidth = mc.width;
  65.             var oldheight = mc.height;
  66.            
  67.             var newObjectClass = getDefinitionByName(type);
  68.             var newObject = new newObjectClass();
  69.             newObject.x = oldx;
  70.             newObject.y = oldy;
  71.             if (keepDimensions) {
  72.                 newObject.width = oldwidth;
  73.                 newObject.height = oldheight;
  74.             }
  75.            
  76.             parent.removeChild(mc);
  77.             parent.addChild(newObject);
  78.            
  79.             return newObject;
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement