14 Replies Latest reply on Sep 6, 2007 10:19 AM by kglad


    Dave.Hollings Level 1
      Good afternoon,

      I am currently working on a form and have managed to get Alerts to popup if certain fields are not completed (basic validation). With each Alert box there is an OK button. I have been trying to figure out (unsuccessfully, hence why I am here in the forum) how to get the users text cursor (the focus) into the text input component that is in question, once the user has clicked the OK button. For example: the user does not type in anything for the fullname_txt input component. Flash throws up an Alert box informing the user that the Fullname needed to be completed before sending the form. The user clicks the OK button and I want the text cursor (the focus) inside that input component so the user can click the OK button and then automatically start typing instead of select the box themselves with their mouse or touch pad.

      I hope I have explained it correctly and look forward to the response(s).
        • 1. Re: Alerts
          kglad Adobe Community Professional & MVP
          use an onRelease (not onPress) for you ok button, then use selection.setFocus(yourInputComponent).
          • 2. Re: Alerts
            Dave.Hollings Level 1
            Many thanks for your help I will try and get that working based on your reply. I do have another question regarding Alerts:

            I have the following code which calls an Alert box and shows a specific message in the defined colour, and aligns the text to the center. The issue is that the the title is not displayed on the Alert, and I cannot understand why. Can you see any error in the code?

            • 3. Re: Alerts
              kglad Adobe Community Professional & MVP
              you've assigned a parameter for the alert component's title. try:

              • 4. Re: Alerts
                kglad Adobe Community Professional & MVP
                wait; i thought you didn't want an alert title. but after rereading your post it seems something else is at issue.

                if you want a title "Form Alert", there's no problem with your code though there is no icon linkage and therefore you dould have trouble with your last parameter.
                • 5. Re: Alerts
                  Dave.Hollings Level 1
                  I have once again tried again by putting in another null in the Alert script however the title is still not displaying. I have also tried out the myClilckHandler script however the focus is still not going to the component. Any ideas?
                  • 6. Re: Alerts
                    kglad Adobe Community Professional & MVP
                    you can't see the title when you use one (like "Form Alert")? if your text color the same as the alert's background title color?
                    • 7. Re: Alerts
                      Dave.Hollings Level 1
                      Correct I have the title in my Alert as "Form Alert", above this script I have set the styles I want for the Alert. See complete script below:

                      To make things a little clearer - I have a contact_mc at frame 30 and the code has been moved from within the mc to the main timeline, at frame 30.

                      I have on the _root timeline at frame 1 global styles, which set the font text, colour and halo for all components however I thought if I assigned specific styles to a particular component this would overwrite the global style. I had a though that the global styles were affecting the title issue so I changed the text colour however still same results - No title. I cannot tell if the title is not showing completely or if the text colour of the title is that of the same as the title background area of the Alert box.

                      At this point I am at a loss of what to try next - your thoughts, comments or suggestions would b greatly appreciate. Thank you for your time so far and I hope we can get this resolved.

                      • 8. Re: Alerts
                        kglad Adobe Community Professional & MVP
                        isolate the if-else branch that's executing when you fail to see a title. if they all fail, create a test copy of your current fla and start removing chunks of code until you get to the minimum code needed to reveal the issue.
                        • 9. Re: Alerts
                          Dave.Hollings Level 1
                          I was thinking of doing the same thing, so I decided to do a little test. New stage new fla. One button on the stage and the window component in my library. on the action script layer the following code:

                          Same problem the title is appearing but in white or grey so very hard to make out with the window component colour. The other problem I did not get any output when I clicked the OK button. I guess the myClickHandler is not working correctly. Any ideas??

                          • 10. Re: Alerts
                            kglad Adobe Community Professional & MVP
                            you have two problems in that code but neither explains an issue limited to the title of the alert component.

                            first, onRelease is not the same as OnRelease.
                            second, your function is defined after your Alert.show and is undefined when Alert.show executes.


                            • 11. Re: Alerts
                              Dave.Hollings Level 1
                              Cool - the code worked for the myClickHandler I had to mess around with it a little as I have a large if, else if statement. In the end I created another variable in each if and else if statment to hold the component name. At the end of the if, else if statements I put myClickHandler AS in with Selection.setFocus(_global.componentname); and it works fine now.

                              Still no luck with the title - haven't got a clue why this is not changing its colour considering I have set the colour to 0x990000 (red) in my _global.setStyle.Alert statment. I guess it must be one of those things, that will sort it's self out one day.

                              I would like to say at this point as I believe we have done all we can and should close this topic now - many thanks for your help it has been well received, you are an asset to this forum and a project saver for people like me - THANK YOU!
                              • 12. Re: Alerts
                                kglad Adobe Community Professional & MVP
                                you're welcome.

                                but oops. i didn't realize you were trying to assign titleStyleDeclaration for the alert component and that was the cause of the problem.

                                here's what you want:

                                • 13. Re: Alerts
                                  Dave.Hollings Level 1
                                  Well that works fine thanks again - but I found one more issue I am having - Sorry!

                                  I have an icon graphic now showing on my Alert on the left (looks great) however the text I want to show is only showing half of it the other half is missing is there any way to define the size of the Alert box before it is displayed?
                                  • 14. Re: Alerts
                                    kglad Adobe Community Professional & MVP
                                    no, but you can set its x-scaling using: