# Package in variable assignment

**URL:** <https://forum.kirupa.com/t/package-in-variable-assignment/316427>\
**Category:** Uncategorized\
**Created:** [November 21, 2010, 7:26am UTC](https://forum.kirupa.com/t/package-in-variable-assignment/316427 "2010-11-21T07:26:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sasxa](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sasxa](https://forum.kirupa.com/u/sasxa)\
**Post date:** [November 21, 2010, 7:26am UTC](https://forum.kirupa.com/t/package-in-variable-assignment/316427/1 "2010-11-21T07:26:33Z")

</div>

I’m making some custom controls/components and I have an issue with package paths. I know what I want, but don’t know how to do it ^^

I’ll try to illustrate with code:

```php
package {
  public class Test extends Sprite {
    public function Test() {
      // let's make some instances...
      // I'll use full path names to avoid imports
      var _one:ClassOne = new domain.controls.ClassOne();
      var _two:ClassTwo = new domain.controls.ClassTwo();
      var _four:ClassFour = new domain.componens.ClassFour();
 
      // now I want to assign some custom properties
      _one.style = domain.controls.Style.DEFAULT;
      _two.type = domain.controls.classTwo.Type.DEFAULT;
      _two.style = domain.controls.classTwo.Style.RED;
      _four.etc = domain.controls.EtCetera.CUSTOM;
 
      // note: these constants are not simple data type, 
      // like String or Number
      // but Functions, Regular Expressions and whatnot ((;
      // properties (style, type, etc) are mostly setters
    }
  }
}
// sample class
package domain.controls {
  public class ClassOne extends Something {
    private var _style:domain.controls.Style;
    public function ClassOne() {
    }
    protected function set style(value:*):void {
      _style = new domain.controls.Style(value);
      // or whatever, some crazy stuff :P
    }
  }
}

```

This is all ok, works and stuff… But as you can see code is awefull (: And If I make import statements:  
[COLOR=red]import domain.controls.Style;[/COLOR]  
[COLOR=red]import domain.controls.classTwo.Style;[/COLOR]  
[COLOR=black]I’d still have a mess in code, since I’d have to use full paths.[/COLOR]  
Now, I would like to simplify things, but keep it clear also. Lets say I’m making a component that uses several controls. I want to make package part of the assignment statement, like:

```auto
import domain.controls.*;
......
// inside my component
test1.style = [COLOR=red]Style[/COLOR].DEFAULT;
test2.style = [COLOR=red]classTwo.Style[/COLOR].RED;

```

But this is not working… Anyone have an idea how to make things easier? I was thinking about making some kind of proxy class/variable/object named **classTwo** , but before I waste time on that, maybe someone has different idea/aproach…
