spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column37


JavaScript and Frames, Part II (7)

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Removing and Covering A Card

In this page we explain the remaining functions of the scripts, revealNow(), coverNow(), and removeCards(). They all involve a simple assignment of the src property of any frame's first (and single) image. Here is the listing for the revealNow() function:

function revealNow() {
top.frames[tobeRevealedCol].frames[tobeRevealedRow].document.images[0].src
     = pictures[assignAr[tobeRevealedLocation]];
}

As we explained earlier in this column, assignAr[tobeRevealedLocation] is the index into the pictures array of GIF file names. The frame is located by the its row and column positions, tobeRevealedRow, and tobeRevealedColumn, respectively.

The coverNow() function covers the two cards in a similar fashion:

function coverNow() {
  top.frames[tobeRevealedCol].frames[tobeRevealedRow].document.images[0].src
      = cover;
  top.frames[revealedCol].frames[revealedRow].document.images[0].src = cover;
  nowRevealed = false;
  blockClicking = false;
  if (nowPlaying == "left") nowPlaying = "right"
  else nowPlaying = "left";
}

The coverNow() function takes care of other maintenance work. It sets the nowRevealing variable to false, it tuns off the blockClicking to let the players continue the game, and it switches between the right and left players.

Finally, the removeCards() function removes the two cards (in case of a match):

function removeCards() {
 top.frames[tobeRevealedCol].frames[tobeRevealedRow].document.images[0].src
     = blank;
 top.frames[revealedCol].frames[revealedRow].document.images[0].src
     = blank;
 nowRevealed = false;
 blockClicking = false;
}


http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Created: April 5, 1999
Revised: April 5, 1999

URL: http://www.webreference.com/js/column37/remove.html