views:

181

answers:

1

Hi,

Im trying to find some way (in actionscript 3) to output info for the current package at runtime.

Given the following code snippet;

package com.foo.thing
{
  import com.foo.Helper;

  public class Tester
  {
    public function Tester(){
      Helper.tracePackage();
    } 
  }
}

I'd want the tracePackage method to trace out the string "com.foo.thing.Tester". Is there any way to do that?

Cheers, Greg

+2  A: 

Hi you can use the getQualifiedClassName() method to find out the full path of an object, you can then reg ex to just get the package.

var fullName:String = getQualifiedClassName(this);
var justPackage:String = fullName.replace(/::[\w]+/, "");

Magic!

Hope this helps

Perfect - just what I was looking for! Cheers
MrGreg