-
AS2 automatic update fields - help
Hi everybody
I need a little help for making my movie-application perfect. I have made this app:
www.uddannelsesfonde.dk/beregner
don't spend time trying to read it because it's in danish Just so you can see how it works.
I need it to change the final amount (last box) if I choose another one from the scroll down bar. (right now the final amount does not update when first option is changed.
Its at simple array form which multiply with the second box and give me a anwser.
The code:
//This is used for the scroll down bar. It get's the info from a array.
on(change){
_root.message=_root.manufacturers.selectedItem.dat a;
_root.text=_root.manufacturers.selectedItem.text;
}
//This is used for the second box where the calculations take place.
on(change){ with(_parent){
resultat.text = Number (message_txt.text) * Number
(antal.text);
value = Math.round ((resultat.text)) + ",00 kr.";}
Any ideas? Need more info, then just say it thx!
-
Flash/Flex Developer
You should create a separate calculation function. It will take the information from the first two boxes and display the results in the third box. The onChange events for the dropdown list and the text fields should call this new function. Whenever there is a change, the make is recomputed and display in the result field. For example:
PHP Code:
(Dropdown) on(change){ _root.message=_root.manufacturers.selectedItem.data; _root.text=_root.manufacturers.selectedItem.text; recomputeResult(); }
(TextField) on(change){ with(_parent){ recomputeResult(); }
function recomputeResult(){ resultat.text = Number (message_txt.text) * Number(antal.text); resultfield.text = Math.round ((resultat.text)) + ",00 kr."; }
Last edited by samac1068; 08-21-2009 at 11:13 AM.
Reason: Giving an Example
Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.
-
Originally Posted by samac1068
You should create a separate calculation function. It will take the information from the first two boxes and display the results in the third box. The onChange events for the dropdown list and the text fields should call this new function. Whenever there is a change, the make is recomputed and display in the result field. For example:
PHP Code:
(Dropdown) on(change){
_root.message=_root.manufacturers.selectedItem.data;
_root.text=_root.manufacturers.selectedItem.text;
recomputeResult();
}
(TextField) on(change){ with(_parent){
recomputeResult();
}
function recomputeResult(){
resultat.text = Number (message_txt.text) * Number(antal.text);
resultfield.text = Math.round ((resultat.text)) + ",00 kr.";
}
Thx for the reply. I tried it now but can't get it to work. It will not make the intial calcualtions. Do I need more code than the recompute?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|