A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Move a character with touch

  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    7

    Move a character with touch

    Hi,

    I created a game in AS2 where you use the left and right keys to move a character left and right.

    Would I be able to amend the below code (to AS3) so the same thing occurs by touching to the left or the right of the character?

    Thanks
    Matt

    onClipEvent (load) {
    speed = 5;
    var crash:String = undefined;
    }
    onClipEvent (enterFrame) {
    trace(crash);
    if (Key.isDown(Key.LEFT) && crash == undefined) {
    tellTarget ("/Raggles") {
    gotoAndStop(2);
    }
    preXcor = _x;
    _x -= speed;
    _xscale = 100;
    if (_x<265) {
    _x = preXcor;
    }
    }
    if (Key.isDown(Key.RIGHT) && crash == undefined) {
    tellTarget ("/Raggles") {
    gotoAndStop(2);
    }
    preXcor = _x;
    _x += speed;
    _xscale = 100;
    tot = _x+this._width;
    if (_x>860) {
    _x = preXcor;
    }
    }
    }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I don't think you will get anybody to just convert it for you as it takes slightly more than just giving the code, you also need to publish for AIR(whichever one you need)

    http://help.adobe.com/en_US/as3/dev/...a3d6-7ffe.html

    It might be best if you get to grips with the environment you need first

  3. #3
    Junior Member
    Join Date
    Nov 2014
    Posts
    7
    Quote Originally Posted by fruitbeard View Post
    Hi,

    I don't think you will get anybody to just convert it for you as it takes slightly more than just giving the code, you also need to publish for AIR(whichever one you need)

    http://help.adobe.com/en_US/as3/dev/...a3d6-7ffe.html

    It might be best if you get to grips with the environment you need first
    Hi,

    It was really just to see if there was an alternative way:

    I can't have like a button on the screen that if you click it activates the code. For example a button which when pressed tells a movieclip to go to frame 2. And the code i already posted instead of activating when the left key is pressed, activates if the aforementioned movieclip is on frame 2. I know its bastardised but honestly any roundabout way is fine with me at this point :/

    Thanks in advance.

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    You need AS3, the code is the same (virtually) as normal AS3 swf code, but you need touchEvents instead of mouseEvents etc etc
    You also need to publish for AIR etc etc

    You can have a button yes but it needs to be touched or swiped whichever you desire.

    http://help.adobe.com/en_US/air/buil...d0cb-8000.html

    http://stackoverflow.com/questions/2...s-and-desktops

    I wish it could be more simple for you, but its not

    AS3 doesnt use onClipEvent either

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