Author Topic: Changing the settings box and inputting information  (Read 1458 times)

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Changing the settings box and inputting information
« on: April 05, 2009, 09:55:43 pm »
Hello,

I want to make a few changes to the Settings dialogue box. My idea is to firstly change the Settings button to look like a pencil



and secondly to change the appearance of the Settings box



I want the user to be able to type in a review in the Settings box and then when they click the little tick, the users review is sent to a PHP and MySQL database and sent into the XML to be displayed in the book.

I already have the Megazine communicating with PHP and MySQL already i still have alot of work to do with regard to relationships, tables, interface and refactoring.

But what i really want to know is how can i change the appearance of the Settings dialogue box that pops up (e.g get a input textbox displaying), if anybody can be specific about where exactly i can change everything it would be great.

Thanks so much.

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Changing the settings box and inputting information
« Reply #1 on: April 06, 2009, 07:28:09 am »
Hi.

You'll need to change the interface.fla (for which you'll need the Flash IDE from CS3 or CS4) and then republish/compile it.

In the library you'll find a symbol named btnConfig (in the folder static) which you need to edit to change the settings button's appearance.

In the classes folder there's a symbol named Settings, which is the "window" shown when one clicks the settings button.

To change the behavior of the settings box you'll need to modify the SettingsDialog class (SettingsDialog.as in the megazine/gui folder) and then republish/compile the megazine.fla.

Good luck ;)
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.

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Changing the settings box and inputting information
« Reply #2 on: April 06, 2009, 12:12:02 pm »
Thanks Florian, you the man!

I'll let you know if i have troubles  ;)

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Changing the settings box and inputting information
« Reply #3 on: April 26, 2009, 11:04:23 pm »
Hey Florian,

i'm trying to get reviews that are written in an input text box thats in the Settings MC into my localhost database just to test, i don't think the problem is in my PHP but here it is...

Code: (php)
  1. <?php
  2.  
  3. if (isset($_POST['newReview'])){
  4.  
  5. include_once("Connections/connection.php");
  6.  
  7. $userReview = $_POST['newReview'];
  8.  
  9. $userReview = stripslashes($userReview);
  10.  
  11. $sql = mysql_query("SELECT * FROM reviews WHERE review='$userReview'");
  12. while($row = mysql_fetch_array($sql)){
  13. $userReview = $row["review"];
  14. }
  15.  
  16. if ($_POST['newReview']) {
  17. $state = $_POST['newReview'];
  18. $sql = mysql_query("INSERT INTO reviews VALUES review='$userReview'");
  19. }
  20.  
  21. exit();
  22. ?>

And heres the ActionScript, the only things i've added are var variables, varSend, varLoader just after the imports and the onClose function down at the very bottom where i put

Code: (actionscript3)
  1. variables.newReview = reviewTxt.text;
  2. varLoader.load(varSend);

into the function. If you could help it would be great. I'm pretty poor at AS so if you could explain in simple terms i would be really grateful.

Code: (actionscript3)
  1.  
  2. package de.mightypirates.megazine.gui {
  3.  
  4. import de.mightypirates.megazine.MegaZine;
  5. import de.mightypirates.utils.Localizer;
  6. import de.mightypirates.utils.Logger;
  7. import de.mightypirates.utils.ToolTip;
  8.  
  9. import flash.display.*;
  10. import flash.events.*;
  11. import flash.geom.Rectangle;
  12. import flash.net.SharedObject;
  13. import flash.text.TextField;
  14.  
  15. var variables:URLVariables = new URLVariables;
  16.  
  17. var varSend:URLRequest = new URLRequest("http://localhost/megazine_experiment/megazine/review_parse.php");
  18. varSend.method = URLRequestMethod.POST;
  19. varSend.data = variables;
  20.  
  21. var varLoader:URLLoader = new URLLoader;
  22. varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  23. varLoader.addEventListener(Event.COMPLETE, onClose);
  24.  
  25. public class SettingsDialog extends Sprite {
  26.  
  27.  
  28. public function SettingsDialog(mz:MegaZine, loc:Localizer, lib:Library) {
  29.  
  30. visible = false;
  31.  
  32.  
  33. lib.getInstanceOf(LibraryConstants.SETTINGS) as DisplayObjectContainer;
  34.  
  35. tt = new ToolTip("", gui["btnOK"] as SimpleButton);
  36. loc.registerObject(tt, "text", "LNG_SETTINGS_ACCEPT");
  37.  
  38.  
  39. (gui["dragBar"] as Sprite).buttonMode = true;
  40. (gui["dragBar"] as Sprite).addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
  41.  
  42.  
  43. (gui["btnOK"] as SimpleButton).addEventListener(MouseEvent.CLICK, onClose);
  44.  
  45. addChild(gui);
  46.  
  47.  
  48. addEventListener(Event.ADDED_TO_STAGE, registerEventListeners);
  49. }
  50.  
  51. private function registerEventListeners(e:Event):void {
  52. removeEventListener(Event.ADDED_TO_STAGE, registerEventListeners);
  53. addEventListener(Event.REMOVED_FROM_STAGE, removeEventListeners);
  54. stage.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
  55. }
  56.  
  57. private function removeEventListeners(e:Event):void {
  58. removeEventListener(Event.REMOVED_FROM_STAGE, removeEventListeners);
  59. stage.removeEventListener(MouseEvent.MOUSE_UP, onStopDrag);
  60. }
  61.  
  62. private function onStartDrag(e:MouseEvent):void {
  63. startDrag(false);
  64. }
  65.  
  66. private function onStopDrag(e:MouseEvent):void {
  67. stopDrag();
  68. }
  69.  
  70.  
  71. private function onClose(e:MouseEvent):void {
  72.  
  73. variables.newReview = reviewTxt.text;
  74. varLoader.load(varSend);
  75.  
  76. visible = false;
  77. dispatchEvent(new Event("closed"));
  78. }
  79.  
  80. }
  81.  
  82. }

Thanks a million :) :D

