I was wondering if there is a simple way to access variables from a class object, where the variables are not actually a part of that class.
So if you had an array defined on the first frame of the stage, and added some elements to it, you could use the methods of the custom class to manipulate the array’s data.
Stage Frame 1
var myArray:Array = new Array( "apple", "banana", "pear" );
var myClass:someFunctions = new someFunctions();
myClass.addValue( "orange" );
myClass.sortValues();
someFunctions.as
package{
public class someFunctions{
public function someFunctions(){
}
public function addValue():void{
//add an element to the array
}
public function sortValues():void{
//sort the values in the array
}
}
}
It might not seem logical as to why you would ever want to do that, but it’s a very simple example, and it’s the means I’m after, not the result.
I’m creating a list of functions available to execute by a user via an input field. To keep things simple I made them the methods of a class. The issue, however, is that these methods need to manipulate objects which are on the stage, added and removed by a separate controller class. Passing the objects by reference to the class as a parameter would not be viable with what I’m trying to do either.
Any ideas? thanks.