What you want is a basic stack.  It looks like this:

on push info
   global stack

   if (voidP(stack)) then
     stack =[]
   end if

   add(stack, info)
end



on pop
   global stack

   if (voidP(stack)) then
     stack =[]
   end if

   -- If stack is empty, you have nothing to return.  You can return VOID, 
or #empty,
   -- or whatever works for you.  You could give an alert or just have a 
silent return.
   numItems =count(stack)
   if (numItems =0) then
     alert "Pops exceed pushes!"    -- Or make a put statement, or 
something to let you know there's no more back
     return(VOID)
   end if

   -- Otherwise there's something to return
   info =stack[numItems]            -- Retrieve the last entry
   deleteAt(stack, numItems)        -- then kill it from the stack

   return(info)                     -- Send it back
end


so, to use it, you push whatever information you want to store.  This could 
be a frame number, or a label, or whatever.  Then, when they click the back 
button, you pop off the info, and go to whatever it is.

So, as an example, when they click to go somewhere, you have a script 
attached to the button that first, before you relocate, remembers where you 
are.  Let's say for the sake of this demonstration that it's the frame 
number (easy enough).  So it's:

on mouseUp
   -- This is attached to the button that takes you somewhere

   push(the frame)

   -- Now relocate, etc...
end



The back button, however, will retrieve the information, and go to it.

on mouseUp
   -- This is specific to the back button.

   lastLoc =pop()
   if (voidP(lastLoc)) then
     alert "Can't go back any further!"
     return
   end if

   -- Otherwise, it's good
   go to frame lastLoc
end


I haven't tested this specific code out - just did it in my head - but it 
should be fine.

- Tab


At 01:22 AM 5/6/01 +0000, Chris McCoy wrote:
>Hi everybody.
>I have this  problem...
>I intend to implement a Back Button for my multimedia cd rom.
>It's made with Director 8 and i want to add some smart features in it.
>I searched the web for available tips and tricks and i came up with this code:
>
>
>property spriteNum
>
>global gBackList, gBack
>
>on prepareFrame me
>if gBack = void then set gBack = false
>if gBackList = void then set gBackList = []
>if spriteNum < 1 then
>   --framescript
>   set totalBacks = count(gBackList)
>   if gBack = false then
>     --did not come from back button
>     if totalBacks > 0 then
>       set lastEntry = getAt(gBackList, totalBacks)
>     else
>       set lastEntry = ["", 0]
>     end if
>     if lastEntry <> [the moviePath & the movieName, the frame] then
>       --not thecurrent frame, add tothe list
>       add gBackList, [the moviePath & the movieName, the frame]
>     end if
>   else
>     --came from the back button.  Remove last entry
>     deleteAt(gBackList, totalBacks)
>     set gBack = false
>   end if
>end if
>end
>
>on mouseUp me
>if gBack = void then set gBack = false
>if gBackList = void then set gBackList = []
>if spriteNum >= 1 then
>   --is a button
>   if count(gBackList) > 1 then
>     --there are back locations
>     set gBack = true
>     set destination = getAt(gBackList, count(gBackList) - 1)
>     if the moviePath & the movieName = getAt(destination, 1) then
>       --same movie
>       go to frame getAt(destination, 2)
>     else
>       --different movie
>       go to frame getAt(destination, 2) of movie getAt(destination, 1)
>     end if
>   end if
>end if
>end
>
>on getBehaviorDescription me
>return "Drop this behavior on the framescript of each frame you want ot be
>included in the back button history.  Also drop it on the back button and
>the script does the rest."
>end
>
>
>The author of this code doesn't give much explanation of how to use it ...
>
>It is quite obvious that this script works only if in your movie you have 
>only buttons and the script...
>Does anyone has the script for all cases....
>I am asking much here i know...!!!
>But if this someone has the solution to my problem
>it would be very appreciated if he/she shares it with me...
>Any recomentations?
>Thanks for your time....
>
>
>
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
>email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to