Author Topic: Referencing Megazine from an external production  (Read 2226 times)

kopitejay

  • Support
  • Jr. Member
  • *****
  • Posts: 37
Referencing Megazine from an external production
« on: February 11, 2009, 11:17:15 am »
Firstly, well done on developing Megazine. It is really cool.

Secondly, I need some advice on referencing the Megazine object so I can call some of the methods (e.g. firstPage();)
The scenario is that I am loading the megazine.swf into my main production and I want to be able to develop custom controls for the user interface, which make calls to megazine methods. These controls I want to sit inside the main production.

This is the code I use to load megazine.swf into the main production.

Code: [Select]
var p:MovieClip = parent as MovieClip;

var myrequest:URLRequest=new URLRequest("megazine.swf");
var myloader:Loader=new Loader();
myloader.load(myrequest);

var mycontent:MovieClip;

function swfLoaded(myevent:Event):void{
addChild(myloader);
mycontent=myevent.target.content;
mycontent.x=0;
mycontent.y=255;
mycontent.scaleX = 0.85;
mycontent.scaleY = 0.85;
p.gotoAndPlay(3);
}
myloader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);

My initial thought was to use "mycontent._mz.firstPage(false);" (The _mz I am referencing here is the one from the main class). This did not work so I decided to write a custom public function in the main class that would make a call to the firstPage function in the Megazine class. Again this didn't work. I don't know what the next stage is.

If you can give me any guidance of what to try next I will be very grateful.
For once I'm really puzzled.  ;D

Cheers
Jay

Max

  • Newbie
  • *
  • Posts: 13
Re: Referencing Megazine from an external production
« Reply #1 on: February 11, 2009, 03:21:40 pm »
if you add a function called megazineSetup like this:
Code: [Select]
function megazineSetup(mz:IMegaZine, page:IPage, even:Boolean, library:ILibrary){}
it should work, ive already posted a list of all the functionality within IMegaZine in a different post.
Also the above function is described in more detail in the tutorial section in Actionscript Interaction.

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Referencing Megazine from an external production
« Reply #2 on: February 12, 2009, 01:54:34 pm »
The megazineSetup (which I have yet to write a tutorial about...) only works for swfs loaded via the img elements, so that's not an option here, I'm afraid.

The idea of adding a public function to the Main class should in fact work, you'll just have to make sure to address it properly. When loading the swf via a loader you'll have to use something like this:

Code: [Select]
function swfLoaded(e:Event):void {
    var main:DisplayObject = myloader.getChildAt(0); // to get the actual instance of the Main class
    main.yourPublicFunction();
}

If you can live without the features provided through the main class, though (SWFAddress, console, ...) you could just create a new instance, though, instead of loading the swf (which would simplifiy interaction a bit). You can do that by adding the classes to your include path an then create a new instance by doing
Code: [Select]
var mz:MegaZine = new 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.

kopitejay

  • Support
  • Jr. Member
  • *****
  • Posts: 37
Re: Referencing Megazine from an external production
« Reply #3 on: February 16, 2009, 10:32:23 am »
Hi Guys

Thanks for your tips.
I'll go through some of them today and see how I get on.

Cheers
Jay

kopitejay

  • Support
  • Jr. Member
  • *****
  • Posts: 37
Re: Referencing Megazine from an external production
« Reply #4 on: February 16, 2009, 05:42:43 pm »
Thanks for your help. I inserted the code that you suggested below and I have control of the object now. It is also running more efficiently using this method.

Code: [Select]
var mz:MegaZine = new MegaZine();
Thanks again guys.

reiderea

  • Newbie
  • *
  • Posts: 2
Re: Referencing Megazine from an external production
« Reply #5 on: March 03, 2009, 12:20:37 pm »
Hi there-
Thanks for sharing MegaZine! 

I am hoping someone can give me some advice... I am using the same code "var mz:MegaZine = new MegaZine();" to reference the MegaZine from my main production.  All is working okay- except that the .swf's I've loaded (via img tag in xml) no longer navigate to the URL's as they should.  The .swf's have a button- when clicked- navigates to the URL I specified in InDesign CS4. 
The buttons all work perfectly when I just test megazine.swf- but when I export my main production- the rollover effect continues to show, but the URL interactivity is lost.  Any thoughts/ideas??  Thanks so much!