# Navigating an object path, using a variable

**URL:** <https://forum.kirupa.com/t/navigating-an-object-path-using-a-variable/254357>\
**Category:** Uncategorized\
**Created:** [March 11, 2008, 8:44am UTC](https://forum.kirupa.com/t/navigating-an-object-path-using-a-variable/254357 "2008-03-11T08:44:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danywachy](https://avatars.discourse-cdn.com/v4/letter/d/919ad9/32.png) [@danywachy](https://forum.kirupa.com/u/danywachy)\
**Post date:** [March 11, 2008, 8:44am UTC](https://forum.kirupa.com/t/navigating-an-object-path-using-a-variable/254357/1 "2008-03-11T08:44:19Z")

</div>

lets say I have a variable like this:

```auto
var pathName = "section2";

```

Then I have an object called “book”. “book” is the parent of other objects named:  
section1, section2, section3 and section4.

I want to apply a gotoAndStop() to section2 inside the book object. But instead of typing it the normal way:

```auto
_root.book.section2.gotoAndStop(2);

```

I want to use the variable pathName for this. Like so:

```auto
_root.book.pathName.gotoAndStop(2);

```

This is obviously not working, how can I use a variable as part of an object path navigation?

Thanks in advanced I hope someone here can help me !!! cheers
