# Can't get functions to work after re-entering first frame

**URL:** <https://forum.kirupa.com/t/cant-get-functions-to-work-after-re-entering-first-frame/262979>\
**Category:** flash\
**Created:** [June 11, 2008, 3:40pm UTC](https://forum.kirupa.com/t/cant-get-functions-to-work-after-re-entering-first-frame/262979 "2008-06-11T15:40:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xstevenx](https://avatars.discourse-cdn.com/v4/letter/x/4491bb/32.png) [@xstevenx](https://forum.kirupa.com/u/xstevenx)\
**Post date:** [June 11, 2008, 3:40pm UTC](https://forum.kirupa.com/t/cant-get-functions-to-work-after-re-entering-first-frame/262979/1 "2008-06-11T15:40:09Z")

</div>

I don’t know what’s going on here. I have some onRelease functions on movieclips that work fine. However one of them takes the user to a contact form in another frame but after selecting another button to go back to the first frame of the movieclip none of the functions work again.

Here’s a link to my swf so you can see what I mean:

> **[flash](http://stevenserna.deviantart.com/art/flash-88357292)**
>
> 1234

It’s kind of glitchy because it’s on deviantart and I took out a lot of stuff so the .swf would be smaller.

And here is the action script I’m using:

```auto
stop();

Stage.scaleMode="noScale";
Stage.align="TL";

onLoad = function() :Void {
    definedMove(img, 50, -1300, -2150);
};

img.explore.onRelease = function():Void {
    onMouseMove = function ():Void {
    constrainedMove(img, 5, 0, 0, _xmouse, _ymouse);
    };
};

img.contact.onRelease = function():Void {
    onMouseMove = null;
    definedMove(img, 100, -1300, -2150);
    img.gotoAndPlay(2);
};
///////////////////functions////////////////

function constrainedMove(target:MovieClip, speed:Number, dir:Number, dir2:Number):Void {
    var mousePercent:Number = _xmouse/Stage.width;
    var mousePercent2:Number = _ymouse/Stage.height;
    var mSpeed:Number;
    var mSpeed2:Number;
    if (dir == 1) {
        mSpeed = 1-mousePercent;
    } else {
        mSpeed = mousePercent;
    }
/////////////////////////////
    if (dir2 == 1) {
        mSpeed2 = 1-mousePercent2;
    } else {
        mSpeed2 = mousePercent2;
    }
////////////////////////
    target.destX = Math.round(-((target._width-Stage.width)*mSpeed));
    target.destY = Math.round(-((target._height-Stage.height)*mSpeed2));
    target.onEnterFrame = function() {
        if (target._x == target.destX) {
            delete target.onEnterFrame;
    } else {
            target._x += Math.ceil((target.destX-target._x)*(speed/75));
    }
        if (target._y == target.destY) {
            delete target.onEnterFrame;
    } else {
            target._y += Math.ceil((target.destY-target._y)*(speed/75));
        }
    };
}
function definedMove(target:MovieClip, speed:Number, destination:Number, destination2:Number):Void {
    target.onEnterFrame = function() {
        if (target._x == destination) {
            delete target.onEnterFrame;
        } else if ((destination-target._x)>0) {
            target._x += Math.ceil((destination-target._x)*(speed/100));
        } else {
            target._x += Math.floor((destination-target._x)*(speed/100));
        };
        if (target._y == destination2) {
            delete target.onEnterFrame;
        } else if ((destination2-target._y)>0) {
            target._y += Math.ceil((destination2-target._y)*(speed/100));
        } else {
            target._y += Math.floor((destination2-target._y)*(speed/100));
        };
    };
};

```

I’m thinking because the actionscript is located in the \_root of the whole .fla and all the action is happening in the img movieclip that something is off. I just don’t know what else to do. Any help would be greatly appreciated. Thanks!

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 11, 2008, 3:44pm UTC](https://forum.kirupa.com/t/cant-get-functions-to-work-after-re-entering-first-frame/262979/2 "2008-06-11T15:44:29Z")

</div>

stop with the timeline control all ready!

AS and timeline always mucks up

---

<div class="post-metadata">

**Author:** ![xstevenx](https://avatars.discourse-cdn.com/v4/letter/x/4491bb/32.png) [@xstevenx](https://forum.kirupa.com/u/xstevenx)\
**Post date:** [June 11, 2008, 4:59pm UTC](https://forum.kirupa.com/t/cant-get-functions-to-work-after-re-entering-first-frame/262979/3 "2008-06-11T16:59:52Z")

</div>

Well could you suggest a better alternative please?