Florian: just added code highlighting to make it more readable.
« Last Edit: April 27, 2009, 11:49:19 am by Florian Nücke »

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Changing the settings box and inputting information
« Reply #4 on: April 27, 2009, 11:56:33 am »
Does this actually compile? ;)

Because the whole block of code before the class declaration (i.e. everything from var variables:... to varLoader.addEventListener...) is not allowed there. You'll have to place that inside the class.

Plus your reviewTxt which I assume is part of the display object in the library is most likely not accessible this way, you'll need to go through the gui object gotten from the library.

Try something like this:

Code: (actionscript3)
  1.  
  2. package de.mightypirates.megazine.gui {
  3.  
  4. import de.mightypirates.megazine.MegaZine;
  5. import de.mightypirates.utils.Localizer;
  6. import de.mightypirates.utils.Logger;
  7. import de.mightypirates.utils.ToolTip;
  8.  
  9. import flash.display.*;
  10. import flash.events.*;
  11. import flash.geom.Rectangle;
  12. import flash.net.SharedObject;
  13. import flash.text.TextField;
  14.  
  15. public class SettingsDialog extends Sprite {
  16.  
  17.  
  18. var variables:URLVariables = new URLVariables;
  19.  
  20. // ! This...
  21. var varSend:URLRequest;
  22. var varLoader:URLLoader;
  23. var reviewTxt:TextField;
  24.  
  25. public function SettingsDialog(mz:MegaZine, loc:Localizer, lib:Library) {
  26.  
  27. // ! This...
  28. varSend = new URLRequest("http://localhost/megazine_experiment/megazine/review_parse.php");
  29. varSend.method = URLRequestMethod.POST;
  30. varSend.data = variables;
  31. varLoader =  new URLLoader();
  32. varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  33. varLoader.addEventListener(Event.COMPLETE, onClose);
  34.  
  35. visible = false;
  36.  
  37. lib.getInstanceOf(LibraryConstants.SETTINGS) as DisplayObjectContainer;
  38.  
  39. tt = new ToolTip("", gui["btnOK"] as SimpleButton);
  40. loc.registerObject(tt, "text", "LNG_SETTINGS_ACCEPT");
  41.  
  42.  
  43. (gui["dragBar"] as Sprite).buttonMode = true;
  44. (gui["dragBar"] as Sprite).addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
  45.  
  46.  
  47. (gui["btnOK"] as SimpleButton).addEventListener(MouseEvent.CLICK, onClose);
  48.  
  49. // ! And this
  50. reviewTxt = gui["reviewTxt"] as TextField;
  51.  
  52. addChild(gui);
  53.  
  54.  
  55. addEventListener(Event.ADDED_TO_STAGE, registerEventListeners);
  56. }
  57.  
  58. private function registerEventListeners(e:Event):void {
  59. removeEventListener(Event.ADDED_TO_STAGE, registerEventListeners);
  60. addEventListener(Event.REMOVED_FROM_STAGE, removeEventListeners);
  61. stage.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
  62. }
  63.  
  64. private function removeEventListeners(e:Event):void {
  65. removeEventListener(Event.REMOVED_FROM_STAGE, removeEventListeners);
  66. stage.removeEventListener(MouseEvent.MOUSE_UP, onStopDrag);
  67. }
  68.  
  69. private function onStartDrag(e:MouseEvent):void {
  70. startDrag(false);
  71. }
  72.  
  73. private function onStopDrag(e:MouseEvent):void {
  74. stopDrag();
  75. }
  76.  
  77.  
  78. private function onClose(e:MouseEvent):void {
  79.  
  80. variables.newReview = reviewTxt.text;
  81. varLoader.load(varSend);
  82.  
  83. visible = false;
  84. dispatchEvent(new Event("closed"));
  85. }
  86.  
  87. }
  88.  
  89. }

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.

carmonkeycasino

  • Newbie
  • *
  • Posts: 12
Re: Changing the settings box and inputting information
« Reply #5 on: April 27, 2009, 09:55:56 pm »
Hey Florian,

Thanks for your reply, it doesn't seem to be working. Thanks for trying it though. I was wondering would my table have anything to do with it. Here's a look at my table, do i need to mention reviewID or bookID_fk in the ActionScript by any chance?


Thanks

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Changing the settings box and inputting information
« Reply #6 on: April 28, 2009, 08:17:16 pm »
Sorry, I've no actual experience regarding php interaction. Have you tried using GET instead, and tested in by just calling it in the browser? (just to make sure the php part works)
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.