• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Error 1013: The private attribute may be used only on class property definitions.

New Here ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hi i have this code and get the error stated above. This isn't my code I am an absolute noob and someone with far more skill created it. I've looked on the forum and seen it has something to do with the curly braces but i can't quite figure it out. any help would be appreciated.

 

the error is here:

Line 102, Column 3 1013: The private attribute may be used only on class property definitions.

The corresponding line of code is:

private function onKeyboard(event: KeyboardEvent): void{

 

package {
	import flash.desktop.NativeApplication;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.DisplayObjectContainer;
	import flash.display.StageDisplayState;
	import flash.text.TextField;
	import flash.text.TextFieldType;
	import flash.events.FocusEvent;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import flash.ui.Keyboard;
	import flash.ui.Mouse;
	import flash.media.Sound;
	import Timekeeper;
	import TimekeeperEvent;
	import flash.media.SoundChannel;

	public class FlashPLAB extends MovieClip {
		var promptDoc: DisplayObjectContainer;
		var promptUp: TextField;
		var promptOver: TextField;
		var promptDn: TextField;

		var prompt2Up: TextField;
		var prompt2Over: TextField;
		var prompt2Dn: TextField;

		var newCounter: Timekeeper;
		var remaining: int;

		var clockTimer: Timer;
		var time: Date;

		var StartStage: Number;
		var FinalStage: Number;
		var CurrentStage: Number;
		var StageTime: Number;
		var IntTime: Number;
		var PromptTime: Number;
		var Prompt2Time: Number;

		var PlayDing: audDing;
		var PlayIntro: audIntro;
		var PlayBegin: audBegin;
		var PlayNext: audNext;
		var PlayEnd: audEnd;
		var Play30: audRem30;
		var Play60: audRem60;
		var Play90: audRem90;
		var Play120: audRem120;
		var Play3Min: audRem3min;
		var Play4Min: audRem4min;
		var Play5Min: audRem5min;
		var Play6Min: audRem6min;

		var DingChannel: SoundChannel;
		var VoxChannel: SoundChannel;
	}
		public function FlashPLAB() {
			PlayDing = new audDing;
			PlayIntro = new audIntro;
			PlayBegin = new audBegin;
			PlayNext = new audNext;
			PlayEnd = new audEnd;
			Play30 = new audRem30;
			Play60 = new audRem60;
			Play90 = new audRem90;
			Play120 = new audRem120;
			Play3Min = new audRem3min;
			Play4Min = new audRem4min;
			Play5Min = new audRem5min;
			Play6Min = new audRem6min;

			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyboard);
			stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

			clockTimer = new Timer(1000);
			clockTimer.addEventListener(TimerEvent.TIMER, onClockTick);

			newCounter = new Timekeeper();
			newCounter.setRealTimeValue();
			newCounter.setRealTimeTick();

			LoadFrame(1);

			StartStage = Number(textStart.text);
			FinalStage = Number(textStations.text);
			StageTime = Number(textStageMins.text);
			IntTime = Number(textIntSeconds.text);
			if (promptUp.text != "Off") {
				PromptTime = Number(promptUp.text);
			} else {
				PromptTime = 0;
			}

			stage.addEventListener(MouseEvent.CLICK, onStageClick);
		}

		private function onKeyboard(event: KeyboardEvent): void{
			switch (event.keyCode) {
				case Keyboard.F12:
					NativeApplication.nativeApplication.exit();
					break;
				case Keyboard.ESCAPE:
					event.preventDefault();
					if (this.currentFrame == 4 || this.currentFrame == 5) {
						newCounter.removeEventListener(TimekeeperEvent.CHANGE, onCountTick);
					}
					if (this.currentFrame != 1) {
						LoadFrame(1)
					};
					break;
			}
		}

		private function LoadFrame(frame: Number): void {
			this.gotoAndPlay(frame);
			this.stop();
			clockTimer.stop();

			switch (frame) {
				case 1:
					textStart.restrict = "0-9";
					textStations.restrict = "0-9";
					textStageMins.restrict = "0-9";
					textIntSeconds.restrict = "0-9";
					textStart.addEventListener(FocusEvent.FOCUS_OUT, onLeaveStart);
					textStart.addEventListener(FocusEvent.FOCUS_IN, onFocusText);
					textStations.addEventListener(FocusEvent.FOCUS_OUT, onLeaveStations);
					textStations.addEventListener(FocusEvent.FOCUS_IN, onFocusText);
					textStageMins.addEventListener(FocusEvent.FOCUS_OUT, onLeaveStageMins);
					textStageMins.addEventListener(FocusEvent.FOCUS_IN, onFocusText);
					textIntSeconds.addEventListener(FocusEvent.FOCUS_OUT, onLeaveIntSeconds);
					textIntSeconds.addEventListener(FocusEvent.FOCUS_IN, onFocusText);

					butPrompt.addEventListener(MouseEvent.CLICK, onPromptClick);

					promptDoc = DisplayObjectContainer(butPrompt.upState);
					promptUp = TextField(promptDoc.getChildAt(1));
					promptDoc = DisplayObjectContainer(butPrompt.overState);
					promptOver = TextField(promptDoc.getChildAt(1));
					promptDoc = DisplayObjectContainer(butPrompt.downState);
					promptDn = TextField(promptDoc.getChildAt(1));

					butPrompt2.addEventListener(MouseEvent.CLICK, onPrompt2Click);

					promptDoc = DisplayObjectContainer(butPrompt2.upState);
					prompt2Up = TextField(promptDoc.getChildAt(1));
					promptDoc = DisplayObjectContainer(butPrompt2.overState);
					prompt2Over = TextField(promptDoc.getChildAt(1));
					promptDoc = DisplayObjectContainer(butPrompt2.downState);
					prompt2Dn = TextField(promptDoc.getChildAt(1));



					butClock.addEventListener(MouseEvent.CLICK, onBClockClick);
					butStart.addEventListener(MouseEvent.CLICK, onStartClick);

					Mouse.show()
					break;
				case 2:
					clockBG.addEventListener(MouseEvent.CLICK, onClockClick);

					clockTimer.start();
					setClock();
					Mouse.hide();
					break;
				case 3:
					Mouse.hide();
					break;
				case 4:
					setCount(remaining);

					if (CurrentStage > FinalStage) {
						LoadFrame(6);
						break;
					} else {
						textStageTitle.text = "Stage " + String(CurrentStage);
					}

					if (DingChannel != null) {
						DingChannel.stop();
					}
					if (VoxChannel != null) {
						VoxChannel.stop();
					}
					DingChannel = PlayDing.play();
					if (CurrentStage == 1) {
						VoxChannel = PlayIntro.play();
					} else {
						VoxChannel = PlayNext.play();
					}
					break;
				case 5:
					setCount(remaining);
					textStageTitle.text = "Stage " + String(CurrentStage);

					if (DingChannel != null) {
						DingChannel.stop();
					}
					if (VoxChannel != null) {
						VoxChannel.stop();
					}
					DingChannel = PlayDing.play();
					VoxChannel = PlayBegin.play();
					break;
				case 6:
					newCounter.stopTicking();
					if (DingChannel != null) {
						DingChannel.stop();
					}
					if (VoxChannel != null) {
						VoxChannel.stop();
					}
					DingChannel = PlayDing.play();
					VoxChannel = PlayEnd.play();
					break;

			}
			stage.focus = this;

		}

		private function onCountTick(event: TimekeeperEvent): void {
			remaining -= 1;
			if (remaining == Prompt2Time && this.currentFrame == 5) {
				if (VoxChannel != null) {
					VoxChannel.stop();
				}
				switch (Prompt2Time) {
					case 180:
						VoxChannel = Play3Min.play();
						break;
					case 240:
						VoxChannel = Play4Min.play();
						break;
					case 300:
						VoxChannel = Play5Min.play();
						break;
					case 360:
						VoxChannel = Play6Min.play();
						break;
				}
			}
			if (remaining == PromptTime && this.currentFrame == 5) {
				if (VoxChannel != null) {
					VoxChannel.stop();
				}
				switch (PromptTime) {
					case 30:
						VoxChannel = Play30.play();
						break;
					case 60:
						VoxChannel = Play60.play();
						break;
					case 90:
						VoxChannel = Play90.play();
						break;
					case 120:
						VoxChannel = Play120.play();
						break;
				}
			} else if (remaining <= 0) {
				if (this.currentFrame == 4) {
					iniStation();
					LoadFrame(5);
				} else if (this.currentFrame == 5) {
					CurrentStage += 1;
					iniInterval();
					LoadFrame(4);
				}
				return;
			}
			setCount(remaining);

		}

		private function setCount(time: Number): void {
			var mins: Number = Math.floor(time / 60);
			var secs: Number = time - (60 * mins);

			if (secs > 9) {
				textRemain.text = String(mins) + ":" + String(secs);
			} else {
				textRemain.text = String(mins) + ":0" + String(secs);
			}
		}

		private function onStartClick(event: MouseEvent): void {
			event.stopPropagation();
			LoadFrame(3);
		}

		private function iniInterval(): void {
			remaining = IntTime;
		}

		private function iniStation(): void {
			remaining = StageTime * 60;
		}

		private function onStageClick(event: MouseEvent): void {
			switch (this.currentFrame) {
				case 3:
					CurrentStage = StartStage;
					iniInterval();
					newCounter.addEventListener(TimekeeperEvent.CHANGE, onCountTick);
					newCounter.startTicking();
					LoadFrame(4);
					break;
				case 4:
					//termInterval();
					iniStation();
					LoadFrame(5);
					break;
				case 5:
					//termStation();
					CurrentStage += 1;
					iniInterval();
					LoadFrame(4);
					break;
				case 6:
					LoadFrame(1);
					break;
			}
		}

		private function onClockClick(event: MouseEvent): void {
			LoadFrame(1);
		}

		private function onLeaveStart(event: FocusEvent): void {
			if (Number(textStart.text) > Number(textStations.text)) {
				textStart.text = textStations.text;
			}
			if (Number(textStart.text) < 1) {
				textStart.text = "1";
			}
			StartStage = (Number(textStart.text));
			textStart.text = String(StartStage);
		}

		private function onLeaveStations(event: FocusEvent): void {
			if (Number(textStations.text) > 40) {
				textStations.text = "40";
			}
			if (Number(textStations.text) < 1) {
				textStations.text = "20";
			}
			FinalStage = Number(textStations.text);
			textStations.text = String(FinalStage);
			if (Number(textStations.text) < Number(textStart.text)) {
				textStart.text = textStations.text;
			}
		}

		private function onLeaveStageMins(event: FocusEvent): void {
			if (Number(event.currentTarget.text) < 1) {
				event.currentTarget.text = "8";
			}
			StageTime = Number(event.currentTarget.text)
			event.currentTarget.text = String(StageTime);

		}

		private function onLeaveIntSeconds(event: FocusEvent): void {
			if (Number(event.currentTarget.text) < 1) {
				event.currentTarget.text = "90";
			}
			IntTime = Number(event.currentTarget.text)
			event.currentTarget.text = String(IntTime);
		}

		private function onFocusText(event: FocusEvent): void {
			event.target.text = "";
		}

		private function onPromptClick(event: MouseEvent): void {
			var current: String = promptUp.text;
			if (current == "Off") {
				setPromptText("30");
				PromptTime = 30;
			} else {
				var t: Number = Number(promptUp.text);
				t += 30;
				if (t >= (Number(textStageMins.text) * 60) || t > 120) {
					setPromptText("Off");
					PromptTime = 0;
				} else {
					setPromptText(String(t));
					PromptTime = t;
				}
			}
		}

		private function onPrompt2Click(event: MouseEvent): void {
			var current: String = prompt2Up.text;
			if (current == "Off") {
				if (Number(textStageMins.text) > 3) {
					setPrompt2Text("3");
					Prompt2Time = 180;
				}
			} else {
				var t: Number = Number(current);
				t += 1;
				if (t >= (Number(textStageMins.text)) || t > 6) {
					setPrompt2Text("Off");
					Prompt2Time = 0;
				} else {
					setPrompt2Text(String(t));
					Prompt2Time = t * 60;
				}
			}
		}

		private function setPromptText(v: String): void {
			promptUp.text = v;
			promptOver.text = v;
			promptDn.text = v;
		}

		private function setPrompt2Text(v: String): void {
			prompt2Up.text = v;
			prompt2Over.text = v;
			prompt2Dn.text = v;
		}

		private function onClockTick(event: TimerEvent): void {
			if (this.currentFrame == 2) {
				setClock();
			}
		}

		private function setClock(): void {
			time = new Date();
			clkSecs.rotation = time.seconds * 6;
			clkMins.rotation = time.minutes * 6;
			clkHours.rotation = time.hours * 30;
		}

		private function onBClockClick(event: MouseEvent): void {
			LoadFrame(2);
		}


	}

}

Views

286

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Hi.

 

It's because this code it's meant to be place inside of an ActionScript 3.0 class file not in an actions frame.

 

To solve this error alone, create a file called FlashPLAB.as where your FLA file is located. Then go to File > ActionScript Settings... and type FlashPLAB in the Document class field.

image.png

 

Then review and possibly fix references in the rest of the code.

 

Regards,

JC

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

Thank you JC, that seemed to do the trick.

 

Is it possible to convert from AS3 to HTML5 without having to rewrite everything?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 14, 2021 Apr 14, 2021

Copy link to clipboard

Copied

LATEST

Great.

 

Unfortunately not. You're gonna have to rewrite the code from scratch.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines