Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package {
- import flash.display.MovieClip;
- import flash.events.MouseEvent;
- import flash.utils.getDefinitionByName;
- import flash.events.Event;
- import scaleform.click.events.*;
- public class WinConditionSelector extends MovieClip {
- // element details filled out by game engine
- public var gameAPI:Object;
- public var globals:Object;
- public var elementName:String;
- public var settings:Object = {
- "time": true,
- "kill": false,
- "timeAmount": 1,
- "killAmount": 1
- };
- public function WinConditionSelector() { }
- // called by the game engine when this .swf has finished loading
- public function onLoaded():void {
- gameAPI.SubscribeToGameEvent("sheeptag_show_wincond_select", this.display);
- }
- public function display(data:Object):void {
- trace("PEW");
- this.replaceWithValveComponent(_root.bgBox, "bg_overlayBox", true);
- var timeCheck = this.replaceWithValveComponent(_root.timeCheckbox, "DotaCheckBoxDota");
- timeCheck.addEventListener(Event.SELECT, function(evt:Event):void {
- trace(evt);
- })
- var killCheck = this.replaceWithValveComponent(_root.killCheckbox, "DotaCheckBoxDota");
- this.replaceWithValveComponent(_root.timeSlider, "Slider_New", true);
- this.replaceWithValveComponent(_root.killSlider, "Slider_New", true);
- var confirm = this.replaceWithValveComponent(_root.confirmBtn, "chrome_button_primary", true);
- confirm.label = "#sheeptag_btn_confirm";
- confirm.enabled = true;
- visible = true;
- }
- // called by the game engine after onLoaded and whenever the screen size is changed
- public function onScreenSizeChanged():void {
- // By default, your 1024x768 swf is scaled to fit the vertical resolution of the game
- // and centered in the middle of the screen.
- // You can override the scaling and positioning here if you need to.
- // stage.stageWidth and stage.stageHeight will contain the full screen size.
- }
- /*Parameters:
- mc - The movieclip to replace
- type - The name of the class you want to replace with
- keepDimensions - Resize from default dimensions to the dimensions of mc (optional, false by default)
- */
- public function replaceWithValveComponent(mc:MovieClip, type:String, keepDimensions:Boolean = false) : MovieClip {
- var parent = mc.parent;
- var oldx = mc.x;
- var oldy = mc.y;
- var oldwidth = mc.width;
- var oldheight = mc.height;
- var newObjectClass = getDefinitionByName(type);
- var newObject = new newObjectClass();
- newObject.x = oldx;
- newObject.y = oldy;
- if (keepDimensions) {
- newObject.width = oldwidth;
- newObject.height = oldheight;
- }
- parent.removeChild(mc);
- parent.addChild(newObject);
- return newObject;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement