# Namespace and the "in" operator?

**URL:** <https://forum.kirupa.com/t/namespace-and-the-in-operator/261856>\
**Category:** flash\
**Created:** [May 31, 2008, 9:27pm UTC](https://forum.kirupa.com/t/namespace-and-the-in-operator/261856 "2008-05-31T21:27:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![warhero](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/warhero/32/1251_2.png) [@warhero](https://forum.kirupa.com/u/warhero)\
**Post date:** [May 31, 2008, 9:27pm UTC](https://forum.kirupa.com/t/namespace-and-the-in-operator/261856/1 "2008-05-31T21:27:32Z")

</div>

I’m trying to figure out how to use namespaces with the “in” operator. My problem is that I’m using dynamic objects and can’t get a reference to the target namespace without an error being thrown.

this is essentially what I’m trying to do…

```auto

var obj:IEventDispatcher = IEventDispatcher(e.target);
var info:Object = Object(edinfo[obj]);
var f:String = info.callbackPrefix + func;
var d:* = info.callbackDelegate;
var ns:Namespace = d.event_handler; //event_handler is the namespace in "d". This causes problems because d is not typed??
trace(f in ns);

```

That code doesn’t tell you much about context of what I’m doing. But that’s what I need to do with this namespace situation…

Any ideas?  
Thanks.

---

<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:** [June 1, 2008, 4:40pm UTC](https://forum.kirupa.com/t/namespace-and-the-in-operator/261856/2 "2008-06-01T16:40:18Z")

</div>

```auto
package {
	import flash.display.Sprite;
	import flash.utils.describeType;
	
	public class Foo extends Sprite {
		
		public namespace abc = 'abcd';
		
		public function Foo () {
			super();
			var methods:XMLList = describeType(this).*.(attribute('declaredBy') == "Foo" && name() == "method").@name;
			for each(var s:XML in methods){
				try {
					this.abc::[s]();
					trace('using NS');
				} catch (e:Error) {
					this[s]();
					trace('not using using NS');
				}
			}
		};
		
		abc function fooFunc ():void {
			trace ('I\'m fooFunc');
		}
		public function barFunc ():void {
			trace ('I\'m barFunc');
		}
	}
}

```

Don’t know how helpfull this is, but… can you tell a bit more about your task? May be the solution is more simple…

---

<div class="post-metadata">

**Author:** ![warhero](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/warhero/32/1251_2.png) [@warhero](https://forum.kirupa.com/u/warhero)\
**Post date:** [June 2, 2008, 2:20am UTC](https://forum.kirupa.com/t/namespace-and-the-in-operator/261856/3 "2008-06-02T02:20:41Z")

</div>

yeah that’s somewhat helpful. My biggest concern was having to use a try catch. Because of what I’m doing, there could potentially be a lot of exceptions raised. and try catch’s are slow. But that describe type might lead me down the right path… let me know if you think of anything else.

---

<div class="post-metadata">

**Author:** ![warhero](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/warhero/32/1251_2.png) [@warhero](https://forum.kirupa.com/u/warhero)\
**Post date:** [June 2, 2008, 3:23am UTC](https://forum.kirupa.com/t/namespace-and-the-in-operator/261856/4 "2008-06-02T03:23:03Z")

</div>

cool that got me what I needed… like so:

```auto

var d:XMLList = describeType(callbackDelegate).*.(attribute('uri') == event_handler && name() == "method");

```

that gives me all methods in the specified namespace. so i don’t need the “in” operator anymore, I just use the xml…

thanks.
