Mailing List
Home
Forum Home
Flash Pro
Subjects
Subject: RE: Firework Effect
Web Service Results
Flash Interface with 10mb xml file
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash MX 2004 Sucks
Reading and displaying RSS feeds in Flash MX
Flash and QuickTime VR
Textfield prototype question
XML to Object help
Order of events per frame
MX2004 Dataset itemClassName
memory management removeMovieClip /
Event Dispatcher between classes
Help: MX 2004 How to script a print button to print the entire sli
ScrollPane component doesn 't auto update
setInterval bug identified and fixed
setInterval bug identified and fixed
Listener Object 's best practice
 
Listener+gotoAndPlay

Listener+gotoAndPlay

2004-03-10       - By Jim Cheng

 Back
Reply:     1     2     3     4     5     6     7     8     9  

IsK wrote:

> It's a kids 'secret agent' game. I want it to listen for a sequence of
> letter/numbers whilst the rest of the game plays. On the stage I have a
> movie clip and on hearing them sequentially it should move from frame to
> frame, within its movie clip with the final frame launching the browser.

Hmm, it might be easier to do it all from a single listener in
Actionscript.  This keeps things organized in one place.

I'd do something like the following, and place it in frame 1. An
additional group of frames follow, the number being equal to the
total characters in the code word, e.g. eight additional frames
in this example for the eight letter "codeword":

<code>

/*
   Change secretListener.word and secretListener.url to
   suit your needs and put this code in frame 1 of the
   movie.
*/

// Define a new listener object
var secretListener = {};
secretListener.word = 'codeword';
secretListener.url = 'http://www.google.com/';
secretListener.ptr = 1;

// Define a handler for onKeyDown
secretListener.onKeyDown = function() {
    // See if they entered the next letter...
    if (Key.getAscii() == this.word.charCodeAt(this.ptr)) {
   
        // Go to the next frame if it's correct
        gotoAndStop(this.ptr++);
   
        // If the entire code is entered, go to the URL
        if (this.ptr == this.word.length) {
            getURL(this.url);
        }
    }
}

// Add the listener
Key.addListener(secretListener);

</code>

Regards,
Jim

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Supported by Fig Leaf Software
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Lower Prices for Certified Training! Check out new lower prices for
Certified Macromedia Training from Fig Leaf Software. Expand your
skill set with courses in ColdFusion, Flash, Rich Internet
Applications and .NET in the new year.  Fig Leaf Software provides
the highest caliber instruction at our training centers in Washington  
D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at
your location.

Get the details at http://training.figleaf.com/
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected)
For additional commands, e-mail: flashnewbie-help@(protected)