Topic: As 2.0
AS 2.0/MTASC difficulties.
Hi All,
I'm trying to write my first widget in AS 2.0/MTASC/FlashDevlop.
Below is my two source files.
-------------------Main.as--------------------------------
class Main
{
public static function main(swfRoot:MovieClip):Void
{
var swfAPP = new Main(swfRoot);
}
public function Main(swfRoot:MovieClip)
{
var TorrentList:ChumbyList = new ChumbyList(swfRoot, "testString");
}
}
-------------------ChumbyList.as--------------------------------
class ChumbyList extends MovieClip
{
var background:MovieClip;
var myLongTermString:String;
public function ChumbyList(myParent:MovieClip, myString:String)
{
background = myParent.createEmptyMovieClip("background", myParent.getNextHighestDepth());
myLongTermString = myString;
var BGColour: Number = 0x777777;
background.beginFill(BGColour, 100);
background.moveTo(0, 0);
background.lineTo(100, 0);
background.lineTo(100, 100);
background.lineTo(0, 100);
background.endFill();
background.onPress = function() {
trace("click");
this.traceString(); //not getting called
//traceString(); //doesn't compile
}
}
public function traceString() {
trace("function called");
trace(myLongTermString);
}
}
--------------------------------------------------------------------
As you can see I am trying to call the .onPress function in my ChumbyList constructor.
From within the .onPress function I am unable to call functions from with inside the class. Is there something a particular way to go about this that I am getting wrong?
Thanks in advance,
Joshua