A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Nice movieclip moving xy - need as1 to as2 conversion.

  1. #1
    Junior Member
    Join Date
    Oct 2001
    Posts
    3

    Question Nice movieclip moving xy - need as1 to as2 conversion.

    I've got a nice code moving movieclip in xy axis with a hit of a button... but it is as1 and so I cannot use some fonts features present in higher flash versions. If exported in as2 the movieclip moves only via x axis. Could someone please help me convert the code to as2? It is not much and I'm still in my very early stages of as education.
    Here it is as attached to the movieclip:

    onClipEvent (enterFrame) {
    Xsquare = _root.maincontainer.mapmc._x;
    Xdiff = Xpos-Xsquare;
    Xmove = Xdiff/12;
    _root.maincontainer.mapmc._x = Xsquare+Xmove;
    Ysquare = _root.maincontainer.mapmc._y;
    Ydiff = Ypos-Ysquare;
    Ymove = Ydiff/12;
    _root.maincontainer.mapmc._y = Ysquare+Ymove;
    updateAfterEvent(enterFrame);
    }

    and now the code for a button

    on (release) {
    _root.maincontainer.mapmc.Xpos = 1670;
    _root.maincontainer.mapmc.ypos = 1700;

    }

    Thanks in advance!

  2. #2
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    This code can be use in both AS1 and AS2. The thing made mistake is a capital Y.

    Code:
    onClipEvent (enterFrame) {
    Xsquare = _root.maincontainer.mapmc._x;
    Xdiff = Xpos-Xsquare;
    Xmove = Xdiff/12;
    _root.maincontainer.mapmc._x = Xsquare+Xmove;
    Ysquare = _root.maincontainer.mapmc._y;
    Ydiff = Ypos-Ysquare;
    Ymove = Ydiff/12;
    _root.maincontainer.mapmc._y = Ysquare+Ymove;
    updateAfterEvent(enterFrame);
    }
    
    and now the code for a button
    
    on (release) {
    _root.maincontainer.mapmc.Xpos = 1670;
    _root.maincontainer.mapmc.Ypos = 1700;
    
    }


    arkitx

  3. #3
    Junior Member
    Join Date
    Oct 2001
    Posts
    3
    Thanks a lot. I forgot As2 is case sensitive. Now it works.

Tags for this Thread

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