Professional Web Applications Themes

list component working with dynamic text field - Macromedia Flash Actionscript

Hey guys, I'm building a list component for my shopping cart that adds and deletes items in the box. I know how to script adding the labels, but my problem is relating it the total price dynamic field. So when I use the list_lb.addItemAt(0,Chewing Gum,5.00), would the data parameter be the price of the item? If so, how do I get the info to add correctly to the totalprice dynamic text field? Something like totalprice_txt.text = totalprice_txt.text + = list_lb.value Then if I choose the removeItemAt (list_lb.selectedIndex), how would I subtract the price from the total amount? Thanks for your ...

  1. #1

    Default list component working with dynamic text field

    Hey guys,

    I'm building a list component for my shopping cart that adds and deletes items in the box. I know how to script adding the labels, but my problem is relating it the total price dynamic field.

    So when I use the list_lb.addItemAt(0,Chewing Gum,5.00), would the data parameter be the price of the item? If so, how do I get the info to add correctly to the totalprice dynamic text field? Something like

    totalprice_txt.text = totalprice_txt.text + = list_lb.value

    Then if I choose the removeItemAt (list_lb.selectedIndex), how would I subtract the price from the total amount?

    Thanks for your help,

    Hoz


    hoz webforumsuser@macromedia.com Guest

  2. #2

    Default Re: list component working with dynamic text field

    First of all, answering your first question, yes the data parameter could be the price.
    Don't forget to use the quotation marks in the addItem function like this list_lb.addItemAt(0,"Chewing Gum",5.00), instead of this list_lb.addItemAt(0,Chewing Gum,5.00).

    Finally here is a script the you can use to calculate the total price.

    var totalprice = 0;
    for(var i=0; i < list_lb.getLength(); i++)
    totalprice += list_lb.getItemAt(i).data;

    totalprice_txt.text = totalprice;


    juankpro webforumsuser@macromedia.com Guest

  3. #3

    Default Re: list component working with dynamic text field

    Thanks so much!

    This is a great solution and makes sense. Another great post from this forum! Now I can build my two functions and then include this to run everytime within that function.

    Best!

    Hoz


    hoz webforumsuser@macromedia.com Guest

Similar Threads

  1. load external text to dynamic text field in levels
    By GaiHo in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: February 10th, 01:29 AM
  2. How to center text in dynamic HTML text field ???
    By AmnISaid webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: January 20th, 03:01 PM
  3. changing text color of list component
    By cade in forum Macromedia Flash Actionscript
    Replies: 0
    Last Post: January 16th, 03:21 PM
  4. Dynamic text in smooth scrolling text field - help
    By ROKKSTAR in forum Adobe Flash, Flex & Director
    Replies: 1
    Last Post: August 5th, 06:18 PM
  5. Dynamic List based on form field data
    By Brian S. Kiesel in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 14th, 05:02 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139