# \[MX\] problem with function

**URL:** <https://forum.kirupa.com/t/mx-problem-with-function/25921>\
**Category:** flash\
**Created:** [July 17, 2003, 5:30pm UTC](https://forum.kirupa.com/t/mx-problem-with-function/25921 "2003-07-17T17:30:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipe\_Bastos](https://avatars.discourse-cdn.com/v4/letter/f/f05b48/32.png) [@Felipe\_Bastos](https://forum.kirupa.com/u/Felipe_Bastos)\
**Post date:** [July 17, 2003, 5:30pm UTC](https://forum.kirupa.com/t/mx-problem-with-function/25921/1 "2003-07-17T17:30:18Z")

</div>

On the main timeline, layer as, I have the function goPage:

```auto
_root.C.anterior._visible=0;
function goPage (whichWay) {
	_root.content.destinationFrame = _root.content._currentFrame+whichWay;
	_root.content.alphaChange = -20;
	_root.C.proximo._visible=(_root.content.destinationFrame<>1);
	_root.C.anterior._visible=(_root.content.destinationFrame<>_root.content._totalFrames);
	//trace("function goPage OK");
	updateAfterEvent;
}

```

On a movieclip (instance name “content”) I set:

```auto
onClipEvent(load) {
	stop();
	
}

onClipEvent(enterFrame) {
	_root.C.frameatual = "( " + _root.content._currentframe;
	_root.C.framestotal = "/ " + _root.content._totalframes + " )";
	_alpha+=alphaChange;
	if(_alpha<1) {
		gotoAndStop(destinationFrame);
		alphaChange=20;
	_root.C.frameatual = "( " + _root.content._currentframe;
	_root.C.framestotal = "/ " + _root.content._totalframes + " )";
	}
	if(_alpha>100) {
		alphaChange=0;
	}
}

```

on the btn “next” I set:

```auto
_root.goPage(+1);

```

on the “previous” btn:

```auto
_root.goPage(-1);

```

[color=red] When I hit the next btn the content does not go to the next frame. It goes to the last one. I used this actions in another work and it works fine. What is happening here?[/color]

Thanks

---

<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:** [July 17, 2003, 10:52pm UTC](https://forum.kirupa.com/t/mx-problem-with-function/25921/2 "2003-07-17T22:52:37Z")

</div>

Well, Im not sure, but you are sending “+1” to the goPage-function as a parameter.

Then, in goPage, you are adding “+1” to currentFrame, resulting in the expression:

currentFrame + +1

I mean, if you send “-1” that is a number (minus one), but if you are sending “+1” that is an expression (ADD one - not a simple one).

Try just sending “1” in the goPage-next call, and leave the “-1” in the goPage-previous call, and perhaps it will work.

---

<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:** [July 18, 2003, 12:33am UTC](https://forum.kirupa.com/t/mx-problem-with-function/25921/3 "2003-07-18T00:33:08Z")

</div>

I tried that but it doesnt work!  
I think it might be something with the swf that is loaded into the movieclip.  
Its has some layers with text, mcs, fotos, like a page of a book. And there are some actions and empty movieclips. Sometimes I think its misunderstanding something and cant go to the next frame stooping at the last one.  
Thanks for helping!!!  
Comeback if I find something 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:** [July 19, 2003, 12:34am UTC](https://forum.kirupa.com/t/mx-problem-with-function/25921/4 "2003-07-19T00:34:50Z")

</div>

try

```auto
_root.C.anterior._visible=0;
function goPage (whichWay) {
        _root.content.destinationFrame = _root.content._currentFrame+Number(whichWay);
        _root.content.alphaChange = -20;
        _root.C.proximo._visible=(_root.content.destinationFrame<>1);
        _root.C.anterior._visible=(_root.content.destinationFrame<>_root.content._totalFrames);
        //trace("function goPage OK");
        updateAfterEvent;
}

```

---

<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:** [July 19, 2003, 12:39am UTC](https://forum.kirupa.com/t/mx-problem-with-function/25921/5 "2003-07-19T00:39:02Z")

</div>

one quick thing I noticed skimming

updateAfterEvent;

should be

updateAfterEvent();
