Hi there,
In my application I have a container object (ContainerSquares) that has a number of smaller objects (Square). I create an instance of the container class on the main timeline, and create the instances of the squares inside of the container class. The Square object is a movieClip in the library that is linked to the Square class.
I can create these movieclips fine, but when I try to code an onRelease for them, I can't seem to reference any functions outside of the onRelease function. If I put a trace directly inside of the onRelease I can see it, but if I put a function inside the container class with a trace, and call that from the onRelease function, I can't see that (I've tried referencing it with every syntax I could think of (_root.container.function, this.cParent.function [cParent is a var in Square, it references the parent container]), I've also tried putting the function to call in the Square class, and the main timeline, and I can't seem to call any other function belonging to any of them (main movie, Container, or Square) inside of this onRelease.
The other weird thing is that I can perform the actions directly inside of the onRelease handler. I can check what frame that instance of a mcSquare is on, and tell it to gotoAndPlay("something")... but I have a few of them, and it seems ridiculous to code the same thing directly into each onRelease.
This works:
This doesn't work:
Regardless of where I put 'otherFunction' or how I reference it. It's maddening.
I suppose I could use a for loop and go through an array of these objects and still write the code just once, but I'd REALLY like to know how to call another function from inside the onRelease function, and why it's not working!
Sorry for the long rambling post! Thanks!
c.
In my application I have a container object (ContainerSquares) that has a number of smaller objects (Square). I create an instance of the container class on the main timeline, and create the instances of the squares inside of the container class. The Square object is a movieClip in the library that is linked to the Square class.
I can create these movieclips fine, but when I try to code an onRelease for them, I can't seem to reference any functions outside of the onRelease function. If I put a trace directly inside of the onRelease I can see it, but if I put a function inside the container class with a trace, and call that from the onRelease function, I can't see that (I've tried referencing it with every syntax I could think of (_root.container.function, this.cParent.function [cParent is a var in Square, it references the parent container]), I've also tried putting the function to call in the Square class, and the main timeline, and I can't seem to call any other function belonging to any of them (main movie, Container, or Square) inside of this onRelease.
The other weird thing is that I can perform the actions directly inside of the onRelease handler. I can check what frame that instance of a mcSquare is on, and tell it to gotoAndPlay("something")... but I have a few of them, and it seems ridiculous to code the same thing directly into each onRelease.
This works:
Code:
this.mcSquare1.onRelease = function(){
trace("in onRelease");
if(this._currentframe > 19){
this.gotoAndPlay("next");
}else if (this._currentframe > 9){
this.gotoAndPlay("big");
} else if(this._currentframe > 0){
this.gotoAndPlay("next");
}
}
This doesn't work:
Code:
this.mcSquare3.onPress = function()
{this.otherFunction(mcSquare3);}
Regardless of where I put 'otherFunction' or how I reference it. It's maddening.
I suppose I could use a for loop and go through an array of these objects and still write the code just once, but I'd REALLY like to know how to call another function from inside the onRelease function, and why it's not working!
Sorry for the long rambling post! Thanks!
c.