I have Adobe CS4 Pro with Flash v10. I'm trying to create a simple, basic calculator that adds 2 numbers. I followed the tutorial at http://layersmagazine.com/flash-design-calculator.html. At first, I was unable to assign variables to any objects, but got that cleared up by selecting ActionScript 2.0 (was set to 3.0). At this point, the calculator accepts the two numbers, but when I select the "add" button with the associated code as shown in the tutorial, nothing happens. Does anyone have a suggestion as to what I might be doing wrong? Thanks.
Thanks for your reply. I am truly a novice at Flash, so I'm not sure how to check my listeners. I did use the Trace() function, and the only output I'm getting is "NaN" (NotANumber). I don't understand this since I've defined both of my input variables as number - Number(firstnumber) and Number(secondnumber). I tried defining the output as a number - Number(total) - but then got a compiler error.
This is all the code there is:
on(release) {
total = Number(firstnumber)+Number(secondnumber);
}
There's really not an error--I just don't get any output. I've created two 'Input Text' boxes, and on the properties tab for each I have defined the "Variable:" field as either 'Number(firstnumber)' or 'Number(secondnumber)'. I've also created a 'Dynamic Text' box and defined the "Variable:" field as 'Number(total)'.
Note: the example I was following did not specify to include the 'Number()' function in the "Variable:" fields. However, when I don't, and I run 'Test Movie', the 3 boxes are automatically filled with "_level0.firstnumber", "_level0.secondnumber" and "_level0.total". When I type 2 numbers in to the 2 'Input Text' boxes, and then select my button that has the above code associated with it, I get "NaN" in the output ('Dynamic Text') box.
Thanks again for your help!
This works fine for text. I am having the same difficulty creating a dynamic score box.
For example,
onClipEvent (enterFrame) {
if(this.hitTest(MC2)) {
score++;
}
}
Message was edited by: RSchenck302@Hotmail.com
start a new thread on the as1/as2 forum: http://forums.adobe.com/thread/1141486?tstart=0
North America
Europe, Middle East and Africa
Asia Pacific