Skip to main content
Inspiring
February 16, 2024
Answered

How do I translate putting a number in a field that was written in Director's Lingo script?

  • February 16, 2024
  • 2 replies
  • 1291 views

I'm converting a project that I built many years ago in Macromedia Director into Animate HTML5. One of the scenes contains a humorous stock market that rapidly rotates the cost of the stock between graphic numbers 28, 29, 30, and 32 (no 31 for some reason - I can't remember why). There are 3 buttons: 1 share, 10 shares and 1,000 shares. When you click one of the buttons the amount that is currently displayed is used to calculate the total. And the current total is displayed in a number of shares field and a dollar field. 

 

First of all can you display a number on the stage in a white box (field) named "total" in Animate without it having to be a graphic?

 

Second question, is how do I re-write this code for HtML5?

 

on Price
  
  if the mouseCast = the number of member "Price28" then
    
    put field "Stock28" into newNumber
    set the floatPrecision to 2
    put field "Total" into oldNumber
    put value (newNumber) + value (oldNumber) + .001 into field "Total"
    
    if the mouseCast = the number of member "Price29" then
      
      put field "Stock29" into newNumber
      set the floatPrecision to 2
      put field "Total" into oldNumber
      put value (newNumber) + value (oldNumber) + .001 into field "Total"
      
      if the mouseCast = the number of member "Price30" then
        
        put field "Stock30" into newNumber
        set the floatPrecision to 2
        put field "Total" into oldNumber
        put value (newNumber) + value (oldNumber) + .001 into field "Total"
        
        if the mouseCast = the number of member "Price32" then
          
          put field "Stock32" into newNumber
          set the floatPrecision to 2
          put field "Total" into oldNumber
          put value (newNumber) + value (oldNumber) + .001 into field "Total"
        end if
      end if
    end if
  end if
end

 

This topic has been closed for replies.
Correct answer Charles_I
function priceF(){
_this.price = _this.price_A[_this.index];
if(_this.price == .3){
_this.currentPrice_tf.text=".30";
}else{
_this.currentPrice_tf.text = _this.price;
}
_this.index = (_this.index+1)%_this.price_A.length;
}

That's brilliant, thanks.  I made one minor change, I changed ".30" to "0.30" because all of the other numbers have 0 before the number of cents.

2 replies

Vladin M. Mitov
Inspiring
February 16, 2024

I am familiar with Director Lingo, albeit with not such an ancient version 🙂
Honestly, I find it difficult to understand the logic of this code. If I understood correctly, mouseCast returns the number of the cast member clicked. In that case, it seems like:

If we click on the field "Price28", then
    If we click on the field "Price29", then
        If we click on the field "Price30", then
            If we click on the field "Price32", then

So, the conditions are nested within each other.
Could you please explain in more detail the intention of the code or, if possible, send me the .dir file for better understanding?


- Vlad: UX and graphic design, Flash user since 1998Member of Flanimate Power Tools team - extensions for character animation
Charles_IAuthor
Inspiring
February 19, 2024

The graphic numbers just keep rotating - ie looping and swapping between each one while you're on the frame. MouseCast was just their fancy name for the name of an object. I realise looking closer at the code that it's only the second half of the process. So I'm going to translate and write out what should happen.

 

In seudocode it should do this:

 

Start listener

depending on which of the three buttons is pressed, 1, 10 or 1,000

put the number pressed into the integer "newNumber"

put the corresponding price of the object when it was pressed into "currentPrice" (ie .29)

put the number currently in "numberOfShares" into the integer "currentNumber"

put (currentNumber) + (newNumber) into "numberOfShares" and write it to the object "Shares"

 

put the number in "currentNumber" times "currentPrice" into the float (2 decimal points) "newPrice"

- because the prices are in cents, ie if the button is pressed at 29 cents it's ".29"

put (currentPrice) + (newPrice) in "newTotal" and write it to the object "Total"

delete the number in "newNumber"

delete the number in "newPrice"

 

When you goto the next frame (ie press "Step Here When Done") remove listener

 

I think I got that right.

 

These two pieces of codes run at the same time, so if a button is pressed both the Price and the Total update. I am uloading screenshots of pushing each button in sequence on the frame to help visualise this.

 

   

 

kglad
Community Expert
Community Expert
February 20, 2024

your screenshots (ss) don't make sense. 

 

if you purchase 1 share at .32, the first ss is ok.

if you then purchase 10 shares at .28, you have 11 shares and paid .32+2.80 = 3.12 which has current value 3.08

 

ie, the left textfield shows the total number of shares but the right textfield does not show the total paid nor the current value of the purchases.  what is it supposed to show?

kglad
Community Expert
Community Expert
February 16, 2024

i don't know lingo.

 

what triggers the cost to rotate?