# Need some help understanding abit of code

**URL:** https://forum.kirupa.com/t/need-some-help-understanding-abit-of-code/309524
**Category:** Uncategorized
**Created:** [May 17, 2010, 4:28pm UTC](https://forum.kirupa.com/t/need-some-help-understanding-abit-of-code/309524 "2010-05-17T16:28:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Iakona](https://avatars.discourse-cdn.com/v4/letter/i/bbe5ce/32.png) [@Iakona](https://forum.kirupa.com/u/Iakona)
#### Post date: [May 17, 2010, 4:28pm UTC](https://forum.kirupa.com/t/need-some-help-understanding-abit-of-code/309524/1 "2010-05-17T16:28:41Z")

</div>

> stop()

\_global.applescollected = 0;  
\_global.maxapples = 5;

xpos = 190;  
for (i=1;i\<=\_global.maxapples;i++){  
attachMovie(“appleicon”,[“apples”+i],i);  
xpos +=30  
\_root[“apples”+i].\_x = xpos;  
\_root[“apples”+i].\_y = 568;  
}

// Controls Player Speed  
var mySpeed:Number = 4;

// Controls how far the Player bounces off the wall after impact  
var myBounce:Number = 4;  
onEnterFrame = function():Void {  
**with (\_root.player) {**

// keyboard controls  
if (Key.isDown(Key.DOWN)) {  
\_y += mySpeed;  
gotoAndStop(“forward”);  
}  
if (Key.isDown(Key.UP)) {  
\_y -= mySpeed;  
gotoAndStop(“back”);  
}  
if (Key.isDown(Key.LEFT)) {  
\_x -= mySpeed;  
gotoAndStop(“left”);  
}  
if (Key.isDown(Key.RIGHT)) {  
\_x += mySpeed;  
gotoAndStop(“right”);  
}

// detect if edges of the player is colliding with the Maze Walls  
if (\_root.maze.hitTest(getBounds(\_root).xMax, \_y, true)) {  
\_x -= myBounce;  
}  
if (\_root.maze.hitTest(getBounds(\_root).xMin, \_y, true)) {  
\_x += myBounce;  
}  
if (\_root.maze.hitTest(\_x, getBounds(\_root).yMax, true)) {  
\_y -= myBounce;  
}  
if (\_root.maze.hitTest(\_x, getBounds(\_root).yMin, true)) {  
\_y += myBounce;  
}

if (\_global.applescollected == \_global.maxapples) {  
\_root.empty.attachMovie(“gold”, “goldapple”,1);  
}

if (\_root.empty.hitTest(\_x, getBounds(\_root).yMax, true)) {  
unloadMovie(\_root.player);  
\_root.gotoAndStop(1);

}  
}  
The bit in bold has me stumped, mainly the “with” part… I knew the rest in reference to my player movieclip. It does something though because if i remove it the code breaks. It’s for a college project and my lecturer won’t accept my code until i know what “with” does… It also seems to cause an error when the player hits the end zone(goldapple).

This the error in the output box  
**Error: A ‘with’ action failed because the specified object did not exist.**

So anyway what does with do… and is there away to remove it without breaking my code?

Thanks in advance.
