Disabling swipe on pages

I have tried to do swipe: on one page, pages.disable(); pages.page.swipe:false and nothing disables swipe. Any ideas?

I have separate js files for each page. I would like to execute the js file everytime the page is active how can I do that? I have tried running the function, under page transitioned, swipe and S.update and nothing.

Thanks

1 Like

Sounds like a scope issue perhaps. Are you using plain ZIM with no Adobe Animate?

pages.disable() - works for me to disable. And running the JavaScript function on "page", "swipe" or "pagetransitioned" should work as well. Do a zog() in the event function to see if the event is running.

You are welcome to show some code and we can take a look.

Plain ZIM.

Here is the code:

// given F (Frame), S (Stage), W (width), H (height)
// put code here
let score1 = 0;
let score2 = 0;
let score3 = 0;
let score4 = 0;
var intro = makeIntro(stage);
var pv1a = makePv1a(stage);
var pv1b = makePv1b(stage);
var pv1c = makePv1c(stage);
var pv1d = makePv1d(stage);
var pv1e = makePv1e(stage);
var pv2a = makePv2a(stage);
var pv2b = makePv2b(stage);
var pv2c = makePv2c(stage);
var pv2d = makePv2d(stage);
var pv2e = makePv2e(stage);
var ftn1a = makeFtn1a(stage);
var ftn1b = makeFtn1b(stage);
var ftn1c = makeFtn1c(stage);
var ftn1d = makeFtn1d(stage);
var ftn1e = makeFtn1e(stage);
var ftn2a = makeFtn2a(stage);
var ftn2b = makeFtn2b(stage);
var ftn2c = makeFtn2c(stage);
var ftn2d = makeFtn2d(stage);
var ftn2e = makeFtn2e(stage);
var ftn3a = makeFtn3a(stage);
var ftn3b = makeFtn3b(stage);
var ftn3c = makeFtn3c(stage);
var ftn3d = makeFtn3d(stage);
var ftn3e = makeFtn3e(stage);
const transs = ["reveal", "slide", "fade", "fan", "pixelDark", "pixelLight", "pixelZIM",
	"bubbleDark", "bubbleLight", "bubbleZIM", "lineDark", "lineLight", "lineZIM",
	"explodeDark", "explodeLight", "explodeZIM"];
shuffle(transs);
rightsnd = new Aud("right.mp3");
wrongsnd = new Aud("wrong.mp3");

var pages = new Pages([{page: intro, swipe: []}, pv1a, pv1b, pv1c, pv1d, pv1e, pv2a, pv2b, pv2c, pv2d, pv2e,
	ftn1a, ftn1b, ftn1c, ftn1d, ftn1e, ftn2a, ftn2b, ftn2c, ftn2d, ftn2e, ftn3a, ftn3b, ftn3c, ftn3d, ftn3e
], transs[rand(0, transs.length - 1)], .7
).addTo();
pages.disable();

intro.name = "intro";
pv1a.name = "pv1a";
pv1b.name = "pv1b";
pv1c.name = "pv1c";
pv1d.name = "pv1d";
pv1e.name = "pv1e";
pv2a.name = "pv2a";
pv2b.name = "pv2b";
pv2c.name = "pv2c";
pv2d.name = "pv2d";
pv2e.name = "pv2e";
ftn1a.name = "ftn1a";
ftn1b.name = "ftn1b";
ftn1c.name = "ftn1c";
ftn1d.name = "ftn1d";
ftn1e.name = "ftn1e";
ftn2a.name = "ftn2a";
ftn2b.name = "ftn2b";
ftn2c.name = "ftn2c";
ftn2d.name = "ftn2d";
ftn2e.name = "ftn2e";
ftn3a.name = "ftn3a";
ftn3b.name = "ftn3b";
ftn3c.name = "ftn3c";
ftn3d.name = "ftn3d";
ftn3e.name = "ftn3e";

const paagnms = [pv1a, pv1b, pv1c, pv1d, pv1e, pv2a, pv2b, pv2c, pv2d, pv2e,
	ftn1a, ftn1b, ftn1c, ftn1d, ftn1e, ftn2a, ftn2b, ftn2c, ftn2d, ftn2e, ftn3a, ftn3b, ftn3c, ftn3d, ftn3e];

loop(paagnms.length, i => {
	paagnms[i].go.on("mousedown", function() {
		pages.go(intro, "left");
		if (paagnms[i].correct == true) {
			if (n == 0) {
				score1 = paagnms[i].points + score1;
				intro.p1score.label.text = score1;
			} else if (n == 1) {
				score2 = paagnms[i].points + score2;
				intro.p2score.label.text = score2;
			} else if (n == 2) {
				score3 = paagnms[i].points + score3;
				intro.p3score.label.text = score3;
			} else if (n == 3) {
				score4 = paagnms[i].points + score4;
				intro.p4score.label.text = score4;
			}

		}

		nextplayer();
		S.update();
	});


});
pages.on("pagetransitioned", function() {
	shuffle(transs);
	pages.disable();
	S.update();
});
pages.on("page", () => {
	pages.disable();
	S.update();

});

pages.on("swipe", () => {
	pages.disable();

});

You can see I even added the empty swipe array to the first page, as I understood from the docs, to "disable" the swipe.

Also, you can see the functions tied to each page that launch the separate js files. How can I launch the js file every time the page is "active"? Right now, they only launch one, when I go back to the page it's as it was when I left it. I doesn't relaunch the js file.

Thanks,

  1. SWIPE

You should just need the pages.disable() after you make the pages object - I see you have it there. Hmmm... that works is this example:

So just to be clear - a swipe is when you swipe it with your finger or mouse. The only way I can go from page to page in the example above is to press the arrow. That is the same for you too?

  1. FUNCTIONS

You have a set of function calls at the top - those are actually calling the functions at that time - and therefore maybe making all your pages at once to start?

Are you trying rather to not do that - but randomly choose a page to make as you swipe to the next page?

If so, it might be good to make a second page as a Page() or a Container() and that's it. Then when you go to the second page, you page2.removeAllChildren() and use one of your functions to add new content to page2. Then you can go back to page1 at any time.

Give it some thought. I can't quite tell what you are wanting to do, but that was the gist I got.

For me, I can swipe with the mouse or touch still even with the disable. I don't want to do that. I want to be able to go to a specific page only by clicking a button.

I am creating a jeopardy type game with pages and each page has stuff that would dynamically chance that's why i want to be able to run the function each time a page is active. I have tried the remove all on the "page transitioned" method and then executed the js function. The page gets cleared but the new content doesn't get loaded as if the function doesn't run.

I will give it another go tomorrow.

Thanks

1 Like

So, are you saying that the example I posted on the editor is swiping for you? It does not swipe for me on my PC touch screen or on Android or Apple iOS.

No, my code swipes not the example.

This is solved. I added the pages to a container, removed and disposed of all of that and ran the function to repopulate.

I may have been mistaken on the swipe. I have a tile with buttons and I have the action on mousedown so when I press the mouse down and move the cursor it goes to that page and not becuase I swipe. duh!

Working like a charm, I LOVE ZIM! So fun to code, less code, even though I love to code! :slight_smile:

Thanks

1 Like