Author Topic: Change the Navigation Bar  (Read 3658 times)

colt

  • Newbie
  • *
  • Posts: 8
Change the Navigation Bar
« on: February 13, 2009, 11:09:38 pm »
Hi, im new into this amazing program, im trying to change the position of the navigation bar but im unable to find the action script that calls it, if some could give me a little help please at least I would like to know with file calls and place the position of the navigation bar or buttons to change them to different possitions.
I'm COLT !

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Change the Navigation Bar
« Reply #1 on: February 15, 2009, 12:30:58 pm »
Hi colt,

if it's a simpler position change of the bar, you can use the barpos attribute of the book.

For more in-depth changes have a look at the Navigation class (de.mightypirates.megazine.gui.Navigation) which builds the displayed navigation bar.

It's actually even possible to build a completely custom navigation - I'm planning on writing a tutorial on that soon.
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.

colt

  • Newbie
  • *
  • Posts: 8
Re: Change the Navigation Bar
« Reply #2 on: February 16, 2009, 02:44:11 pm »
thanx man, Im cheking on it right now and I will give it a try to customize it , thanks for the help :)
I'm COLT !

colt

  • Newbie
  • *
  • Posts: 8
Re: Change the Navigation Bar
« Reply #3 on: February 16, 2009, 05:26:47 pm »
 ??? , I was able to find the navigation code and somehow change it a little bit, where can I find the code that shows the zoom glass at the every bottom of each page ? I would like to change it or remove it to see how it looks like
I'm COLT !

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Change the Navigation Bar
« Reply #4 on: February 16, 2009, 11:00:59 pm »
The zoom buttons are implicitly defined in the img tags, and will be shown if the hires attribute is set - unless the showbutton attribute is not set to false.

To change the look of the button open the interface.fla and change the according library item.
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.

colt

  • Newbie
  • *
  • Posts: 8
Re: Change the Navigation Bar
« Reply #5 on: February 17, 2009, 10:31:54 pm »
have anyone thought  on changing the way of navigating the magazine ? , for example im thinking on making an input so users can just type the page number and it will go directly, could that be possible with a little coding ?
I'm COLT !

kopitejay

  • Support
  • Jr. Member
  • *****
  • Posts: 37
Re: Change the Navigation Bar
« Reply #6 on: February 18, 2009, 10:48:44 am »
Hey Colt

Thought I'd have a crack at this one.
I have not tested the code below, but this is how I would personally go about it.

I'd place a text box on the stage ("txt_pageNo") for the user to input a page number.
I'd also place a button next to it ("btn_gotoPage") so the user can execute the goto page function.
This function takes the user's input and converts it to an integer, which in turn is sent to the method gotoPage that belongs to the MegaZine class.
This should get the page to turn to the user's choice.

Code: [Select]
function btnPress_gotoPage(event:MouseEvent):void
{
//Get user input from text box on stage and convert to an integer
var pageNo = int(txt_pageNo.text);
//Call gotoPage Method on the MegaZine class
_mz.gotoPage(pageNo, false);
}
btn_gotoPage.addEventListener(MouseEvent.CLICK, btnPress_gotoPage);

I have not included any form validation or error catching in this button script but would suggest you do so to stop users inputting invalid values like letters.

Let us know how you get on with this.

Cheers
Jay

colt

  • Newbie
  • *
  • Posts: 8
Re: Change the Navigation Bar
« Reply #7 on: February 18, 2009, 04:14:17 pm »
Thanks Jay, I have applied what your idea but it doesnt work :( , I just get some strange errors, the code you mentioned has to be applied to a frame or button?  and where we must call it on the megazine.fla  or an action script file?
I'm COLT !

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Change the Navigation Bar
« Reply #8 on: February 18, 2009, 04:37:37 pm »
It's not that quite simple, I'm afraid.

Two possible ways (there are more to be sure):
  • Create an element in the interface.fla's library that represents your navigation bar element, i.e. with the textfield and the button.
    Make it available as a class to ActionScript (library element properties, see other elements like the ButtonXXX ones and you'll see what I mean).
    In the LibraryConstants.as and LibrarySWF.as files (both in de/mightypirates/megazine/gui/): in the first add a constant for your element, in the second insert a case for your element.
    In the Navigation.as (same folder, not the one in ../elements) around line 180 you'll see the creation of an array with all the possible buttons, add your element to that list (in [] because every element is expected to be an array, for elements that can be toggled).
    Now your last problem will be the size of the element, which will most likely be wider than normal buttons... easiest way I can think of is to add an "empty" element right next to it... else you'll need to play around with the code a bit.

    This will probably work if done right, but might require some in depth reading of the code if it doesn't work. And will likely require some more changes. I haven't touched those classes for some time now, so I'm not too sure on the exact workings myself. ;)
  • This will be easier, but may still require more work: it is possible to build completely custom navigations, in which case the stage content of the library.as will be displayed instead of the normal navigation bar. Currently (version 1.31) you have to declare a variable named custom in the interface.fla's first frame's ActionScript:
    var custom:Boolean = true;
    This will undergo some minor changes in the next version (after which I'll also write a little tutorial on that, currently it's more of a hack...)
    That way you can add anything you like, but you'll also have to reimplement basic workings like the pagination and all the other buttons. You'll then want to declare a function named setup with a signature like this:
    function setup(mz:Object, currentPage:uint):void
    to interact with the megazine instance.

So all in all: possible, yes. But work intensive.
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.

colt

  • Newbie
  • *
  • Posts: 8
Re: Change the Navigation Bar
« Reply #9 on: February 18, 2009, 09:26:10 pm »
wow.. I tried the first way you posted florian and it didnt worked, if Im not mistaken there most be another actions script file that is related to these buttons but im unable to find them , well anyways I will depth read the code to see if I find something  :-\
I'm COLT !

kopitejay

  • Support
  • Jr. Member
  • *****
  • Posts: 37
Re: Change the Navigation Bar
« Reply #10 on: February 19, 2009, 10:47:27 am »
Hi Colt

I thought I'd give it a go myself.  ;D
I have attached a fla with the code in that I suggested.
I have it working here locally on my machine.

Place this file in the same directory as your xml file and make sure that the MegaZine classes are in your classpath.
Then update "XXX.xml" in the fla so it points to your xml file.

Publish out and you should get a crude but working page search function.

Cheers
Jay

colt

  • Newbie
  • *
  • Posts: 8
Re: Change the Navigation Bar
« Reply #11 on: February 19, 2009, 04:13:49 pm »
 ;D amazing it worked, the only thing left is to make the navigation bar appear since it doesnt show up so I think I will have to check the code itself to see whats going up, great job Jay   :D
I'm COLT !

kopitejay

  • Support
  • Jr. Member
  • *****
  • Posts: 37
Re: Change the Navigation Bar
« Reply #12 on: February 20, 2009, 10:46:04 am »
No problem, Colt.  ;)

Happy to help

Cheers
Jay

maatsche

  • Newbie
  • *
  • Posts: 3
Re: Change the Navigation Bar
« Reply #13 on: June 23, 2009, 01:01:49 am »
hey guys, im planning to create my custom navigation too. i cant see the file kopitejay uploaded.

can anyone please give me a link to the file or a link to a good tutorial in order to do so?

Cheers,

Marcel

PS: Florian, echt cooles project! Mach weiter so!