Skip navigation
Currently Being Moderated

Need some help with air (Beginner)

Jan 25, 2013 1:07 PM

Tags: #air #cs5 #as3 #action_script_3 #actionscript #flash_cs5

Don't know whether I'm posting this in the right place, but here it goes. I'm relatively new to Flash, and I'm currently working on an Air app in Flash CS5, which displays my site trough HTMLLoader. I'm having a small problem at the login page. What I want to be able to do is log in through the app, and have it remember my username and password, so that it will automatically log me in the next time I open the app. My login has one of those "remember me" check boxes, which is supposed to remember the login details. The problem is when I close the app down, it doesn't store my username and password, so when I reopen it, it just gives me a blank login screen again. How can I fix this?

 

Another problem is what happens if the internet cuts out. I've added code into the app, which displays an error message if there's no internet connection, but if the internet cuts out while using the app, it just displays the error message over the site, but everything is still active under it. Is there a way to "kill" HTMLLoader when there's no internet, then have it reopen when it reconnects?

 

 

Thanks in advance.

 
Replies
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Jan 25, 2013 1:41 PM   in reply to looserlf

    how are you storing the username/password?

     

    you can monitor the user's internet connection:  http://magicwithflex.wordpress.com/2009/11/23/monitor-the-availabilty- of-internet-connection-for-an-air-application/

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 25, 2013 1:44 PM   in reply to looserlf

    For the latter, disabling the content in HTMLLoader, use the mouseChildren standard boolean, e.g.:

     

    myHTMLLoader.mouseChildren = false;

     

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/display/DisplayObjectContainer.html#mouseChildren

     

    That should disable anything inside from responding to the mouse until you re-enable it.

     

    As for saving the username/password, that's up to you to handle in a few ways. You really should use ExternalInterface and communicate with JavaScript to set up a session. Storing username/password in plain text in a cookie is a bad idea (which is another way). You typically log a person in, generate a key server-side (sometimes called a session) and store that in a cookie. If you have a key when the app is loaded, it's sent to the server, validated, and then auto-logs in the user.

     

    Just adding a checkbox, calling it "Remember Me" does not add the programming involved to make it function.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 25, 2013 1:52 PM   in reply to looserlf

    If the checkbox is in HTML/outside flash then you'll have to deal with JavaScript and ExternalInterface to work with JavaScript to get the values.

     

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/external/ExternalInterface.html

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 26, 2013 7:02 AM   in reply to looserlf

    You're welcome!

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 27, 2013 6:39 AM   in reply to looserlf

    Try:

    htmlL.mouseEnabled = false;

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 27, 2013 4:44 PM   in reply to looserlf

    // must be defined outside the function or

    // when you create htmlL ONLY if monitor.available

    // can you actually use htmlL. Otherwise it doesn't exist.

    // So make it exist in both situations.

     

    var htmlL:HTMLLoader;

     

    function checkHTTP(e:StatusEvent)

    {

              if (monitor.available)

              {

                        htmlL= new HTMLLoader();

                        htmlL.width=1200;

                        htmlL.height=662;

                        htmlL.x=0;

                        htmlL.y=38;

                        addChild(htmlL);

                        htmlL.load(new URLRequest("http://www.google.com"));

              }

              else

              {

                        if (htmlL)

                        {

                                  htmlL.mouseChildren = false;

                                  htmlL.mouseEnabled = false;

                        }

              }

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 29, 2013 4:11 PM   in reply to looserlf

    Kglad linked a tutorial in post #1 for this already.

     

    Here's the URLMonitor on livedocs, a class to monitor internet connectivity and fire events based on it:

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/air /net/URLMonitor.html

     

    HTTP monitoring example (because you can monitor more than just HTTP):

    http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b8f6 c0-7ffe.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7cbf

     

    The examples are pretty much cut and paste. Pay attention to the events and do whatever you wish based on what it reports.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 31, 2013 11:57 AM   in reply to looserlf

    You're welcome, please mark any helpful/correct responses. Good luck!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points