• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Convert Actionscript to HTML5

New Here ,
Dec 11, 2021 Dec 11, 2021

Copy link to clipboard

Copied

Can someone please help me convert the following from Actionscript to HTML5:

 

import flash.events.MouseEvent

stop();

var offset:int = 20

var BH1StartX:int = 347.15
var BH1StartY:int = 376.75
var BH1EndX:int = 816.6
var BH1EndY:int = 514.65

BH1.buttonMode = true;
BH1.addEventListener (MouseEvent.MOUSE_DOWN, startDragging);
BH1.addEventListener (MouseEvent.MOUSE_UP, stopDragging);

var BH2StartX:int = 192.4
var BH2StartY:int = 212.1
var BH2EndX:int = 746.2
var BH2EndY:int = 577.95

BH2.buttonMode = true;
BH2.addEventListener (MouseEvent.MOUSE_DOWN, startDragging);
BH2.addEventListener (MouseEvent.MOUSE_UP, stopDragging);

var BH3StartX:int = 397.3
var BH3StartY:int = 435.35
var BH3EndX:int = 1047.05
var BH3EndY:int = 365.35

BH3.buttonMode = true;
BH3.addEventListener (MouseEvent.MOUSE_DOWN, startDragging);
BH3.addEventListener (MouseEvent.MOUSE_UP, stopDragging);

var BH4StartX:int = 103.4
var BH4StartY:int = 331.65
var BH4EndX:int = 868.8
var BH4EndY:int = 606.7

BH4.buttonMode = true;
BH4.addEventListener (MouseEvent.MOUSE_DOWN, startDragging);
BH4.addEventListener (MouseEvent.MOUSE_UP, stopDragging);

var BH5StartX:int = 401.8
var BH5StartY:int = 15.95
var BH5EndX:int = 1046.4
var BH5EndY:int = 517.75

BH5.buttonMode = true;
BH5.addEventListener (MouseEvent.MOUSE_DOWN, startDragging);
BH5.addEventListener (MouseEvent.MOUSE_UP, stopDragging);

var BH6StartX:int = 334.3
var BH6StartY:int = -33.4
var BH6EndX:int = 1313.95
var BH6EndY:int = 208.55

BH6.buttonMode = true;
BH6.addEventListener (MouseEvent.MOUSE_DOWN, startDragging);
BH6.addEventListener (MouseEvent.MOUSE_UP, stopDragging);

//------------------------------------------------------------------


function startDragging(e:MouseEvent): void {
e.currentTarget.startDrag();
}
function stopDragging(e:MouseEvent): void {
e.currentTarget.stopDrag();
switch (e.currentTarget) {
case BH1:
if (BH1.x < BH1EndX - offset || BH1.x > BH1EndX + offset || BH1.y < BH1EndY - offset || BH1.y > BH1EndY + offset){
BH1.x = BH1StartX;
BH1.y = BH1StartY;
} else {
BH1.x = BH1EndX;
BH1.y = BH1EndY;
}
case BH2:
if (BH2.x < BH2EndX - offset || BH2.x > BH2EndX + offset || BH2.y < BH2EndY - offset || BH2.y > BH2EndY + offset){
BH2.x = BH2StartX;
BH2.y = BH2StartY;
} else {
BH2.x = BH2EndX;
BH2.y = BH2EndY;
}
case BH3:
if (BH3.x < BH3EndX - offset || BH3.x > BH3EndX + offset || BH3.y < BH3EndY - offset || BH3.y > BH3EndY + offset){
BH3.x = BH3StartX;
BH3.y = BH3StartY;
} else {
BH3.x = BH3EndX;
BH3.y = BH3EndY;
}
case BH4:
if (BH4.x < BH4EndX - offset || BH4.x > BH4EndX + offset || BH4.y < BH4EndY - offset || BH4.y > BH4EndY + offset){
BH4.x = BH4StartX;
BH4.y = BH4StartY;
} else {
BH4.x = BH4EndX;
BH4.y = BH4EndY;
}
case BH5:
if (BH5.x < BH5EndX - offset || BH5.x > BH5EndX + offset || BH5.y < BH5EndY - offset || BH5.y > BH5EndY + offset){
BH5.x = BH5StartX;
BH5.y = BH5StartY;
} else {
BH5.x = BH5EndX;
BH5.y = BH5EndY;
}
case BH6:
if (BH6.x < BH6EndX - offset || BH6.x > BH6EndX + offset || BH6.y < BH6EndY - offset || BH6.y > BH6EndY + offset){
BH6.x = BH6StartX;
BH6.y = BH6StartY;
} else {
BH6.x = BH6EndX;
BH6.y = BH6EndY;
}
}
}

Views

106

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 12, 2021 Dec 12, 2021

Copy link to clipboard

Copied

LATEST

instead of 

 

import flash.events.MouseEvent

stop();

var offset:int = 20

var BH1StartX:int = 347.15
var BH1StartY:int = 376.75
var BH1EndX:int = 816.6
var BH1EndY:int = 514.65

BH1.buttonMode = true;
BH1.addEventListener (MouseEvent.MOUSE_DOWN, startDragging);
BH1.addEventListener (MouseEvent.MOUSE_UP, stopDragging);

 

use:

 

this.stop();

var offset = 20

var BH1StartX = 347.15
var BH1StartY = 376.75
var BH1EndX = 816.6
var BH1EndY = 514.65

// BH1.buttonMode = true;  // you'll need to change the cursor on "mouseover" and "mouseout"
BH1.addEventListener ("mousedown", startDragging);
BH1.addEventListener ("pressup", stopDragging);

 

 

etc.

 

finally,

 

function startDragging(e) {
e.currentTarget.addEventListener("pressmove", dragF.bind(e.currentTarget);
}

function dragF(e){

this.x = e.stageX;
this.y = e.stageY;

stage.update();

}

 

function stopDragging(e) {
//e.currentTarget.stopDrag();

// rest unchanged

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines