Skip to main content
Participant
August 30, 2021
Question

Simple Drag + Drop Game - Need to use HTML5?

  • August 30, 2021
  • 1 reply
  • 201 views

Hi there. I'm a total n00b looking for some help. I used to make really simple dress up games in Flash 2017 in actionscript 3 .fla - > .swf for web. These games just had the clothes be draggable - not even snapping into place - and I had a back/forth button to change the hair, the doll's expression changed if you hovered over it. I want to make the same thing again but Flash is dead now. If I can still make it in actionscript then I know how to make it but not to export it as something functional ..but I think you can't? so it seems HTML5 is the thing I have to do now? 

I've been googling and reading and watching tutorials but I can't seem to figure it out..they all seem to be making something too different. I'm also confused as to what kind of file I should be trying to export the game as. Any code snippets/help/advice is so so appreciated. Thank you.

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    August 31, 2021

    var this_var = this;

    function initF(){
    for(var i=1;i<=15;i++){
    this_var['pz'+i].addEventListener('pressmove',startDrag2F);
    this_var['pz'+i].addEventListener('pressup',stopDrag2F);

    this_var['pz'+i].addEventListener('pressup',stopDrag2F);

    this_var['pz'+i].startX = this_var['pz'+i].x;

    this_var['pz'+i].startY = this_var['pz'+i].y;
    }
    }
    function startDrag2F(e){
    var img = e.currentTarget;
    img.parent.addChild(e.currentTarget);
    img.x = e.stageX;
    img.y = e.stageY;
    }
    function stopDrag2F(e){
    var hit = false;
    for(var i=1;i<=15;i++){
    var p = this_var['t_grid'+padF(i)].globalToLocal(e.stageX, e.stageY);
    if(e.currentTarget.hitTest(p.x,p.y)){
    e.currentTarget.x = this_var['t_grid'+i].x;
    e.currentTarget.y = this_var['t_grid'+i].y;
    hit = true;
    break;
    }
    }
    if(!hit){
    e.currentTarget.x = e.currentTarget.startX;
    e.currentTarget.y = e.currentTarget.startY;
    } else {
    //checkForEndF();
    }
    }