Author Topic: control megazine via JS from Webpage  (Read 1369 times)

brc_ragnaroek

  • Newbie
  • *
  • Posts: 12
control megazine via JS from Webpage
« on: February 17, 2010, 06:19:12 pm »
All the features of the Megazine are very interesting. While searching i found no information on the following question:

is it possible to control megazine via JS embedded in the same Webpage as the application?

What ineed to do is, to flip to pages from the webpage and to retrieve information on which page is opened.

Thx. also posted for version1.0

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: control megazine via JS from Webpage
« Reply #1 on: February 17, 2010, 09:50:45 pm »
This is possible indeed. Have a look at the megazine.js file for all the available JavaScript functions.
You'll need to have the javascript plugin loaded.
Then you can do something like this:
Code: (javascript)
  1. MegaZine.gotoPage(10);
  2. // Or
  3. MegaZine.gotoNextPage();
  4. // To get the current page
  5. alert(MegaZine.getCurrentPage());
  6. // Or to update an element with the ID "pagenum"
  7. MegaZine.onPageChange = function(newPage, oldPage) { document.getElementById("pagenum").innerHtml = newPage; };
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

brc_ragnaroek

  • Newbie
  • *
  • Posts: 12
Re: control megazine via JS from Webpage
« Reply #2 on: February 19, 2010, 02:29:23 pm »
i am sure. it will be a silly error build in from me but:

i am doin the following:

Code: [Select]
<script type="text/javascript" src="megazine/megazine.js"></script>
    <script type="text/javascript">
swfobject.embedSWF("megazine/megazine.swf", "megazine", "800", "600", "9.0.115", "swfobject/expressInstall.swf", null, {bgcolor : "#333333", allowFullscreen : "true", allowScriptAccess: "always"}, {id : "megazine"});
    </script>

and

Code: [Select]
<input type="button" value="test" onclick="Javascript:megazine.gotoPage(10);">
But all i get ist:

Code: [Select]
Fehler: megazine.gotoPage is not a function

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: control megazine via JS from Webpage
« Reply #3 on: February 19, 2010, 04:16:18 pm »
JavaScript is case sensitive. It's MegaZine, not megazine.
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

brc_ragnaroek

  • Newbie
  • *
  • Posts: 12
Re: control megazine via JS from Webpage
« Reply #4 on: February 19, 2010, 04:29:25 pm »
Yes but CamelCase-Written:

Code: [Select]
Fehler: MegaZine.getMovie().gotoPage is not a function
Quelldatei: file:///E:/Blaetterkatalog/demo/megazine/megazine.js
Zeile: 114

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: control megazine via JS from Webpage
« Reply #5 on: February 19, 2010, 04:36:04 pm »
As it reads "demo" there: might I assume you downloaded the demo zip? I forgot to update that, it
was still version 1.38. I just uploaded the new demo (based on 2.0.6), maybe you'll have more luck
with that. Although it *should* work with the 1.38 one, too... maybe it's because the files are accessed
locally (i.e. via file:///...). Could you try this via a webserver (i.e. access it via http://...), e.g. using wamp
or xampp or just a regular webserver?
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.