Accessing undetermined component

Hello,

I just started messing with unity and one of the things that struck me, is that there doesn’t seem to be any system of parent class in Javascript (like in Flash Actionscript)… So now I do not know how to resolve this little problem:

I want to make sort of a sprite manager which I tell to go to a frame, then it automatically modifies the tiling/offset properties of the texture so it shows the good frame. This part is alright, but I’d want my script to receive an array of objects that contains the actual frame stats for each frame(tileX, tileY, offsetX, offsetY) I previously build with a little utility I’ve made externally.

How could I make it accept some sort of pre-made Value Object containing those stats?

Key->Value in JS would be Hashtable

in C# it would either be Hashtable or Dictionary<KeyClass,ValueClass>

Thanks for your time :slight_smile: Actually I’ve just found some info on extending and classes on a post on which you helped http://forum.unity3d.com/viewtopic.php?t=47112&highlight=class+extends

With this information I’ve been able to build all I wanted but my processing Behavior only takes my parent class array and not my child class array… why?

Here is the code if it ever helps…

AnimateSprite (processing Behavior)

var framesPerSecond = 10.0;
var playing=true;
var currentFrame:float =1.0;


//The CRUCIAL Variable that contains AnimationArr1 in this example
var myAnim:AnimationArr;

private var time:float;
private var anim:Array=[];


function Awake(){
	time=0;
	
	//I get my timeline Array from the anim passed in parameter
	anim=myAnim.timeline;
	print(anim); //null ; I don't know why...
}

AnimationArr (Basic class file)

class AnimationArr extends MonoBehaviour{
	var timeline:Array;
}

class AnimationFrame{
	var width:float;
	var height:float;
	var offsetX:float;
	var offsetY:float;
	var x:float;
	var y:float;
	var tileX:float;
	var tileY:float;
	var name:String;
	
	
	function AnimationFrame(w:float,h:float,theX:float,theY:float,oX:float,oY:float,n:String){
		width=w;
		height=h;
		x=theX;
		y=theY;
		offsetX=oX;
		offsetY=oY;
		name=n;
	}
}

AnimationArr1(Actual VO based on AnimationArr)

class AnimationArr1 extends AnimationArr{
	var timeline=[
		new AnimationFrame(75.85,39.85,37.9,20.05,0,0.8,"phoenix_dwn_01"),
		new AnimationFrame(78,40,115.5,21,0.149,0.839,"phoenix_dwn_02"),
		new AnimationFrame(58.5,46,211.2,67.5,0.35,0.64,"phoenix_rgt_03"),
		new AnimationFrame(59.5,63,269.75,76.5,0.46,0.5,"phoenix_rgt_04"),
		new AnimationFrame(76,47.5,338,75.75,0.585,0.611,"phoenix_up_01"),
		new AnimationFrame(78,49,39,130,0,0.396,"phoenix_up_03"),
		new AnimationFrame(66,69,120,132.5,0.169,0.347,"phoenix_up_04")
	];
}

Okay, that was some stupid question… I attempted to modify a “super” variable from outside a function, outside the constructor, that obviously won’t work… it’s all fixed, thanks for your support :smile: