9 Replies Latest reply on Aug 3, 2011 9:20 AM by kglad

    Buttons trouble

    rohanlon

      I have a dreamweaver site. In it I have an swf file. The swf contains 908 buttons numbered b1 - b908. Users click a button of their choice, then they are taken out to paypal whereby they can make a donation. After the donation has been made I redirect them to a different swf file. The reason I do this is to insert code somewhere in the second swf so that I can disable the button that they originally clicked in the first swf file.

       

      Now, I have also used wild characters on the buttons so that I didn't have to type 908 lines of code. Therefore, whatever code I introduce into the second swf file will need to be able to recognise which button was clicked in the first swf file. (I hope this doesn't all sound like gibberish).

       

      With loads of help from kglad, I have got to this point, and I just require a simple piece of code to finish it off. I am stumped at this stage, I have tried everything but cannot get it to work.

       

      File names :

      The name of the first swf file which takes the user out to paypal is called "pitch.swf".

      The name of the second swf file which takes the user back to my main website is called "thankyou.swf"

       

      Many thanks in advance.

        • 1. Re: Buttons trouble
          kglad Adobe Community Professional & MVP

          hopefully, you created those button listeners/handlers using a for-loop.  if so, copy that for-loop code and paste here.

          • 2. Re: Buttons trouble
            rohanlon Level 1

            Here is the code from the first swf file, I had to take a screengrab of it for you as for some crazy reason I can't seem to be able to do a simple copy and paste of the actual code.

            code.jpg

            There are three different prices - €5, €10 and €50.

             

            Buttons b1 - b200 are the first piece of code, (these are the €5 buttons).

            Buttons b201 - b788 are the second piece of code, (these are the €10 buttons).

            Buttons b789 - b908 are the last piece of code, (these are the €50 buttons).

             

            The green coloured code is obviously the link to paypal for each block of buttons. I have a return from paypal to a new swf file. Currently the new swf file is only a thank you message with a return to main website button. I haven't added any code yet. It is in the new swf file that I want to include a disable option for whatever button was clicked in the first swf file.

             

            Below is a link to the actual site (not yet live) to give you an idea what it is I'm attempting to accomplish.

            http://www.pitchplot.com

             


            • 3. Re: Buttons trouble
              kglad Adobe Community Professional & MVP

              copy and paste your code, don't use a screenshot of code.

              • 4. Re: Buttons trouble
                rohanlon Level 1
                //5euro buttons 
                for(var i:int=1;i<=200;i++)
                { 
                this["b"+i].addEventListener(MouseEvent.CLICK,gotoPP5); 
                }
                 function gotoPP5(event:MouseEvent):void
                {           
                navigateToURL(new URLRequest
                
                ("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=72XEHB8ZX5VQY")) 
                }  
                
                
                //10euro buttons 
                
                for(var j:int=201;j<=788;j++) 
                {
                 this["b"+j].addEventListener(MouseEvent.CLICK,gotoPP10); 
                } 
                function gotoPP10(event:MouseEvent):void      
                { 
                navigateToURL(new URLRequest
                ("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y7LYK46W6A7AG")) 
                }  
                
                
                //50euro buttons 
                for(var k:int=789;k<=908;k++) 
                {
                 this["b"+k].addEventListener(MouseEvent.CLICK,gotoPP50); 
                }
                 function gotoPP50(event:MouseEvent):void 
                {           
                navigateToURL(new URLRequest
                ("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=29JXCAQ3FH5FU"))
                }
                
                • 5. Re: Buttons trouble
                  rohanlon Level 1

                  For some strange reason the forum won't allow a simple cut and paste of the

                  code as I have it in AS3. No idea why but anyhow I managed to paste it in

                  the format above which is very similar (except for text colours) to the code.

                  Many thanks.

                  • 6. Re: Buttons trouble
                    rohanlon Level 1

                    oops....double post by error.

                    • 7. Re: Buttons trouble
                      kglad Adobe Community Professional & MVP

                      (use ctrl-c to copy code and ctrl-v to paste code.  similar shortcuts are available to mac users.)

                       

                      you can disable clickedButton in your receiving localconnection method:

                       

                       

                       

                      var clickedButton:CorrectClass;

                       


                      //5euro buttons
                      for(var i:int=1;i<=200;i++) { this["b"+i].addEventListener(MouseEvent.CLICK,gotoPP5); } function gotoPP5(event:MouseEvent):void {  

                      clickedButton=event.currentTarget;
                              navigateToURL(new URLRequest ("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=72XEHB8ZX5VQY")) }  //10euro buttons for(var j:int=201;j<=788;j++) { this["b"+j].addEventListener(MouseEvent.CLICK,gotoPP10); } function gotoPP10(event:MouseEvent):void      {
                      clickedButton=event.currentTarget;
                      navigateToURL(new URLRequest ("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y7LYK46W6A7AG")) }  //50euro buttons for(var k:int=789;k<=908;k++) { this["b"+k].addEventListener(MouseEvent.CLICK,gotoPP50); } function gotoPP50(event:MouseEvent):void { 
                      clickedButton=event.currentTarget;
                               navigateToURL(new URLRequest ("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=29JXCAQ3FH5FU")) }
                      • 8. Re: Buttons trouble
                        rohanlon Level 1

                        Does the code you have inserted above now mean that I don't require the second swf file

                        and that everything will run fine in the first "pitch.swf" file......

                         

                        "you can disable clickedButton in your receiving localconnection method:"

                         

                        Can you explain in simple terms what the string above means. I'm not sure I understand it.

                        Thanks again.

                        R

                        • 9. Re: Buttons trouble
                          kglad Adobe Community Professional & MVP

                          your main (i think, pitch.swf) calls paypal.  after paypal records payment it calls another swf, eg thankyou.swf.  in thankyou.swf, you should have a sending localconnection that calls a function/method in the receiving localconnection in pitch.swf.  that function then disables clickedButton which is what you wanted.