# Using variables created from "this"

**URL:** <https://forum.kirupa.com/t/using-variables-created-from-this/76029>\
**Category:** flash\
**Created:** [January 14, 2005, 3:37am UTC](https://forum.kirupa.com/t/using-variables-created-from-this/76029 "2005-01-14T03:37:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![waffe](https://avatars.discourse-cdn.com/v4/letter/w/c37758/32.png) [@waffe](https://forum.kirupa.com/u/waffe)\
**Post date:** [January 14, 2005, 3:37am UTC](https://forum.kirupa.com/t/using-variables-created-from-this/76029/1 "2005-01-14T03:37:11Z")

</div>

I am trying to select an object and use its path as a varible in flash

```auto

c1.c2.onPress =function () {
selected_object = this
trace(selected_object)
selected_object = selected_object.substr(0, 2)
trace(selected_object)
}

```

The 1st trace command yields the full path, but the second trace command yields an “undefined”. This problem seems to exist all over, if I use the variable from “selected\_objcet = this” for any thing it does not work unless I but “” around it - this of course, does not solve the problem.

Another way to point out the problem, if I do a comparison check in flash with the variable created from “this” I get:

c1.c2.onPress =function () {  
selected\_object = this  
selected\_object == c1.c2 \<------- False in flash  
selected\_object == “c1.c2” \<------- True in flash  
}

Is there a way around this problem?
