-- -- Scripts to make a slideshow -- Ken Loge - http://diginoodles.com -- ------------ MOVIE SCRIPT - Initialize Image List and Counter global gImageList -- a list of the images to show global gCounter -- a counter to identify which image in the list to display on startMovie gImageList = ["Basalt Storm", "Crater Bumps", "Fractured StepRock", "Pine Valley", "Shore and Ocean", "Tower Shadow"] gCounter = 1 -- make sure gCounter shows image 2 next end ------------ ------------ FRAME SCRIPT - Hold Frame on exitFrame me _movie.go(_movie.frame) end ------------ ------------ FRAME SCRIPT - Change Cursor -- change the cursor for visual feedback on mouseEnter me cursor 280 -- switch to finger cursor end on mouseLeave me cursor -1 -- switch to normal arrow cursor end ------------ ------------ FRAME SCRIPT - Hold Frame on exitFrame me _movie.go(_movie.frame) end ------------ ------------ FRAME SCRIPT - Go to Previous Image global gImageList -- a list of the images to show global gCounter -- a counter to identify which image in the list to display on mouseUp me gCounter = gCounter - 1 if gCounter < 1 then gCounter = gImageList.count end if sprite(me.spriteNum).member = gImageList[gCounter] end ------------ ------------ FRAME SCRIPT - Go to Next Image global gImageList -- a list of the images to show global gCounter -- a counter to identify which image in the list to display on mouseUp me gCounter = gCounter + 1 if gCounter > gImageList.count then gCounter = 1 end if sprite(me.spriteNum).member = gImageList[gCounter] end ------------ ------------ FRAME SCRIPT - Control the Slideshow with Keys global gImageList -- a list of the images to show global gCounter -- a counter to identify which image in the list to display property pAutoPlayback -- use for auto playing images -- This script should be placed in the frame where you want to control -- image playback using keys on the keyboard. on beginSprite me pAutoPlayback = FALSE end -- show the previous image in the list on prevImage me gCounter = gCounter - 1 if gCounter < 1 then gCounter = gImageList.count end if sprite(1).member = gImageList[gCounter] end -- show the next image in the list on nextImage me gCounter = gCounter + 1 if gCounter > gImageList.count then gCounter = 1 end if sprite(1).member = gImageList[gCounter] end -- stay on this frame on exitFrame me _movie.go(_movie.frame) end -- -- Auto Play Images (toggle) -- 'howLong' is an argument for the number of milliseconds to -- wait before displaying the next image. -- on autoPlay howLong, me if pAutoPlayback = FALSE then -- initialize a timer object myTimer = timeOut().new("imagePlay", howLong, #nextImage, me) pAutoPlayback = TRUE else -- stop the timer object pAutoPlayback = FALSE timeOut("imagePlay").forget() end if end -- process keyboard key events to trigger handlers on keyUp me case (_key.keyCode) of 123: prevImage(me) -- left arrow 124: nextImage(me) -- right arrow 125: prevImage(me) -- down arrow 126: nextImage(me) -- up arrow 49: autoPlay(1000, me) -- spacebar end case end ------------ ------------ FRAME SCRIPT - Shuffle Slide Images global gImageList -- a list of the images to show on exitFrame me _movie.go(_movie.frame) end on mouseUp me -- call the shuffleImages handler shuffleImages(me) -- read from the global "master" dice list 6 times to retrieve the value of each die repeat with i = 2 to 7 sprite(i).member = gImageList[i-1] end repeat end -- The handler below works by randomly choosing an image from the global gImageList list, -- then copying it to a temporary "shuffle" list. It then deletes the image item that was -- chosen from the master list so it can't be chosen again. The last thing the handler does -- is copy the "shuffled" list back to the global image list, so it ends up having exactly -- the same number of elements it had before it was scrambled. -- Randomly Shuffle the Images on shuffleImages me shuffleList = [] -- do the following until the global "master" list is empty repeat while gImageList.count > 0 -- randomly pick an image based on how many elements are left in the list r = random(gImageList.count) -- add the image chosen to gImageList[] add shuffleList, gImageList[r] -- delete the image chosen from the global "master" list deleteAt gImageList, r end repeat -- copy the temporary shuffled image list to the global "master" list gImageList = shuffleList end ------------ ------------ SPRITE SCRIPT - Toggle Zoom Image property pLoc -- the location of the sprite begore the zoom property pZloc -- where in Z space the sprite came from property pRect -- the rectangle of the sprite before the zoom property pZoom -- the zoom state of the sprite image on beginSprite me pZoom = FALSE pInk = sprite(me.spriteNum).ink pLoc = sprite(me.spriteNum).loc pZloc = sprite(me.spriteNum).locZ pRect = sprite(me.spriteNum).rect end -- -- Attach this behavior to an image sprite to toggle the size -- of the image from its original size to full screen size. -- Ken Loge - http://diginoodles.com -- -- toggle the size and position of the image when the sprite is clicked on mouseUp me if pZoom = FALSE then -- get center point of the stagethe sprite(me.spriteNum).loc = point(getStageWidth(me) / 2, getStageHeight(me) / 2) sprite(me.spriteNum).locZ = 1000 -- make sure the image is in front of all others -- get ehe stage width and height for image size sprite(me.spriteNum).rect = rect(0,0,getStageWidth(me),getStageHeight(me)) pZoom = TRUE else pZoom = FALSE sprite(me.spriteNum).loc = pZoom sprite(me.spriteNum).locZ = pZloc sprite(me.spriteNum).rect = pRect end if end -- get the width of the stage on getStageWidth me return _movie.stage.rect[3] - _movie.stage.rect[1] end -- get the height of the stage on getStageHeight me return _movie.stage.rect[4] - _movie.stage.rect[2] end -- enlarge the sprite slightly on mouseEnter me sprite(me.spriteNum).rect = sprite(me.spriteNum).rect + rect(-4,-4,4,4) end -- restore the sprite to its normal size on mouseLeave me sprite(me.spriteNum).rect = pRect end ------------