6 Replies Latest reply on Nov 28, 2006 7:57 AM by rich.leach

    Button that calls the frame again...

    rich.leach Level 1
      Hi All-

      Probably another simple question for those unencumbered by the web paradigm....

      I have a simple one frame Flash movie (using the Yahoo maps control, very cool). The map control has default values assigned to it by way of variables, so when it loads it displays the map for the defaulted address.

      In the same frame I have a textInput and a button, that I want to be able to have the user enter a new address, click the button and simply have the same frame called again, with code at the top of the frame to simply look at the textInput field to see if a new address has been submitted. If so, display the new map.

      Sounds easy enough, but I can't seem to get the button to call the same frame again, a refresh if you will. Am I missing the obvious (again)??? Does this flow sound correct? I thought a self-submitting form would be the easiest and most elegant solution here.....

      Thanks for your help in advance,

      Rich

        • 1. Re: Button that calls the frame again...
          kglad Adobe Community Professional & MVP
          1. attach a stop() to your first frame and add a 2nd frame.
          2. have your refresh button execute _root.play().
          • 2. Re: Button that calls the frame again...
            rich.leach Level 1
            ... so the 2nd frame would remain empty, and "_root.play()" refers to the name of my play button?

            Thanks so much for your help-

            Rich

            • 3. Re: Button that calls the frame again...
              kglad Adobe Community Professional & MVP
              no, _root.play() is the code your play button would execute. for example:

              • 4. Re: Button that calls the frame again...
                rich.leach Level 1
                ok, thanks again for your help -

                I added the 2nd frame,

                however if I add your suggested button code
                yourButton.onPress=function(){
                _root.play();
                }
                to my root timeline it doesn't do anything and when i add it directly to my button I get an error saying the statement must appear within an onEvent handler....

                Any other suggestions?

                Thanks again,

                Rich

                //first frame - check for submitted address
                if (address_txt.length != 0) {
                _global.mapAddress = address_txt.text;
                } else {
                _global.mapAddress = "Denver, CO 80401";
                }

                //set default zoom level
                _global.mapZoom = "12";

                //set address textInput text
                address_txt.text = _global.mapAddress;

                //call Yahoo's map control
                import com.yahoo.maps.tools.PanTool;
                import com.yahoo.maps.markers.CustomPOIMarker;
                import com.yahoo.maps.widgets.NavigatorWidget;
                import com.yahoo.maps.widgets.SatelliteControlWidget;
                myMap.addEventListener(com.yahoo.maps.api.flash.YahooMap.EVENT_INITIALIZE, onInitMap);
                function onInitMap(eventData) {
                var navWidget = new NavigatorWidget("closed");
                myMap.addWidget(navWidget);
                myMap.addWidget(new SatelliteControlWidget());
                var panTool = new PanTool();
                myMap.addTool(panTool, true);
                myMap.setCenterByAddressAndZoom(_global.mapAddress, _global.mapZoom, 2000);
                var myMarker = {index:'Results>>', title:'Your Address', description: _global.mapAddress, markerColor:0x990099, strokeColor:0xFFFF00};
                myMap.addMarkerByAddress(CustomPOIMarker, _global.mapAddress, myMarker);
                }

                stop();

                //I tried this code directly to the button also, which is when I get the error, else it doesn't do anything
                mapIt_btn.onRelease=function(){
                _root.play();
                }

                • 5. Re: Button that calls the frame again...
                  kglad Adobe Community Professional & MVP
                  the code i gave should be attached to your timeline and should use the instance name of your button.
                  • 6. Re: Button that calls the frame again...
                    rich.leach Level 1
                    ... boy I hate to sound ignorant, but isn't that what I did? The code I listed below is on a layer I called "Actions" and the button's instance is in a different layer called "formlayer" called "mapIt_btn", which I thought I referenced correctly, am I missing something obvious again?

                    Thanks again,

                    Rich