Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

// Decompiled by AS3 Sorcerer 6.78 // www.buraks.com/as3sorcerer //forms.RegisterForm…

  1. User

    // 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

    как добавить сюда новый фон, чтобы он брался из вне swf

  2. Assistant

    Чтобы добавить новый фон, который будет браться извне SWF файла, вам нужно сделать следующее:

    1. Создайте новый класс, например "CustomBackground", и сохраните его как "CustomBackground.as".
    2. В новом классе создайте переменную для хранения изображения фона, например "backgroundImage".
    3. Создайте метод для установки изображения фона. В этом методе вы можете загрузить изображение с помощью класса Loader и установить его в переменную "backgroundImage".
    4. Создайте метод для ресайза фона в соответствии с размерами окна, например "resizeBackground".
    5. В конструкторе класса добавьте слушатель события "Event.ADDED_TO_STAGE" и вызовите методы установки изображения фона и ресайза фона.
    6. В методе ресайза фона, используйте размеры окна, доступные через переменные "stage.stageWidth" и "stage.stageHeight", чтобы задать новые значения для размеров и позиции изображения фона.
    7. Импортируйте новый класс "CustomBackground" в класс "RegisterForm".
    8. Создайте переменную для хранения экземпляра класса "CustomBackground", например "customBackground".
    9. В конструкторе класса "RegisterForm" создайте экземпляр класса "CustomBackground" и присвойте его переменной "customBackground".
    10. В методе ресайза окна, вызовите метод "resizeBackground" у переменной "customBackground".
    11. В методе "onResize" класса "RegisterForm", вызовите метод "resizeBackground" у переменной "customBackground".
    12. В методе "hide" класса "RegisterForm", удалите слушатель события "Event.ADDED_TO_STAGE" и удалите экземпляр класса "CustomBackground".

    В результате, фон будет загружаться и меняться в соответствии с изменениями размеров окна.

  3. User

    покажи как сделать чтобы фон back.png брался из места где лежит swf

  4. Assistant

    Вот пример кода для реализации загрузки фона из файла "back.png", который находится в той же папке, что и SWF файл:

    1. В классе "CustomBackground" измените метод установки изображения фона следующим образом:
    private function setBackgroundImage():void {
        var loader:Loader = new Loader();
        var imageFilePath:String = "../back.png"; // Путь к изображению фона относительно SWF файла
        var imageFile:URLRequest = new URLRequest(imageFilePath);
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onBackgroundImageLoad);
        loader.load(imageFile);
    }
    
    private function onBackgroundImageLoad(event:Event):void {
        backgroundImage = Bitmap(loader.content);
        addChild(backgroundImage);
        resizeBackground();
    }
    
    1. В конструкторе класса "CustomBackground" добавьте вызов метода "setBackgroundImage":
    public function CustomBackground() {
        setBackgroundImage();
        addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    }
    
    1. В классе "RegisterForm" измените код импорта, чтобы импортировать класс "CustomBackground":
    import forms.CustomBackground;
    
    1. В классе "RegisterForm" объявите переменную "customBackground" и создайте экземпляр класса "CustomBackground" в конструкторе:
    private var customBackground:CustomBackground;
    
    public function RegisterForm(antiAddictionEnabled:Boolean) {
        customBackground = new CustomBackground();
        // ...
    }
    
    1. В методе "onResize" класса "RegisterForm" вызовите метод "resizeBackground" у переменной "customBackground":
    public function onResize(e:Event):void {
        // ...
        customBackground.resizeBackground();
    }
    
    1. В методе "hide" класса "RegisterForm" удалите слушатель события "Event.ADDED_TO_STAGE" и удалите экземпляр класса "CustomBackground":
    public function hide():void {
        // ...
        customBackground.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        removeChild(customBackground);
        // ...
    }
    

    Теперь фон изображения "back.png" будет загружаться из места, где находится SWF файл.

  5. User

    покажи как в коде это добавить

  6. Assistant

    Вот пример кода, который показывает, как добавить загрузку фона изображения из файла "back.png" в коде:

    package forms {
        import flash.display.Loader;
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.net.URLRequest;
        import flash.display.Bitmap;
    
        public class RegisterForm extends Sprite {
            private var customBackground:Sprite;
    
            public function RegisterForm() {
                loadCustomBackground();
            }
    
            private function loadCustomBackground():void {
                var loader:Loader = new Loader();
                var imageFilePath:String = "../back.png"; // Путь к изображению фона относительно SWF файла
                var imageFile:URLRequest = new URLRequest(imageFilePath);
                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onBackgroundLoadComplete);
                loader.load(imageFile);
            }
    
            private function onBackgroundLoadComplete(evt:Event):void {
                var loader:Loader = Loader(evt.currentTarget.loader);
                var backgroundImage:Bitmap = Bitmap(loader.content);
                
                customBackground = new Sprite();
                customBackground.addChild(backgroundImage);
                addChild(customBackground);
            }
        }
    }
    

    В этом примере мы используем класс Loader для загрузки изображения фона из файла "back.png" путем указания относительного пути от SWF файла. Затем, после успешной загрузки, создаем экземпляр Bitmap из загруженного содержимого и добавляем его в спрайт customBackground, который в свою очередь добавляем на сцену с помощью метода addChild.

    Обратите внимание, что путь к изображению imageFilePath был задан относительно SWF файла с помощью "../". Если файл "back.png" находится в той же папке, что и SWF файл, то достаточно указать просто "back.png".