A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Two questions for programing a touch screen computer

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    12

    Two questions for programing a touch screen computer

    Hello,
    I am trying to program a touch screen computer to display educational information for a small musuem I work for. I have taken a short course in flash 8, but I am having problems with some things that I'm sure can be done, but arn't done often. So, I am with out a doubt still a newbie.

    I have it mostly figured out and working, but there are two things that I can't get to work.

    a) What are the actionscript commands for getting rid of the mouse cursor? Does this go in the first frame?

    b) How do I make the program returne to the homepage (frame 1) after a certain amount of time. If some one is using the computer, but loses interest without returning to the home screen, I would like the program to automatically do it after a minute and a half.

    Thanks in advance for your help.

    Kyle

  2. #2
    [Horse Thief] gotoAndCrash's Avatar
    Join Date
    May 2007
    Location
    NW, USA
    Posts
    576
    a) Mouse.hide();

    b) research the getTimer() function - you can use it to count. You can use a setInterval that will check the current time of getTimer() versus the time you specify (0:1:30). Keep in mind that Flash works primarily in milliseconds so for 1 second flash counts to 1000. 90 seconds = 90,000 milliseconds. Here's a rough list of things to do :

    getTimer() begins counting when the Flash file loads & doesn't restart itself, so you'll want to set a variable (let's call it "myTime") that will get the current time of getTimer.

    set up an onMouseMove function that tells the myTime variable to update itself with the current getTimer time any time the mouse moves, & use a setInterval (or onEnterFrame) to check to see if the current getTimer time is greater than 90,000 milliseconds more than the myTimer variable. Then have a function that returns the movie to frame 1 when that condition is met.

    Even though the mouse is hidden it will still update to wherever a person taps the screen, so even though it's hidden, it's still there & moving around.
    1 Infinite Loop, Cupertino is a portal of Hell.

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Posts
    12
    Me again.

    I finaly sat down to try to make the timer that would return to the first frame after 90 seconds of inactivity. I haven't had any luck and I need to ask for help. Your tips to use getTimer () pointed me in the right direction, I just don't know how to make it happen. I tried a bunch of different things, but known have worked so far.

    Please advise.

    Kyle

  4. #4
    Junior Member
    Join Date
    Apr 2008
    Posts
    12
    bump

  5. #5
    [Horse Thief] gotoAndCrash's Avatar
    Join Date
    May 2007
    Location
    NW, USA
    Posts
    576
    sorry so late, been on the road.

    Here, try this -

    Make a function that returns the playhead to the first frame :
    Code:
    function takeMeToYourFirstFrame ():Void {
    	clearInterval(myInterval);
    	_root.gotoAndStop(1);
    }
    Then we'll write a "setInterval" to call that function after 90 seconds, but we'll hook it up to a Mouse event that resets it every time the mouse is moved :
    Code:
    var intervalListener:Object = new Object();
    Mouse.addListener(intervalListener);
    intervalListener.onMouseMove = function () {
    	clearInterval(myInterval);
    	myInterval = setInterval(takeMeToYourFirstFrame,90000);
    }
    Some explaining :
    1st code chunk -
    That "clearInterval(myInterval);" is a command to tell Flash to stop counting out our interval, if we didn't put that in there then after 90 seconds went by it would call the function, return to the first frame & begin counting again - then after 90 seconds it would call the function, & return to the first frame again, over & over - so that line tells Flash to "knock it off, now"

    2nd code chunk -
    First we create a generic Object to tie our Mouse to, then we add it as a listener to the mouse - it listens for when the mouse moves (onMouseMove) - when the mouse moves it clears our interval (as described above), then it resets the interval & when the mouse is no longer moving it doesn't clear the interval so it continues to run, then after 90 seconds of inactivity it fires the first code chunk (as described above). the "90000" is in milliseconds as setIntervals work in milliseconds - 90000 of them is 90 seconds.

    You may need to tweak this a bit for your particular needs, so let me know if you have any special requests

    I promise I will get back to you, but I'm on the road so it may take a day or 2.

  6. #6
    Junior Member
    Join Date
    Apr 2008
    Posts
    12
    Thanks for the reply. I didn't see it until now. I will fool around with it and ask some follow up questions in a few days. Thanks again.

    One quick question: The script for this timer, should it go in its own layer that spans the entier movie?

    Kyle

  7. #7
    [Horse Thief] gotoAndCrash's Avatar
    Join Date
    May 2007
    Location
    NW, USA
    Posts
    576
    Quote Originally Posted by cdnkyle
    One quick question: The script for this timer, should it go in its own layer that spans the entire movie?
    Well, it's ideal to have ALL of your code in a layer called "Script" or something, but yes, this script should go in a blank keyframe where other scripts are (as opposed to ON a Movie Clip element). If your timeline is 40 frames long & you want this effect to be called when the timeline is on frame 40, then you may want to put it there. Ideally though, there should be one frame in a movie - several layers, but only one frame long.
    1 Infinite Loop, Cupertino is a portal of Hell.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center