# Accessing Level with variable

**URL:** <https://forum.kirupa.com/t/accessing-level-with-variable/22074>\
**Category:** flash\
**Created:** [May 29, 2003, 9:26pm UTC](https://forum.kirupa.com/t/accessing-level-with-variable/22074 "2003-05-29T21:26:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![redg](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@redg](https://forum.kirupa.com/u/redg)\
**Post date:** [May 29, 2003, 9:26pm UTC](https://forum.kirupa.com/t/accessing-level-with-variable/22074/1 "2003-05-29T21:26:34Z")

</div>

maybe this problem has been adressed before but i couldn’t find it…

i try to be so clear as possible and i tell you it is not easy in my confused state of mind

i have this problem where i want to put different swf’s on a higher level on the click of a button in a row of buttons where i takes the instance name of the button -thats why this.butaction is in my script - clicked and puts the swf on the stage

all the loading works fine but for some reason i cant access the loaded movie clip to play or unload… i know that loading it on the same level would be a solution… but i want it to appear and dissapear with a litle animation

so every loaded movie needs to be loaded on a higher level…

here is the code i use

on the first frame of the timeline i say:[COLOR=royalblue]  
\_global.loadlevel = 3;[/COLOR][COLOR=darkred]  
//since i want the first time i load a clip to load on \_level3  
[/COLOR]

on the button it says:[COLOR=royalblue]  
on (release) {  
level = ((\_global.loadlevel)-1);  
‘\_level’+level.gotoAndPlay (15)  
loadMovieNum(this.butAction+’.swf’, \_global.loadlevel);  
\_global.loadlevel++;  
}[/COLOR][COLOR=darkred]  
//when i do a trace anywhere in my code it gives me the correct level numbers  
[/COLOR][COLOR=red]  
so very desperado i’m trying to solve the problem for a couple of days now…  
hopefully someone can help me…  
[/COLOR]

**tnx redg**

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 29, 2003, 11:38pm UTC](https://forum.kirupa.com/t/accessing-level-with-variable/22074/2 "2003-05-29T23:38:20Z")

</div>

level = ((\_global.loadlevel)-1);

you should change that to

level = ((\_global.loadlevel)+1);

that way each time it goes up one level … if you have it set at 3 and then you subract 1 all you’re going to get is 2, 1, 0 then you’re out of levels. actually i think you could take the +1 out altogether and it would work fine.

additionally, you might have a problem with something else being loaded on the same level. so try a higher number like 254 or something instead of 3 … that way if you have anything else that is occupying the lower levels it won’t matter.

hope this helps

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 30, 2003, 7:57am UTC](https://forum.kirupa.com/t/accessing-level-with-variable/22074/3 "2003-05-30T07:57:59Z")

</div>

hey shuga tnx for the input anyway…  
but it doesnt work…  
as i was writing a reply to your answer…  
someone else served me de answer…

i just have to say

```
            level = "_level"+((_global.loadlevel)-1);
eval(level).gotoAndPlay(15);

```

this eval pulls the string out of the variable  
🙂
