Author Topic: Book is not centered on the Flash container  (Read 1939 times)

RASH

  • Newbie
  • *
  • Posts: 7
Book is not centered on the Flash container
« on: February 14, 2009, 11:37:32 pm »
I d/l megazine ver. 1.31 and built it as an Actionscript project in Flex-builder 3.
Everything seems to work fine except that the book is not displayed on the center of the Flash container but rather on the left side of the screen.
To make sure it's not an IDE issue, I also built the project using FlashDevelop and got same results.
Also, when I take the original SWF that comes with the source code and view it locally, everything is fine.
Pls, what am I doing wrong? What am I missing?

To illustrate the problem, please have a look at the following print screens:

book compiled in Flex builder - book is not centered
http://screencast.com/t/pjridv1CJ

original book - book is centered
http://screencast.com/t/tU1Cjublib

thanks,
Rash
« Last Edit: February 15, 2009, 08:19:19 am by RASH »

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: Book is not centered on the Flash container
« Reply #1 on: February 15, 2009, 12:26:28 pm »
Hi Rash,

are you using the MegaZine class by itself? If so you'll have to do the positioning youself, this is normally performed by the Main class (which acts as a wrapper also patching through flashvars and handling SWFAddress).
The origin of the MegaZine element is the top left corner of the left page, so you'll have to do something like

Code: [Select]
// be mz the MegaZine instance and displayArea the container with the full width
mz.x = (displayArea.width - mz.width) / 2;
mz.y = 42; //< whatever you want the distance to the top to be

Regards,
Florian
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.

RASH

  • Newbie
  • *
  • Posts: 7
Re: Book is not centered on the Flash container
« Reply #2 on: February 15, 2009, 01:26:37 pm »
Hi Florian,

I created a new Actionscript project in Flex builder using the MegaZine sourc-code files, without any change.
The MZ instance in Main.as is defined '_mz', but when I set values for _mz.x & _mz.y it does not seem to have any affect on the result.
I tried different numbers, such as
_mz.x = 300;
_mz.y = 100;
but no affect at all. it's always on the left top corner.

I also wonder - the original source code doesn't include this - so how is it that in the DEMO the SWF appears correctly on the center? How the SWF is positioned there?

Any help is appreciated.

Regards,

Rash

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: Book is not centered on the Flash container
« Reply #3 on: February 15, 2009, 01:51:54 pm »
Mmm. If you're using the Main.as I do have a suspicion: try setting the postion after adding the element to the stage (i.e. after addChild). If that helps, it's because the Main tries to position itself correctly (overwriting your settings), but fails miserably...

(Alternatively: outcomment the body of the position function)
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.

RASH

  • Newbie
  • *
  • Posts: 7
Re: Book is not centered on the Flash container
« Reply #4 on: February 15, 2009, 05:19:23 pm »
Well, I managed to fix the problem by modifying the position() function as follows:

private function position():void {         
         _mz.x = -_mz.pageWidth * _mz.scaleX * 0.5;
         _mz.y = -50;
         /*
         if (!isNaN(_top)) {
            _mz.y = _top * _mz.scaleY - stage.stageHeight * 0.5;
         }
         else {
            _mz.y = -_mz.pageHeight * 0.5 * _mz.scaleY;
         }         
         */

Many thanks for the help!

Rash
      }

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: Book is not centered on the Flash container
« Reply #5 on: February 15, 2009, 08:42:38 pm »
Fine if that works for you :)

I think I'll disable the selfpositioning and scaling if the swf is contained within another starting with the next release, to avoid such issues in the future...
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.

RASH

  • Newbie
  • *
  • Posts: 7
Re: Book is not centered on the Flash container
« Reply #6 on: February 16, 2009, 07:55:56 am »
Florian, my boss approved to make a small donation for your project but the donation page is only in German. No English version?

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1985
  • MegaZine3 Developer
    • MegaZine3
Re: Book is not centered on the Flash container
« Reply #7 on: February 16, 2009, 01:30:50 pm »
Thanks a lot! For the donation and also letting me know about that problem...
I always assumed paypal would perform its own user locale check. Seems I was wrong. Should display in english now when coming from the homepage (while it's displayed in english).
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.