15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

dynsrc<br />

Chapter 6 ✦ Image, Area, and Map Objects (Chapter 22)<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓<br />

Example<br />

To swap between still and video sources, simply empty the opposite property.<br />

Listing 22-3 shows a simplified example that swaps between one fixed image and<br />

one video image. This listing exhibits most of the bugs associated with changing<br />

between static image and video sources described in the text.<br />

Listing 22-3: Changing Between Still and Motion Images<br />

<br />

<br />

IMG dynsrc Property<br />

<br />

var trainImg = new Image(160,120)<br />

trainImg.src = “amtrak.jpg”<br />

trainImg.dynsrc = “amtrak.mpg”<br />

function setLoop() {<br />

var selector = document.forms[0].looper<br />

document.myIMG.loop = selector.options[selector.selectedIndex].value<br />

}<br />

function setImage(type) {<br />

if (type == “jpg”) {<br />

document.myIMG.dynsrc = “”<br />

document.myIMG.src = trainImg.src<br />

} else {<br />

document.myIMG.src = “”<br />

document.myIMG.start = “fileopen”<br />

setLoop()<br />

document.myIMG.dynsrc = trainImg.dynsrc<br />

}<br />

}<br />

<br />

<br />

<br />

IMG dynsrc Property<br />

<br />

<br />

Choose image type:<br />

Still<br />

Continued<br />

321<br />

IMG.dynsrc

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!