Author Topic: Using Megazine for a projector file  (Read 1807 times)

Rohan

  • Newbie
  • *
  • Posts: 4
Using Megazine for a projector file
« on: March 25, 2009, 11:42:20 pm »
Hi all, just found this app and I'm excited to start using it.

I'm going to be using this as part of a projector file so I was wondering if anyone else has done this and whether its straight forward or difficult?

Most of the launching aspects seem to be geared towards placing the swf in a browser, but can I just load the swf from my projector file? Will that work?

Thanks in advance!


Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Using Megazine for a projector file
« Reply #1 on: March 26, 2009, 01:23:15 am »
It will. The only "trouble" you'll run into, i.e. the only thing that won't work out of the box, is the positioning. The rest should work just fine.
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.

Rohan

  • Newbie
  • *
  • Posts: 4
Re: Using Megazine for a projector file
« Reply #2 on: March 26, 2009, 03:50:43 am »
It will. The only "trouble" you'll run into, i.e. the only thing that won't work out of the box, is the positioning. The rest should work just fine.

Thanks Florian, this looks like a really great app. Any tips on how to get me started? I'm kind of new to AS3, basically what I have done so far is change the publish settings of my fla so that it is using Main as the document class.

What I basically need to do is launch the MegaZine as an external SWF from the projector file. I just need to be able to create an instance of it, and pass it the variables it needs like its xml file, interface file etc., I also need to be able to position it on my page accordingly.

Is this possible?
« Last Edit: March 26, 2009, 06:16:39 am by Rohan »

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Using Megazine for a projector file
« Reply #3 on: March 26, 2009, 04:29:59 pm »
Well, as you're using a projector it's probably a better idea to use the MegaZine class directly, instead of using the Main as a document class, because this only adds features that won't work in projectors anyways (such as SWFAddress).

So, what I'd recommend is to just create a new instance in your AS, like so:
Code: [Select]
import de.mightypirates.megazine.MegaZine;
var mz:MegaZine = new MegaZine("path/to.xml");
addChild(mz);

// do stuff with the class, like (note that this will only work once the xml is loaded and parsed)
mz.gotoPage(5);

The created instance is a normal display object and can be positioned like any other (using the x and y properties, that is).
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.

Rohan

  • Newbie
  • *
  • Posts: 4
Re: Using Megazine for a projector file
« Reply #4 on: March 27, 2009, 03:41:36 am »
Oh great! Thanks I'll give it a go now and let you know how it comes along :)

Rohan

  • Newbie
  • *
  • Posts: 4
Re: Using Megazine for a projector file
« Reply #5 on: March 27, 2009, 05:04:44 am »
Okay things are...working kind of.

I think I have a few issues with parsing XML in AS3...and also the positioning seems to be a bit strange. Here is my code:

Code: [Select]
import de.mightypirates.megazine.MegaZine;
import de.mightypirates.megazine.events.MegaZineEvent;
import de.mightypirates.megazine.*;

//get window dimensions
var myStage = this.stage;
myStage.scaleMode = StageScaleMode.NO_SCALE;
myStage.align = StageAlign.TOP_LEFT;
stage.displayState = StageDisplayState.FULL_SCREEN;

var winWidth = stage.stageWidth;
var winHeight = stage.stageHeight;

function matchScreen(element) {
element.width = winWidth;
element.height = winHeight;
}

//get XML
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
 
xmlLoader.load(new URLRequest("xml/megazine.xml"));
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

function LoadXML(e:Event):void {

xmlData = new XML(e.target.data);
Parse(xmlData);

}
 
function Parse(input:XML):void {

trace("XML:",input);

}

var mz:MegaZine = new MegaZine(xmlData,"fla/interface.swf");
addChild(mz);

//center the book
mz.x = winWidth/2;
mz.y = winHeight/2;

trace("book position before resize:",mz.x);

// on resize centering

stage.addEventListener(Event.RESIZE, resizeHandler);

function resizeHandler (e:Event):void {

var winWidth = stage.stageWidth;
var winHeight = stage.stageHeight;
mz.x = winWidth/2;
mz.y = winHeight/2;
trace("book position after resize:",mz.x);

}

The parsing isn't really working because my xml file looks like this:

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book SYSTEM "http://megazine.mightypirates.de/megazine.dtd">
<book padgewidth="1000" pageheight="500">
<chapter>
<page>
here is some text
</page>
</chapter>
<chapter>
<page>
here is some more text
</page>
</chapter>
</book>

And none of that is coming through to the book. Trying to figure out how to parse the XML properly now. Is there anything I am doing really wrong here? Thanks so much for the help!

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Using Megazine for a projector file
« Reply #6 on: March 27, 2009, 09:17:16 pm »
You don't have to parse the XML yourself at all. The constructor does not expect XML data, but the url to the XML file to load.

So instead do something like
Code: (actionscript3)
  1. var mz:MegaZine = new MegaZine("xml/megazine.xml", "fla/interface.swf");
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.