I want a way to pass a string statement from one base class to an other.
The two classes are CLICK and READ. What’s an easy way to do this? I haven’t
worked in classes that often to know some of the simple tricks. I appreaciate your help.
Thanks,
Class: CLICK
Base Class: ClickClass
Object I’ve turned in to a base class and placed in the same FLA
package {
import flash.events.Event;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.display.*;
public class ClickClass extends MovieClip {
//public var read:String = "It's Done!";
public function ClickClass() {
b.addEventListener(MouseEvent.CLICK, onClick);
}
public function onClick(event:MouseEvent){
trace("test!");
//t.text = String(read);
//ReadClass.t.text = String(read);
}
}
}
Class: READ
Base Class: ReadClass
Object I’ve turned in to a base class and placed in the same FLA
package {
import flash.events.Event;
import flash.display.MovieClip;
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.display.*;
public class ReadClass extends MovieClip {
public var read:String = "It's Done!";
public function ReadClass() {
//t.text = String(read);
/*
1119: Access of possibly undefined property
read through a reference with static type Class.
*/
}
//public functions
}
}
ERRORS: ‘talk to a DynamicTextField in an other class’
1119: Access of possibly undefined property read through a reference with static type Class.
1120: Access of undefined property read.‘previous error’
ERROR: ‘Attaching scripts to document class’
5006: An ActionScript file can not have more than one externally visible definition
I am not quite sure if I completely got your question, but you could of course make »read« a
staticmember ofClickClass(probably aconst) and access it viaReadClass.read…A cleaner solution would probably be to create a third class, maybe called
UiStringswhich enumerates all the strings needed in the user interface: