A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: MX functions driving me nuts

  1. #1
    Senior Member Pporksoda's Avatar
    Join Date
    Jul 2000
    Location
    baltimore
    Posts
    174
    i define a simple function in frame 1 on the main timeline that looks like this:

    function moveMe() {
    this._x = _parent._xmouse;
    }

    I create multiple movieclips and put this code on them:

    onClipEvent (load) {
    moveMe = _root.moveMe;
    }
    onClipEvent (enterFrame) {
    moveMe();
    }

    this allows me to change the function and globally affect any movie clip that references it. it also stores any variables passed by the function local to the movieclip instance, not on the root.

    this works fine exported v.5, but doesn't work as v.6

    my question is simply this: in MX, how do i call a function defined on the root into a movieclip where it can run as if it were defined locally?

    i know the answer is simple. i'm no programmer. speak simply. thanks.

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    667
    You could rewrite your function as:

    MovieClip.prototype.moveMe = function() {
    this._x = _xmouse;
    };

    Then call it in your movie clips:

    onClipEvent(enterFrame) {
    moveMe();
    }

  3. #3
    Senior Member
    Join Date
    May 2001
    Posts
    1,838
    Try:

    function moveMe() {
    this._x =this._parent._xmouse;
    }

  4. #4
    Senior Member Pporksoda's Avatar
    Join Date
    Jul 2000
    Location
    baltimore
    Posts
    174
    thanks much. very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center