# Namespaces and AS3

**URL:** <https://forum.kirupa.com/t/namespaces-and-as3/260075>\
**Category:** flash\
**Created:** [May 12, 2008, 1:11pm UTC](https://forum.kirupa.com/t/namespaces-and-as3/260075 "2008-05-12T13:11:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alber\_Kidd](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@Alber\_Kidd](https://forum.kirupa.com/u/Alber_Kidd)\
**Post date:** [May 12, 2008, 1:11pm UTC](https://forum.kirupa.com/t/namespaces-and-as3/260075/1 "2008-05-12T13:11:13Z")

</div>

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  
}

---

<div class="post-metadata">

**Author:** ![wvxvw](https://avatars.discourse-cdn.com/v4/letter/w/a9a28c/32.png) [@wvxvw](https://forum.kirupa.com/u/wvxvw)\
**Post date:** [May 12, 2008, 4:06pm UTC](https://forum.kirupa.com/t/namespaces-and-as3/260075/2 "2008-05-12T16:06:02Z")

</div>

```auto
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?..
