# Calculator in Storyline

Jan 10, 2013

So I've been building a calculator in Storyline that allows the learned to input a value and press submit to see how much they spend on each item per week. Once all Submit buttons are clicked, a new layer appears that divided the yearly total by 2 so the learner can see how much they could save.

However, while i have almost everything working, I need a little bit of advice on the division at the end. Anyone have any comments?

I have attached the file to this post.

## 20 Replies

Hi Michelle,

I like what you've done here. I've played with a for a bit, and am seeing that it seems to work some clicking sequences and not in others.To try to tease it out, I put a FINAL reference in a text box on the Final layer, to see if that was causing the problem. And I think it might be.

I need to run out now, and I haven't quite figured out WHERE it is, but:

When I play with the other items I yield similar results but with different sequences of clicking Submit buttons. Pretty much, it seems if I first hit the Submit button that comes AFTER an item, that item's "full" reference shows as 0.

So, I I only enter a quantity in one of the boxes and:

So for iTunes, if I hit Submit 2, 3, 4, 1, Full = 0.

For Coffee if I hit Submit 3, 4, 1, 2, Full=0

For Lunch if I hit Submit 4, 1, 2, 3, then Full = 0

Wish I had another few minutes. Curious now!

IT seems a slightly strange way to do it using slide level triggers for your calculations, there is something strange going on that i cannot see, your total is not adding up correctly and I really cannot see why. Sorry the problem is not the divide you total is off before the divide

Rebecca -

Perhaps, as Phil pointed out, the route would be better if I didn't have slide level triggers and instead had all things happen on one base layer. Perhaps that is what is causing the addition to be skewed.

If I were to hypothetically place all triggers on the base layer, would the amount of triggers and variable on one base layer affect the overall outcome?

I have a fear that certain things are cancelling out.

It is doing the math correctly when you enter a number in the top row of boxes and press submit and the correct answer appears in the second row of boxes. (See screen shot). I just don't know why the addition after those populate is incorrect.

correct+calculations+from+flash+course.pngI would put most of the action triggers on the buttons and the calculate triggers elsewhere.

I have to be really honest this felt so strange to me I started rebuilding the whole thing and then ran out of time.

The initial calculations are correct, if you remove the divide trigger the total is one box short (I think the last one you press) but I dont know why

But that is where the problem is. To debug this i would need to delete the triggers and start again just because this isnt how I would build it and it is making my head hurt

this is the first calculator i've built is Storyline so I don't really know the best practices.

Any tips for the future?

Hi Michelle

First there is no right or wrong way and looking at it, I am sure it should work your way. It is just not the way I would do it.

I would add all of the logic on the submit buttons, including the show layer trigger. I would exactly the same as you add the calcuations for the total I would add to the layer as timeline start triggers.

It all works but there is something strange that I feel I am missing somewhere and cannot get it (this is frustrating me).

Your way probably uses a few less triggers, I think

If it helps, the calculations I was using are as follows:

iTunes is approximately 0.99/purchase and so i multiplied this by the number entered in the first row.

Lunch was 8.99 and thus that got multiplied by what was entered in the data entry.

Coffee was approximately 2.95 and was multiplied by the number entered.

Gifts was 25 and multiplied by the data entry.

Therefore, all the math to get the second row correct was good, so it has to be something happening during that or after.

(hurts my head to!)

I will have a nother look, just one thing I have noted you do not need a trigger to set an object to visited that is automatic

ha I have like PTSD from triggers. I had a rough patch where the visited state wouldn't work without a trigger on images. So now I add it to be safe.

I think this is working.

I rebuilt it onto the buttons.

I think the problem was using the visited state to show the layer, because this happened before your calculations, trigger order is important so the layer was showing before a calculation took place

calculator_michelle_v3.storythe calculation then happened after the layer showed but at this point it was too late and the total calculation had already happened

Phil,

you're a genius. This works perfect. I didn't realize that order mattered as much as it does. You taught me two things in one day. Thanks!

Nice solution, Phil

Thanks David, thought I had failed, thanks for dropping by

Wow, Phil! I was out on errands and couldn't wait to get back and see what happened with this (geeky, eh? ). Awesome!

I couldn't let this one go, I tried but Michelle was persistent, I also had this nagging voice in my head saying "why can't you do it"

i am happy now

I know what you mean. Tx for not letting it go. I learned a lot from it thanks to you and Michelle.

Michelle, you did things with variable calculations that I hadn't thought of before. And Phil, well, as you saw from my post, I could see that something wasn't firing correctly and it was very "specific" in sequence, but I would never have determined what it was.

I also recreated it, for the sake of practice and because I had some ideas about what I would need to see as a Learner - this is me, not everyone - that would make the math more concrete for me. But, I did it with only 2 items for the sake of time. In fact, I don't really HAVE the time to do this now! But I was so intrigued and I so very much liked what Michelle had started.

I''m attaching here, just for the sake of sharing. I think it all works. I tried it in different sequences: just the item on the left, just the one on the right, left first, right first...

Thanks again to both of you! Signing off now.

calculator_michelle_v3_pm_2brfc.storyVery cool! I haven't worked much with calculations and displaying variables, and this taught me a lot.

One note viewing it for the first time (design thing), I really thought it was a bug that the submit buttons disappeared. I was wanting to change my number and couldn't. Having it disappear really seemed abrupt. Anyway you decide to design it, great job!

I appreciate everyone's input.

We had the Submit button disappear as a request, but i do agrtee as a best practice not to so the learner can play around with different options.

Thanks community!

Hey Storyliners,

We have noticed a lack of calculators out there.

A few of the examples out there don't calculate the decimal point correctly once calculated. If you want to create a calculator that has decimal places or +/-, before you do any calculations, you have to turn the number into a whole number. Multiply by -1 if the number is less than 0, and you have to keep track of your decimal place, multiply accordingly (if one decimal place, multiply by 10, two, multiply by 100), then divide by that same number and multiply by -1 again. It is mostly about keeping track.

This version should do the job. We have put this in our freebies at eLearning Locker where it will stay for about a week. It is normally part of the paid subscription, so please download it and use it as you like!

http://elearninglocker.com/portfolio-items/storyline-template-calculator/

## This discussion is closed. You can start a new discussion or contact Articulate Support.