Appearance
question:// Decompiled by AS3 Sorcerer 6.78 // www.buraks.com/as3sorcerer //forms.RegisterForm package forms { import flash.display.Sprite; import flash.display.Bitmap; import controls.TankInput; import assets.icons.InputCheckIcon; import forms.registration.bubbles.Bubble; import forms.registration.bubbles.RegisterBubbleFactory; import controls.TankCheckBox; import controls.DefaultButton; import controls.Label; import alternativa.tanks.model.captcha.CaptchaForm; import controls.TankWindow; import alternativa.init.Main; import alternativa.osgi.service.locale.ILocaleService; import alternativa.tanks.locale.constants.TextConst; import controls.TankWindowHeader; import flash.events.FocusEvent; import forms.events.LoginFormEvent; import flash.events.Event; public class RegisterForm extends Sprite { public static const CALLSIGN_STATE_OFF:int = 0; public static const CALLSIGN_STATE_PROGRESS:int = 1; public static const CALLSIGN_STATE_VALID:int = 2; public static const CALLSIGN_STATE_INVALID:int = 3; private static var background:Class = RegisterForm_background; private static var backgroundImage:Bitmap = new Bitmap(new background().bitmapData); private var backgroundContainer:Sprite = new Sprite(); public var callSign:TankInput = new TankInput(); public var pass1:TankInput = new TankInput(); public var pass2:TankInput = new TankInput(); private var callSignCheckIcon:InputCheckIcon = new InputCheckIcon(); private var pass1CheckIcon:InputCheckIcon = new InputCheckIcon(); private var pass2CheckIcon:InputCheckIcon = new InputCheckIcon(); private var nameIncorrectBubble:Bubble = RegisterBubbleFactory.nameIsIncorrectBubble(); private var passwordsDoNotMatchBubble:Bubble = RegisterBubbleFactory.passwordsDoNotMatchBubble(); private var passwordEasyBubble:Bubble = RegisterBubbleFactory.passwordIsTooEasyBubble(); public var chekRemember:TankCheckBox = new TankCheckBox(); public var playButton:DefaultButton = new DefaultButton(); public var loginButton:Label = new Label(); public var rulesButton:Label; public var captchaView:CaptchaForm; private var label:Label = new Label(); private var bg:TankWindow = new TankWindow(380, 290); private var p:Number = 0.5; public function RegisterForm(antiAddictionEnabled:Boolean) { var localeService:ILocaleService = (Main.osgi.getService(ILocaleService) as ILocaleService); var title:Label = new Label(); addChild(this.backgroundContainer); this.backgroundContainer.addChild(backgroundImage); addChild(this.bg); this.bg.headerLang = localeService.getText(TextConst.GUI_LANG); this.bg.header = TankWindowHeader.REGISTER; this.bg.addChild(title); this.bg.addChild(this.callSign); this.bg.addChild(this.pass1); this.bg.addChild(this.pass2); this.bg.addChild(this.chekRemember); this.bg.addChild(this.playButton); this.bg.addChild(this.loginButton); this.bg.addChild(this.callSignCheckIcon); this.bg.addChild(this.pass1CheckIcon); this.bg.addChild(this.pass2CheckIcon); title.x = 25; title.y = 23; title.text = localeService.getText(TextConst.REGISTER_FORM_HEADER_TEXT); this.loginButton.htmlText = localeService.getText(TextConst.REGISTER_FORM_BUTTON_LOGIN_TEXT); this.loginButton.x = (title.x + title.width); this.loginButton.y = 23; this.callSign.x = 80; this.callSign.y = 60; this.callSign.maxChars = 20; this.callSign.tabIndex = 0; this.callSign.restrict = ".0-9a-zA-z_-"; this.callSign.label = localeService.getText(TextConst.REGISTER_FORM_CALLSIGN_INPUT_LABEL_TEXT); this.callSign.validValue = true; this.callSign.width = 275; this.callSignCheckIcon.x = 330; this.callSignCheckIcon.y = (this.callSign.y + 7); this.callSignState = CALLSIGN_STATE_OFF; this.pass1.x = 80; this.pass1.y = (this.callSign.y + 40); this.pass1.label = localeService.getText(TextConst.REGISTER_FORM_PASSWORD_INPUT_LABEL_TEXT); this.pass1.maxChars = 46; this.pass1.hidden = true; this.pass1.validValue = true; this.pass1.width = 275; this.pass1.tabIndex = 1; this.pass1CheckIcon.x = 330; this.pass1CheckIcon.y = (this.pass1.y + 7); this.pass1CheckIcon.visible = false; this.pass2.x = 80; this.pass2.y = (this.pass1.y + 40); this.pass2.label = localeService.getText(TextConst.REGISTER_FORM_REPEAT_PASSWORD_INPUT_LABEL_TEXT); this.pass2.maxChars = 46; this.pass2.hidden = true; this.pass2.validValue = true; this.pass2.width = 275; this.pass2.tabIndex = 2; this.pass2CheckIcon.x = 330; this.pass2CheckIcon.y = (this.pass2.y + 7); this.pass2CheckIcon.visible = false; this.label.x = 113; this.label.y = 195; this.label.text = localeService.getText(TextConst.REGISTER_FORM_REMEMBER_ME_CHECKBOX_LABEL_TEXT); this.bg.addChild(this.label); this.chekRemember.x = 80; this.chekRemember.y = 190; this.playButton.x = 0xFF; this.playButton.y = 190; this.playButton.label = localeService.getText(TextConst.REGISTER_FORM_BUTTON_PLAY_TEXT); this.playButton.enable = false; this.rulesButton = new Label(); this.rulesButton.x = 25; this.rulesButton.y = 235; this.rulesButton.htmlText = localeService.getText(TextConst.REGISTER_FORM_AGREEMENT_NOTE_TEXT); this.bg.addChild(this.rulesButton); this.callSignCheckIcon.addChild(this.nameIncorrectBubble); this.pass1CheckIcon.addChild(this.passwordEasyBubble); this.pass2CheckIcon.addChild(this.passwordsDoNotMatchBubble); this.callSign.addEventListener(FocusEvent.FOCUS_OUT, this.validateCallSign); this.pass1.addEventListener(FocusEvent.FOCUS_OUT, this.validatePassword); this.pass1.addEventListener(LoginFormEvent.TEXT_CHANGED, this.validatePassword); this.pass2.addEventListener(FocusEvent.FOCUS_OUT, this.validatePassword); this.pass2.addEventListener(LoginFormEvent.TEXT_CHANGED, this.validatePassword); } public function set callSignState(value:int):void { this.nameIncorrectBubble.visible = false; if (value == CALLSIGN_STATE_OFF) { this.callSignCheckIcon.visible = false; } else { this.callSignCheckIcon.visible = true; this.callSignCheckIcon.gotoAndStop(value); if (value != CALLSIGN_STATE_INVALID) { this.callSign.validValue = true; this.validatePassword(null); } else { this.nameIncorrectBubble.visible = true; this.callSign.validValue = false; this.pass1.validValue = (this.pass2.validValue = true); this.pass1CheckIcon.visible = (this.pass2CheckIcon.visible = false); this.passwordsDoNotMatchBubble.visible = (this.passwordEasyBubble.visible = false); }; }; } private function switchPlayButton(event:Event):void { this.playButton.enable = ((((this.callSign.validValue) && (!(this.callSign.value == ""))) && ((this.pass1.validValue) && (!(this.pass1.value == "")))) && ((this.pass2.validValue) && (!(this.pass2.value == "")))); } private function validatePassword(event:Event):void { var verySimplePassword:Boolean; this.passwordsDoNotMatchBubble.visible = (this.passwordEasyBubble.visible = false); if (((!(this.callSign.validValue)) || ((this.pass1.value == "") && (this.pass2.value == "")))) { this.pass1.validValue = (this.pass2.validValue = true); this.pass1CheckIcon.visible = (this.pass2CheckIcon.visible = false); } else { if (this.pass1.value != this.pass2.value) { this.pass1.validValue = true; this.pass1CheckIcon.visible = false; this.pass2.validValue = false; this.pass2CheckIcon.visible = true; this.pass2CheckIcon.gotoAndStop(3); this.passwordsDoNotMatchBubble.visible = true; } else { verySimplePassword = ((((this.pass1.value == this.callSign.value) || (this.pass1.value.length < 4)) || (this.pass1.value == "12345")) || (this.pass1.value == "qwerty")); this.pass2.validValue = true; this.pass2CheckIcon.visible = true; this.pass2CheckIcon.gotoAndStop(2); this.pass1.validValue = (!(verySimplePassword)); this.pass1CheckIcon.visible = true; if ((!(this.pass1.validValue))) { this.pass1CheckIcon.gotoAndStop(3); this.passwordEasyBubble.visible = true; } else { this.pass1CheckIcon.gotoAndStop(2); }; }; }; this.switchPlayButton(event); } private function validateCallSign(event:Event):void { this.switchPlayButton(null); } public function playButtonActivate():void { this.playButton.enable = true; } public function hide():void { this.callSign.removeEventListener(FocusEvent.FOCUS_OUT, this.validateCallSign); this.pass1.removeEventListener(FocusEvent.FOCUS_OUT, this.validatePassword); this.pass1.removeEventListener(LoginFormEvent.TEXT_CHANGED, this.validatePassword); this.pass2.removeEventListener(FocusEvent.FOCUS_OUT, this.validatePassword); this.pass2.removeEventListener(LoginFormEvent.TEXT_CHANGED, this.validatePassword); stage.removeEventListener(Event.RESIZE, this.onResize); } public function onResize(e:Event):void { this.bg.x = int(((stage.stageWidth / 2) - (this.bg.width / 2))); this.bg.y = (int(((stage.stageHeight / 2) - (this.bg.height / 2))) + 100); backgroundImage.x = int(((Main.stage.stageWidth - backgroundImage.width) >> 1)); backgroundImage.y = 110; } public function captcha(value:Boolean):void { var height:Number; if (((value) && (this.captchaView == null))) { this.captchaView = new CaptchaForm(); this.bg.addChild(this.captchaView); this.bg.addChild(this.pass2CheckIcon); this.bg.addChild(this.pass1CheckIcon); this.bg.addChild(this.callSignCheckIcon); this.captchaView.y = (this.pass2.y + 47); this.captchaView.x = 80; height = (this.captchaView.height + 17); this.bg.height = (this.bg.height + height); this.playButton.y = (this.playButton.y + height); this.chekRemember.y = (this.chekRemember.y + height); this.label.y = (this.label.y + height); this.rulesButton.y = (this.rulesButton.y + height); y = (y - this.captchaView.height); this.p = (this.y / stage.height); this.onResize(null); }; } } }//package forms как background сделать такую подгрузку ResourceUtil.getResource(ResourceType.IMAGE, (skyboxId)).bitmapData;
answer:backgroundImage = ResourceUtil.getResource(ResourceType.IMAGE, (skyboxId)).bitmapData;
question:а куда это в коде
answer:Вам нужно поменять эту строчку кода: `private static var background:Class = RegisterForm_background;` на `private static var backgroundImage:Bitmap = new Bitmap(ResourceUtil.getResource(ResourceType.IMAGE, (skyboxId)).bitmapData);` Таким образом, вы создаете новый экземпляр класса Bitmap с ресурсом изображения, используя `ResourceUtil.getResource()`, и присваиваете его переменной `backgroundImage`.
question:как в коде сделать чтобы это было по типу этого case "skybox_default": specter.utils.Logger.log("Loading skybox_default"); skyBoxTexture = ResourceUtil.getResource(ResourceType.IMAGE, (skyboxId)).bitmapData; break;
answer:Цвет синтаксической подсветки в редакторе всегда отличается, поэтому я опущу часть контекста и сфокусируюсь только на необходимом кусочке кода. В вашем случае, чтобы использовать разные ресурсы для разных идентификаторов "skybox", вам нужно сделать следующее: ``` switch(skyboxId) { case "skybox_default": skyBoxTexture = ResourceUtil.getResource(ResourceType.IMAGE, skyboxId).bitmapData; break; case "skybox_other": skyBoxTexture = ResourceUtil.getResource(ResourceType.IMAGE, skyboxId).bitmapData; break; // Добавьте другие варианты здесь, при необходимости default: // Загрузка по умолчанию или обработка ошибки, если не найден skyboxId break; } ``` В этом коде, внутри каждого `case`, мы используем `ResourceUtil.getResource()`, чтобы получить ресурс изображения для конкретного идентификатора "skyboxId". Затем мы используем это значение для присвоения текстуры `skyBoxTexture`. Вы можете добавить любое количество `case` для других вариантов "skyboxId", которые вам нужны.
question:а как его вызвать вместо этого addChild(this.backgroundContainer); this.backgroundContainer.addChild(backgroundImage);
answer:Вместо использования `this.backgroundContainer.addChild(backgroundImage)`, вы можете вызвать `addChild(backgroundImage)` прямо после создания экземпляра `Bitmap` с помощью `ResourceUtil.getResource()`: ```actionscript var backgroundImage:Bitmap = new Bitmap(ResourceUtil.getResource(ResourceType.IMAGE, skyboxId).bitmapData); addChild(backgroundImage); ``` Здесь мы создаем новый экземпляр `Bitmap` с ресурсом изображения, используя `ResourceUtil.getResource()`, и сразу же добавляем его на сцену с помощью `addChild(backgroundImage)`. Это добавит загруженное изображение "skybox" на экран.