About Kevin Fraser Expertise I have been programming since 1975. I will answer questions on Macromedia Director and its Lingo programming language. I have worked as a full time Lingo developer on several commercially released educational CD-ROM projects for a total of about three years at a major University software lab. cannot answer q`s about Macromedia Flash. I know Director, not Flash
Experience Graduate of the Vancouver Film School Multimedia program, member of the SFU Excite Lab at Simon Fraser University, Director and CTO, Tencrows.com Technologies Inc.
Expert: Kevin Fraser Date: 5/29/2001 Subject: Shopping Basket effect in Director 8
Question Hello there! I'm using director 8 on a NT 4 pc.
I'm trying to achieve a 'shopping basket' effect for a CD ROM. Effectively, there is a object on the screen made up of several parts. When certain parts are 'rollover'd' the part number is shown, I would then like to be able to click on this part number to add it to another piece of the movie (possibly a seperate movie), where they can be seen and costings can be equated, then parts can be deleted from the list if required.
Therefore, could you please inform me of any Lingo that will:
a) place text somewhere different
b) delete text from the 'somewhere'
c) calculate totals.
Hope that's not too cheeky, but as yet I'm not sure of the best way to approach it!
I look forward to your reply. Thanx.
Answer I'm not going to write you a complete solution, of course. I normally charge for that :)
However, here's something you can try that should definitely shed some light for you and show you the rich set of possibilities for handling your requirement using somre Lingo-based database handlers you can construct yourself. If you've never used property lists in Lingo before, it's also an excellent introduction to one of the most powerful, little-used, and little understood features of Director.
Make a new field type cast member and name it 'datatable'
Paste this text into it, or make a simple comma-delimited list using any other software:
-- sets up database table as a global property list
-- accessable from any handler
on initDB
global gBasket
set gBasket = [:]
set the floatprecision = 2
set dataTable = field "datatable"
delete dataTable.line[1] -- field header record
repeat while dataTable <> EMPTY
set rawRec = dataTable.line[1]
delete dataTable.line[1]
set partNmbr = string(rawRec.item[1])
set partName = string(rawRec.item[2])
set partPrice = float(rawRec.item[3])
set inbasket = FALSE
-- chows current total cost for selected items
on basketTotalCost
global gBasket
set invCount = gBasket.count
set totalCost = 0
repeat with thisItem = 1 to invCount
if gBasket.getaprop(gBasket.getpropat(thisItem)).inbasket = TRUE then
set thisCost = gBasket.getaprop(gBasket.getpropat(thisItem)).partPrice
set totalCost = totalCost + thisCost
end if
end repeat
return totalCost
end
Now, try this in your message window:
initdb
You should get this back, depending on what you put in the field.
This is a property list. If you've never seen one, study it until you understand it exactly. It's quite logical and simple. It's also what power, flexibility and speed looks like in Lingo. Also consider how easy it is to edit or update your database by just editing the field.
Try playing with queries to get the data out that you need:
-- to get a record by part number:
put gBasket.getaprop("6238")
-- [#partName: "Widget tightener", #partPrice: 18.23, #inbasket: 0]
-- to get the part name of a part by its number:
put gBasket.getaprop("6238").partName
-- "Widget tightener"
-- to get the part number of row three of your data table
put gBasket.getpropat(3)
-- "sh-276"
-- to put item 3 in the shopping basket:
set gBasket.getaprop(gBasket.getpropat(3)).inbasket = true
-- to check if item 3 is in the basket or not:
put gBasket.getaprop(gBasket.getpropat(3)).inbasket
1
-- 1=TRUE, 0=FALSE
-- to check if item 4 is in the basket or not:
put gBasket.getaprop(gBasket.getpropat(4)).inbasket
0
-- put item 4 in the basket:
gBasket.getaprop(gBasket.getpropat(4)).inbasket = true
-- show the running total:
put basketTotalCost()
-- 32.57
You'll want to look up 'property lists' in the Director Docs & help file.