PDA

View Full Version : Namespaces and AS3



Alber Kidd
May 12th, 2008, 10:11 AM
Hi,

I have a load of functions all on my frames . Most of the functions are the similar, add a movieclip and animate it or change the colour of it(see below)

var colorTransform2:ColorTransform = whiteBox2_mc.transform.colorTransform;
colorTransform2.color = 0xffffff;
whiteBox2_mc.transform.colorTransform = colorTransform2;
whiteBox2_mc.alpha = 0.2;


now the problem is I have many simlar variabales and function names and apart from calling them

colorTransform2
colorTransform3
colorTransform4

etc etc.


I wonder is there is a way do this with namespaces (iso I can use the same name for a variable but under a different namespace? Like main timeline like this below:

namespace frame1;
namespace frame2;


frame1 function showValue() {

//this shows the value on frame1
}


frame2 function showValue() {

//this shows the value on frame2
}

wvxvw
May 12th, 2008, 01:06 PM
namespace frame_1 = 'frame_1';
use namespace frame_1;
frame_1 function foo(){
trace('foo');
}
foo();
Yes, you can do it... but why on the timeline?..