random order not executed

Engaged ,
Aug 05, 2021 Aug 05, 2021

Copy link to clipboard

Copied


over1 = this.A1.on("mouseover", onMouseOver.bind(this));
over2 = this.A2.on("mouseover", onMouseOver.bind(this));
over3 = this.A3.on("mouseover", onMouseOver.bind(this));
over4 = this.A4.on("mouseover", onMouseOver.bind(this));
over5 = this.A5.on("mouseover", onMouseOver.bind(this));
over6 = this.A6.on("mouseover", onMouseOver.bind(this));
over7 = this.A7.on("mouseover", onMouseOver.bind(this));
over8 = this.A8.on("mouseover", onMouseOver.bind(this));
over9 = this.A9.on("mouseover", onMouseOver.bind(this));
over10 = this.A10.on("mouseover", onMouseOver.bind(this));
over11 = this.A11.on("mouseover", onMouseOver.bind(this));
over12 = this.A12.on("mouseover", onMouseOver.bind(this));

 

function onMouseOver(evt) {
item = evt.currentTarget;
item.cursor = "pointer";
}

down1 = this.A1.on("mousedown", onMouseDown.bind(this));
down2 = this.A2.on("mousedown", onMouseDown.bind(this));
down3 = this.A3.on("mousedown", onMouseDown.bind(this));
down4 = this.A4.on("mousedown", onMouseDown.bind(this));
down5 = this.A5.on("mousedown", onMouseDown.bind(this));
down6 = this.A6.on("mousedown", onMouseDown.bind(this));
down7 = this.A7.on("mousedown", onMouseDown.bind(this));
down8 = this.A8.on("mousedown", onMouseDown.bind(this));
down9 = this.A9.on("mousedown", onMouseDown.bind(this));
down10 = this.A10.on("mousedown", onMouseDown.bind(this));
down11 = this.A11.on("mousedown", onMouseDown.bind(this));
down12 = this.A12.on("mousedown", onMouseDown.bind(this));

 

function onMouseDown(evt) {
item = evt.currentTarget;

x = evt.currentTarget.x;
y = evt.currentTarget.y;

item.offset = {
x: 0,
y: 0
};

pt = item.parent.globalToLocal(evt.stageX, evt.stageY);
item.x = pt.x;
item.y = pt.y;
item.drag = true;
}


move1 = this.A1.on("pressmove", onMouseMove.bind(this));
move2 = this.A2.on("pressmove", onMouseMove.bind(this));
move3 = this.A3.on("pressmove", onMouseMove.bind(this));
move4 = this.A4.on("pressmove", onMouseMove.bind(this));
move5 = this.A5.on("pressmove", onMouseMove.bind(this));
move6 = this.A6.on("pressmove", onMouseMove.bind(this));
move7 = this.A7.on("pressmove", onMouseMove.bind(this));
move8 = this.A8.on("pressmove", onMouseMove.bind(this));
move9 = this.A9.on("pressmove", onMouseMove.bind(this));
move10 = this.A10.on("pressmove", onMouseMove.bind(this));
move11 = this.A11.on("pressmove", onMouseMove.bind(this));
move12 = this.A12.on("pressmove", onMouseMove.bind(this));

function onMouseMove(evt) {
item = evt.currentTarget;

this.setChildIndex(item, this.getNumChildren() - 1)
if (item.drag) {
pt = item.parent.globalToLocal(evt.stageX, evt.stageY);
item.x = pt.x;
item.y = pt.y;
}
}

/////////////////////////////////////////////////////////

this.A1.on("pressup", onMouseUp1.bind(this));
this.A1.place1 = this.place1;

