Navigation Problems

Hi there,
I am trying to control what _root frame a movieclip goes to when it is finished from a _root button and am having some problems.

This is what I want to happen:

When the button is released go to a specific frame of the desired mc, if the last frame of that corresponding mc is reached go to a specific _root frame. (i hope this makes sense)

The script is as follows:

on (release) {
cube_mc.gotoAndPlay(“cubeplay”);
if (cube_mc._currentframe == cube_mc._totalframes) {
_root.gotoAndPlay(home);
}
}

Could u give me any scripting help as I am a bit of a novice.
J_Mo