spacer

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

home / experts / javascript / column37


JavaScript and Frames, Part II (7)

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


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, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


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

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