function onMouseUp1(evt) {
item = evt.currentTarget;
pt1 = item.localToLocal(this.x, this.y, item.place1);

if (item.place1.hitTest(pt1.x, pt1.y) && p1 == 0) {
this.goood.play();
p1 = 1;
item.x = item.place1.x;
item.y = item.place1.y;
this.A1.off("mouseover", over1);
this.A1.off("mousedown", down1);
this.A1.off("pressmove", move1);
this.A1.mouseEnabled = false;

} else {
item.x = x;
item.y = y;
this.bad.play();
}

.

.

.

.

.

.

this.start = function () {

that.startButton.on("click", function (e) {
that.startTimer(that.updateCallBack, that.endCallback);
that.start_but_bg.visible = false;
that.startButton.visible = false;
root.shuffle();

}, this);

 

var restart = root.restart;
this.shuffle = function () {
setChildIndex.positions.sort(function (x, b) {
return 0.5 - Math.random();
item.originalX = positions[pt].x;
item.originalY = positions[pt].y;
item.mouseEnabled = true;
createjs.Tween.get(item).to({
x: item.originalX,
y: item.originalY
}, 350, createjs.Ease.backInOut);
});

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

puzzle

Why is random order not executed when I press start for 12 moviclip ??

root.shuffle();

??

 

var restart = root.restart;
this.shuffle = function () {
setChildIndex.positions.sort(function (x, b) {
return 0.5 - Math.random();
item.originalX = positions[pt].x;
item.originalY = positions[pt].y;
item.mouseEnabled = true;
createjs.Tween.get(item).to({
x: item.originalX,
y: item.originalY
}, 350, createjs.Ease.backInOut);
});

Views

143

Likes

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
Adobe Community Professional ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

what are you trying to accomplish?

Likes

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
Engaged ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

I want to implement the random order to cut off the replay?

 

var restart = root.restart;
this.shuffle = function () {
setChildIndex.positions.sort(function (x, b) {
return 0.5 - Math.random();
item.originalX = positions[pt].x;
item.originalY = positions[pt].y;
item.mouseEnabled = true;
createjs.Tween.get(item).to({
x: item.originalX,
y: item.originalY
}, 350, createjs.Ease.backInOut);
});

Likes

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
Adobe Community Professional ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

your code makes no sense to me.  and saying you want to "implement a random order to cut off the replay" doesn't make sense either.  

 

what exactly are you trying to do?

Likes

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
Engaged ,
Aug 07, 2021 Aug 07, 2021

Copy link to clipboard

Copied

@kglad @JoãoCésar 

puzzle 

thinking-emoji-34.gif

 

 

 

 

 

 

 

 

The code works except for random order?

Likes

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
Adobe Community Professional ,
Aug 07, 2021 Aug 07, 2021

Copy link to clipboard

Copied

random ordering of what?

Likes

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
Engaged ,
Aug 08, 2021 Aug 08, 2021

Copy link to clipboard

Copied

@kglad 

 

 

 

 

 

 

 

 

 

 

 

 

 

A1 A2 A3 A4 A5 A6 A7 A8 A9 A10

random for x,y 

Likes

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
Adobe Community Professional ,
Aug 09, 2021 Aug 09, 2021

Copy link to clipboard

Copied

assuming you want to use the original positions of A1,...A10 and then assign those positions randomly among those movieclips, call positionF():

 

this.positionA = [];
for(var i=1;i<11;i++){
this.positionA.push([mc.x,mc.y]);
}

 

function repositionF(){
shuffle(this.positionA);
for(var i=1;i<11;i++){
this.getChildByName("A"+i).x = this.positionA[i-1][0];
this.getChildByName("A"+i).y = this.positionA[i-1][1];
}
}

function shuffle(a) {
var p,t,ivar
for (ivar = a.length-1; ivar>=0; ivar--) {
p=Math.floor((ivar+1)*Math.random());
t = a[ivar];
a[ivar] = a[p];
a[p] = t;
}
}

Likes

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
Engaged ,
Aug 10, 2021 Aug 10, 2021

Copy link to clipboard

Copied

LATEST

@kglad 

What do you mean by mc
Replacing it because it shows an error

It has not been implemented?

 

2021-08-10_11-38-59.png

Likes

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