Author Topic: IMegaZine functionality  (Read 2724 times)

Max

  • Newbie
  • *
  • Posts: 13
IMegaZine functionality
« on: February 11, 2009, 10:01:12 am »
Just thought id share the names of the setters / getters /functions within IMegaZine which can be used from within loaded swf's(check the actionscript interaction tutorial of Florian in tutorials section), im also kind of missing a getter that returns the number of either the left or right page for counter uses, though im guessing the class de.mightypirates.megazine.gui.PageNumber can be used for this?


Code: [Select]
function get leftToRight():Boolean;
function get muted():Boolean;
function set muted(mute:Boolean):void;
function get pageCount():uint;
function get pageHeight():uint;
function get pageWidth():uint;
function get reflection():Boolean;
function set reflection(enabled:Boolean):void;
function get shadows():Boolean;
function set shadows(enabled:Boolean):void;
function get stage():Stage;
function get state():String;
function getAbsPath(url:String, protocols:Array = null):String;
function getElementById(id:String):AbstractElement;
function getPageInfos():String;
function getThumbnailsFor(page:int):Array;
function gotoAnchor(id:String, instant:Boolean = false):void;
function gotoPage(page:uint, instant:Boolean = false):void;
function firstPage(instant:Boolean = false):void;
function lastPage(instant:Boolean = false):void;
function nextPage(instant:Boolean = false):void;
function prevPage(instant:Boolean = false):void;
function openZoom(galleryOrPath:String, page:int = -1, number:uint = 0):void;
function slideStart():void;
function slideStop():void;

Max

  • Newbie
  • *
  • Posts: 13
Re: IMegaZine functionality
« Reply #1 on: February 11, 2009, 04:00:34 pm »
for the use of customizing the interface, i think its good to add a getter for the currentPage. I have added it myself and it works perfectly fine and wasnt to much of a hassle.

Just added this to IMegaZine:
Code: [Select]
function get currentPage():uint;
and this to MegaZine:

Code: [Select]
public function get currentPage():uint{
return _currentPage
}

call it by calling the instance of IMegaZine.currentPage
in combination with the MegaZineEvent.VISIBLE_x /INVISIBLE_x it works very well.

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: IMegaZine functionality
« Reply #2 on: February 12, 2009, 01:30:51 pm »
Good idea, thanks! I'll add it to the next version :)
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.

Teko

  • Newbie
  • *
  • Posts: 9
Re: IMegaZine functionality
« Reply #3 on: April 03, 2009, 10:22:38 pm »
Hi,

The SWF integration works well, i was wondering though if you can check to see if a specific page has loaded before trying to reference the other SWF.

For example if a SWF on page 3 is going to communicate with a SWF on page 2 but page 3 loads before page 2 has completed loading the code below will return a NULL reference.

element = mz.getElementById("imageHolder");
swf = element.swf;

Any ideas?

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: IMegaZine functionality
« Reply #4 on: April 04, 2009, 06:49:52 am »
Good point there. I messed up the getter -.-

It should actually read
Code: (actionscript3)
  1. public function getElementById(id:String):Element {
  2.    return _elementList[id];
  3. }

Regardless, if you only need to check if it's loaded, can't you you just test the return value of getElementById for null? (with the corrected code you'd test if the .element property is null... I could add a boolean isLoaded property, but it wouldn't do much else ;))

If you require the object to be loaded, though, that'd be another story...
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.

Teko

  • Newbie
  • *
  • Posts: 9
Re: IMegaZine functionality
« Reply #5 on: April 04, 2009, 07:36:01 pm »
Thanks Florian,

You are right i do require that the initial SWF has loaded before the second one references it otherwise the interacting between the two wont work (null reference). For example clicking a button on the right page changes the picture on the left page.

The quick (and incredibly dodgy.. there ive said it) fix ive used is to ensure the second SWF is larger than the first so that it wont complete loading before the first one has completed. I did try looping the element.swf call until it returned a non NULL reference but that just kept looping.

Anyone have any ideas?
Thanks,


Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: IMegaZine functionality
« Reply #6 on: April 05, 2009, 08:45:39 am »
Waiting would currently be the only solution, I guess. Especially in a book which is bigger, and where pages could be unloaded again.

If you change the getter as I wrote, and wait with something like this
Code: (actionscript3)
  1. var other:Element = mz.getElementById("theOtherOne");
  2. setTimeout(checkAvailability, 100);
  3.  
  4. function checkAvailability():void {
  5.    if (other.element == null) {
  6.        setTimeout(checkAvailability, 100);
  7.    } else {
  8.        doCommunication();
  9.    }
  10. }
  11.  
  12. function doCommunication():void {
  13.    other.element.doStuff(); // or whatever
  14. }

it should work, I think. I can't imagine why it shouldn't. Assuming the two swfs are "close enough" (pagewise), of course, so that they can be loaded at the same time. Otherwise I'd need to implement an option that would allow for all elements with an id to be present at all times or something like that.
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.

kalani96746

  • Newbie
  • *
  • Posts: 6
Re: IMegaZine functionality
« Reply #7 on: June 19, 2009, 11:46:36 pm »
Hey Florian really would just like an ordinary event broadcast every time a page is loaded with the reference to the page element which has loaded.

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: IMegaZine functionality
« Reply #8 on: June 24, 2009, 01:05:27 pm »
Can do. Won't be the reference, just the number, but I'll also add a getter to the MegaZine class for getting pages of a given number.
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.