Wouldn’t it be nice to create a reference by path. Here is a solution in AS1.
//via an object property
a = {}
a.x = 23
pathRef(‘x’,'_level0.a.x’)
trace(x) //23
x = 45
trace(x) //45
trace(a.x) //45
//via a movieclip property
pathRef(‘x’,'_level0._x’)
trace(x) //0
x = -100
trace(x) //-100
trace(_level0._x) //-100
Better still as a pathRef is always created by path so if you swap the object it is pointed at, the reference will still work. With pure references this would break.
a = {}
a.x = 23
pathRef(‘x’,'_level0.a.x’)
trace(x)
//redefine a
a = function(){}
a.x = “I am a function now!”
trace(x) //I am a function now!
Too fun. This one has 1000′s of uses from remote controlling objects to reference resilient classes.
As always send me any bugs or changes in the code.
Cheers,
ted ::)
