# Slide menu

**URL:** https://forum.kirupa.com/t/slide-menu/23562
**Category:** Uncategorized
**Created:** [June 19, 2003, 3:24pm UTC](https://forum.kirupa.com/t/slide-menu/23562 "2003-06-19T15:24:09Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![blah\_de\_blah](https://avatars.discourse-cdn.com/v4/letter/b/a8b319/32.png) [@blah\_de\_blah](https://forum.kirupa.com/u/blah_de_blah)
#### Post date: [June 19, 2003, 3:24pm UTC](https://forum.kirupa.com/t/slide-menu/23562/1 "2003-06-19T15:24:09Z")

</div>

well i was reading this tutorial…  
[http://www.kirupa.com/developer/flash5/slidingmenu.htm](http://www.kirupa.com/developer/flash5/slidingmenu.htm)

And i dont’ really understand this line…i know its a tutorial but i can’t seem to find where it explains this line…  
[AS]  
onClipEvent (load) {  
\_root.xnew = \_root.mask2.\_x + (4-1)\*100/2 ;  
}  
[/AS]

All it says is it sets a new position for the main slide thing, but why 4-1? and then multiply by 100 divided by 2?

And another quesiton, is why using prototypes? I read the thing about it in the AS tricks, but is there a general answer to it, so i know when to apply it in the future…thx

---

<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: [June 19, 2003, 3:36pm UTC](https://forum.kirupa.com/t/slide-menu/23562/2 "2003-06-19T15:36:24Z")

</div>

that is a line of code that is executed once: when the instance is…well…instanciated or loaded (hence load). what this seems to be doing is setting a variable \_root.xnew

it’s setting it to the value of the x location of \_root.mask2 (in the form \_root.mask2.\_x) and adding the value (4-1)\*100/2;

[edit]:

it’s not necessarily setting a position as the code is only calling for the location. and it also eludes me why that person put a mathematical constant in the form of an equation when he could’ve just solved it outside AS.

and as for prototypes, they are exactly like functions only, you can attach them to certain objects. the advantage of this is that with each object instance (duplicate, if you will), you can call that function and it will behave exactly like it would with any other object. the catch and advantage of prototypes though is the function can _only_ be called by that object and nothing else.

---

<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: [June 19, 2003, 3:37pm UTC](https://forum.kirupa.com/t/slide-menu/23562/3 "2003-06-19T15:37:27Z")

</div>

yea i get that part, but is there any reason for choosing those particular numbers? like 4, 1, 100, 2?!

---

<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: [June 19, 2003, 3:40pm UTC](https://forum.kirupa.com/t/slide-menu/23562/4 "2003-06-19T15:40:51Z")

</div>

the writer of that code must’ve had some special reason and it’s a shame he didn’t document it.

---

<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: [June 19, 2003, 3:44pm UTC](https://forum.kirupa.com/t/slide-menu/23562/5 "2003-06-19T15:44:14Z")

</div>

hmm, well i think ive figured wat the 100 and 2 are, which are just postitions…but why not just 50!? anyways why si it an advantage that it can only be called by an object?! I still don’t really see why it is better :-\

---

<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: [June 19, 2003, 3:52pm UTC](https://forum.kirupa.com/t/slide-menu/23562/6 "2003-06-19T15:52:46Z")

</div>

well, prototype functions have the capability of manipulating variables that are fixated, or unique to that certain object (are you familiar with classes in c++). calling the function from just anywhere (aside from impossible with prototypes) can have adverse effects. for example with a prototype like so:

```auto

MovieClip.prototype.moveLeft = function () {
this._x--;
};

```

you can’t have an array object move left like a movieclip can. it simply doesn’t have the “this.\_x” variable, or property. on the flip side you can have certain functions that only deal with arrays and not movieclips.

---

<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: [June 19, 2003, 3:55pm UTC](https://forum.kirupa.com/t/slide-menu/23562/7 "2003-06-19T15:55:30Z")

</div>

alrite i get that part thx…

but this part…  
[AS]  
MovieClip.prototype.move2 = function () {  
dest = \_root.xnew ;  
pos = this.\_x ;  
vel = vel\*0.7 + (dest-pos)/7 ;  
this.\_x += vel ;  
}  
[/AS]

i understand that, but when it says this.\_x, what exactly is it referring to? the mask? or the moving clip?

---

<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: [June 19, 2003, 3:58pm UTC](https://forum.kirupa.com/t/slide-menu/23562/8 "2003-06-19T15:58:23Z")

</div>

it’s referring to the \_x property of whatever object that calls this function. i can’t say any further since this is only the prototype. look for the actual movieclip that calls this function, like “ball.move2();” or something. in this example, the \_x would be referring to “ball”'s \_x.

---

<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: [June 19, 2003, 3:59pm UTC](https://forum.kirupa.com/t/slide-menu/23562/9 "2003-06-19T15:59:36Z")

</div>

well the only thing that is reffering to it is the line…  
[AS]  
onClipEvent (enterFrame) {  
move2 () ;  
}  
[/AS]

so what would that be? the frame?

---

<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: [June 19, 2003, 4:00pm UTC](https://forum.kirupa.com/t/slide-menu/23562/10 "2003-06-19T16:00:28Z")

</div>

no whatever movieclip this code is in, since you can only call “onClipEvent” in a movieclip.

---

<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: [June 19, 2003, 4:01pm UTC](https://forum.kirupa.com/t/slide-menu/23562/11 "2003-06-19T16:01:15Z")

</div>

ah yes…i see. Alrite i get the thing now, thx a lot for your help 🙂

---

<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: [June 19, 2003, 4:01pm UTC](https://forum.kirupa.com/t/slide-menu/23562/12 "2003-06-19T16:01:41Z")

</div>

yep, that’s what i’m here for 🙂

---

<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: [June 19, 2003, 4:31pm UTC](https://forum.kirupa.com/t/slide-menu/23562/13 "2003-06-19T16:31:05Z")

</div>

> \*Originally posted by blah-de-blah \*  
> \*\*hmm, well i think ive figured wat the 100 and 2 are, which are just postitions…but why not just 50!? anyways why si it an advantage that it can only be called by an object?! I still don’t really see why it is better :-\ \*\*  
> Yeah, that code isn’t really clear, sorry about that. It’s just that I was afraid that if I just put 150 instead of (4-1)\*100/2, people wouldn’t understand where this number came from 🙂

4-1 refers to the number of the cell (it’s the fourth, but it starts from 0 so it is the 4-1 = 3rd)  
100 is the width of the cell  
/2 because the registration point is in the middle.

Anyway, I definitely need to rewrite that tute, it’s seriously outdated and badly scripted ☹

---

<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: [June 19, 2003, 8:34pm UTC](https://forum.kirupa.com/t/slide-menu/23562/14 "2003-06-19T20:34:43Z")

</div>

Ilyas…:bad:

---

<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: [June 19, 2003, 8:41pm UTC](https://forum.kirupa.com/t/slide-menu/23562/15 "2003-06-19T20:41:26Z")

</div>

Yes? :sure:

---

<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: [June 19, 2003, 8:45pm UTC](https://forum.kirupa.com/t/slide-menu/23562/16 "2003-06-19T20:45:07Z")

</div>

…oh nothing :sigh:

:bad:
