# Class scripts errors

**URL:** <https://forum.kirupa.com/t/class-scripts-errors/108861>\
**Category:** Uncategorized\
**Created:** [April 29, 2004, 11:45am UTC](https://forum.kirupa.com/t/class-scripts-errors/108861 "2004-04-29T11:45:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@tico](https://forum.kirupa.com/u/tico)\
**Post date:** [April 29, 2004, 11:45am UTC](https://forum.kirupa.com/t/class-scripts-errors/108861/1 "2004-04-29T11:45:14Z")

</div>

hi, again…

i’m using a component that uses a extenral AS file (FormValidator.as), and it was made in Flash MX (Flash Player 6 /ActionScript 1.0)  
i need to used it with Flash MX 2004 (Flash Player 7 /ActionScript 2.0), and i get some errors.

the FormValidator.as code is:  
[AS]  
FormValidator = function () {  
this.valide = false;  
this.target\_mc.\_visible = false;  
};  
FormValidator. **instances** = [];  
FormValidator. **id** = 0;  
FormValidator. **submit** = 0;  
FormValidator.prototype = new MovieClip();  
ASBroadcaster.initialize(FormValidator.prototype);  
FormValidator.prototype.onLoad = function() {  
FormValidator. **id** ++;  
this.init();  
};  
FormValidator.prototype.init = function() {  
if (!\_root.container\_invalid) {  
\_root.createEmptyMovieClip(“container\_invalid”,989);  
}  
this.t\_mc = this.\_parent[this._targetInstanceName];  
this.t\_mc.parent = this;  
this.id = FormValidator. **id** -1;  
if (this.formType!=“submit”) {  
this.t\_mc.focusDefined=false;  
FormValidator. **instances**.push({mc:this.t\_mc,variableName:this.variableName,type:this.formType});  
}  
if (this.formType==“submit”) {  
if (FormValidator. **submit** \> 1) {  
trace(“O formulário admite apenas uma submissão, consequentemente, este terminará a execução!”);  
return false;  
}  
FormValidator. **submit** ++;  
this.addListener(this);  
if (this.t\_mc.onRelease!=null && !this.t\_mc.oldOnRelease) {  
this.t\_mc.oldOnRelease = this.t\_mc.onRelease;  
}  
this.t\_mc.onRelease = function() {  
this.oldOnRelease();  
var tt = FormValidator. **instances** ;  
var l = tt.length;  
for (var i=0;i\<l;i++) {  
tt\*.mc.parent.validate(tt\*.mc.parent.formType); \*  
 }  
 this.parent.broadcastMessage(“onSubmit”);  
 }  
 }  
 };  
 FormValidator.prototype.validate = function(type\_str) {  
 switch (type\_str) {  
 case “input” :  
 this.valid = this.inputValidate();  
 break;  
 case “email” :  
 this.valid = this.emailValidate();  
 break;  
 }  
 if ((!this.valid) && (type\_str != “submit”)) {  
 var x1 = this.t\_mc.\_x;  
 var y1 = this.t\_mc.\_y;  
 var w1 = this.t\_mc.\_width;  
 \_root.container\_invalid.createTextField(“error”+this.t\_mc.\_name, this.id, x1, y1, w1, 20);  
 var t = \_root.container\_invalid[“error”+this.t\_mc.\_name];  
 var tf = new TextFormat();  
 tf.align=“right”;  
 tf.color = “0xB61212”  
 tf.font = “Verdana”;  
 tf.size = 10;  
 t.text = this.error\_message;  
 t.selectable = false;  
 t.setTextFormat(tf);  
 if (!this.t\_mc.focusDefined) {  
 if (this.t\_mc.onSetFocus!=undefined) {  
 this.t\_mc.oldFocus = this.t\_mc.onSetFocus;  
\*} \*  
 this.t\_mc.onSetFocus=function() {  
 \_root.container\_invalid[“error”+this.\_name].removeTextField();  
 if (this.oldFocus) this.oldFocus();  
 }  
 this.t\_mc.focusDefined = true;  
\*} \*  
 return false;  
 }  
 return true;  
 }  
 FormValidator.prototype.inputValidate = function() {  
 if (this.t\_mc.text != “”) {return true;} else {return false;}  
 }  
 FormValidator.prototype.emailValidate = function() {  
 var v = this.t\_mc.text;  
 if (v != “”) {  
 var len = v.length;  
\*var validName = "abcdefghijklmnopqrstuvwxyz-_.0123456789";\*  
_var validDomain = “abcdefghijklmnopqrstuvwxyz-0123456789”;_  
_var validLast = “abcdefghijklmnopqrstuvwxyz”;_  
_if ((v.charAt(0) == “@”) || (v.charAt(len-1)=="@") || (v.charAt(0) == “.”) || (v.charAt(len-1)==".")) {return false};_  
_if ((v.indexOf("@") == -1) || (v.indexOf(".") == -1)) {return false;}_  
_if (v.split("@").length\>2) {return false};_  
_if (v.split("@")[1].split(".").length\>3) {return false};_  
_var name = v.split("@")[0];_  
_var domain = v.split("@")[1].split(".")[0];_  
_var last = v.split("@")[1].split(".")[1];_  
_for (var i=0;i\<name.length;i++) {_  
\*if (validName.indexOf(name.charAt(i))==-1) return false; \*  
_}_  
_for (i=0;i\<domain.length;i++) {_  
\*if (validDomain.indexOf(domain.charAt(i))==-1) return false; \*  
_}_  
_if ((domain.charAt(0)=="-") || domain.charAt(domain.length-1)=="-") return false_  
_for (i=0;i\<last.length;i++) {_  
\*if (validLast.indexOf(last.charAt(i)) == -1) return false; \*  
_}_  
_return true;_  
_} else {_  
_return false; \*  
 }  
 }  
 FormValidator.prototype.onSubmit = function() {  
 var t = FormValidator. **instances** ;  
 var len = t.length;  
 var result = 0;  
 for (var i=0;i\<len;i++) {  
 if (!t.mc.parent.valid) {_  
_result++;_  
_}_  
_}_  
_if (result\>0) {_  
\*\_root[this.error\_callbak].apply(null); \*  
_}_  
_if (result==0) {_  
_var loadVar = new LoadVars();_  
_loadVar.parent = this;_  
_for (var j=0;j\<len;j++) {_  
_loadVar[t[j].variableName] = t[j].mc.text;_  
_}_  
_loadVar.onLoad = function() {_  
_if (this.parent.callback!="") {_  
\*\_root[this.parent.callback].apply(null); \*  
_}_  
_}_  
_ASSetPropFlags(loadVar,“onLoad”,1,1);_  
_loadVar.sendAndLoad(this.cgiurl, loadVar, this.sendType);_  
_}_  
_}_  
_Object.registerClass(“FormValidator”,FormValidator);_  
_[/AS]_

_…and i get all these errors:_

- 

```auto
*
****Error** \FormValidator.as: Line 4: ActionScript 2.0 class scripts may only define class or interface constructs.*
* };*
 
***Error** \FormValidator.as: Line 6: ActionScript 2.0 class scripts may only define class or interface constructs.*
* FormValidator. __instances__ = [];*
 
***Error** \FormValidator.as: Line 7: ActionScript 2.0 class scripts may only define class or interface constructs.*
* FormValidator. __id__ = 0;*
 
***Error** \FormValidator.as: Line 8: ActionScript 2.0 class scripts may only define class or interface constructs.*
* FormValidator. __submit__ = 0;*
 
***Error** \FormValidator.as: Line 9: ActionScript 2.0 class scripts may only define class or interface constructs.*
* FormValidator.prototype = new MovieClip();*
 
***Error** \FormValidator.as: Line 10: ActionScript 2.0 class scripts may only define class or interface constructs.*
* ASBroadcaster.initialize(FormValidator.prototype);*
 
***Error** \FormValidator.as: Line 15: ActionScript 2.0 class scripts may only define class or interface constructs.*
* };*
 
***Error** \FormValidator.as: Line 47: ActionScript 2.0 class scripts may only define class or interface constructs.*
* };*
 
***Error** \FormValidator.as: Line 85: ActionScript 2.0 class scripts may only define class or interface constructs.*
* FormValidator.prototype.inputValidate = function() {*
 
***Error** \FormValidator.as: Line 88: ActionScript 2.0 class scripts may only define class or interface constructs.*
* FormValidator.prototype.emailValidate = function() {*
 
***Error** \FormValidator.as: Line 117: ActionScript 2.0 class scripts may only define class or interface constructs.*
* FormValidator.prototype.onSubmit = function() {*
 
***Error** \FormValidator.as: Line 144: ActionScript 2.0 class scripts may only define class or interface constructs.*
* Object.registerClass("FormValidator",FormValidator);*
*Total ActionScript Errors: 12 Reported Errors: 12*

```

…and i try to put the \*.AS file in the classes folder… and i get the some errors:

_ **Error** C:\Documents and Settings\Tico\Local Settings\Application Data\Macromedia\Flash MX 2004\en\Configuration\Classes\FormValidator.as: Line 4: ActionScript 2.0 class scripts may only define class or interface constructs._  
_};_  
_etc…_  
_etc…_

can anyone help here this stuff? ☹

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [September 21, 2022, 10:29am UTC](https://forum.kirupa.com/t/class-scripts-errors/108861/3 "2022-09-21T10:29:35Z")

</div>


