Bonjour,
Je souhaiterais créer une calculatrice en as3 (avec des fonctions de bases additioner, multiplier, soustraire, diviser), je trouve des exemples tout fait, mais pas du tout de code...
Merci pour votre aide ou vos conseils.

<table>
<tbody>
<tr>
<td align="left">
<form name="calculator">
<table border="2" cellpadding="0" cellspacing="0" width="160" bgcolor="#DDDDDD" rules="none">
<tbody>
<tr>
<td align="center"><input size="18" name="result" onfocus="refresh()" type="text"></td>
<td rowspan="2">
<table border="0" cellpadding="0" cellspacing="0" width="160" align="center">
<tbody align="center">
<tr>
<td><input value="log" onclick="func('log')" type="button" style="width: 35pt;"></td>
<td><input value="sin" onclick="func('sin')" type="button" style="width: 35pt;"></td>
<td><input value="asin" onclick="func('asin')" type="button" style="width: 35pt;"></td>
</tr>
<tr>
<td><input value="10^" onclick="func('alog')" type="button" style="width: 35pt;"></td>
<td><input value="cos" onclick="func('cos')" type="button" style="width: 35pt;"></td>
<td><input value="acos" onclick="func('acos')" type="button" style="width: 35pt;"></td>
</tr>
<td><input value="ln" onclick="func('ln')" type="button" style="width: 35pt;"></td>
<td><input value="tan" onclick="func('tan')" type="button" style="width: 35pt;"></td>
<td><input value="atan" onclick="func('atan')" type="button" style="width: 35pt;"></td>
</tr>
<tr>
<td><input value="e^" onclick="func('exp')" type="button" style="width: 35pt;"></td>
<td><input value="1/x" onclick="func('1/x')" type="button" style="width: 35pt;"></td>
<td><input value="x!" onclick="func('n!')" type="button" style="width: 35pt;"></td>
</tr>
<tr>
<td><input value="^" onclick="operator('pow')" type="button" style="width: 35pt;"></td>
<td><input value="x²" onclick="func('sqr')" type="button" style="width: 35pt;"></td>
<td><input value="√" onclick="func('sqrt')" type="button" style="width: 35pt;"></td>
</tr>
<tr>
<td><input value="eff" onclick="bksp()" type="button" style="width: 35pt;"></td>
<td><input value="C" onclick="clearDisp()" type="button" style="width: 35pt;"></td>
<td><input value="AC" onclick="clearAll()" type="button" style="width: 35pt;"></td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="160" align="center">
<tbody align="center">
<tr>
<td colspan="2"><input value=" ( " onclick="openp()" type="button"> </td>
<td colspan="2"> <input value=" ) " onclick="closep()" type="button"></td>
</tr>
<tr>
<td><input value=" 7 " onclick="digit(7)" type="button" style="width: 24pt;"></td>
<td><input value=" 8 " onclick="digit(8)" type="button" style="width: 24pt;"></td>
<td><input value=" 9 " onclick="digit(9)" type="button" style="width: 24pt;"></td>
<td><input value=" / " onclick="operator('/')" type="button" style="width: 24pt;"></td>
</tr>
<tr>
<td><input value=" 4 " onclick="digit(4)" type="button" style="width: 24pt;"></td>
<td><input value=" 5 " onclick="digit(5)" type="button" style="width: 24pt;"></td>
<td><input value=" 6 " onclick="digit(6)" type="button" style="width: 24pt;"></td>
<td><input value=" × " onclick="operator('*')" type="button" style="width: 24pt;"></td>
</tr>
<tr>
<td><input value=" 1 " onclick="digit(1)" type="button" style="width: 24pt;"></td>
<td><input value=" 2 " onclick="digit(2)" type="button" style="width: 24pt;"></td>
<td><input value=" 3 " onclick="digit(3)" type="button" style="width: 24pt;"></td>
<td><input value=" - " onclick="operator('-')" type="button" style="width: 24pt;"></td>
</tr>
<tr>
<td><input value=" 0 " onclick="digit(0)" type="button" style="width: 24pt;"></td>
<td><input value=" . " onclick="period()" type="button" style="width: 24pt;"></td>
<td><input value=" ± " onclick="sign()" type="button" style="width: 24pt;"></td>
<td><input value=" + " onclick="operator('+')" type="button" style="width: 24pt;"></td>
</tr>
<tr>
<td><input value=" π " onclick="func('pi')" type="button" style="width: 24pt;"></td>
<td><input value="EE" onclick="exp()" type="button" style="width: 24pt;"></td>
<td colspan="2"><input value="=" onclick="equals()" type="button" style="width: 54pt;"></td>
</tr>
</tbody>
</table>
</td>
</tr>
* #! /usr/bin/env python
* #-*- coding: utf-8 -*-
* import decimal, re, operator
*
* parse_entree = re.compile(r'''(?x) # autorise les commentaires et les espaces
* ([-+]?[.]?\d+\.?\d*) # nombre avec partie fractionnaire éventuelle, signe + ou - éventuel
* \s* # espaces éventuels
* ([-+/*]) # opérateur
* \s* # espaces éventuels
* ([-+]?[.]?\d+\.?\d*) # nombre avec partie fractionnaire éventuelle, signe + ou - éventuel
* $''') # fin de chaîne
*
* oper = { '+': operator.add, '-': operator.sub,
* '*': operator.mul, '/': operator.truediv,
* }
*
* def calc(entree):
* total = decimal.Decimal('0')
* calcul = entree.strip()
* try:
* num_text1, op, num_text2 = parse_entree.match(calcul).groups()
* except AttributeError:
* print 'Entrée incorrecte : %r' % calcul
* print 'Entrez un nombre, un opérateur et un nombre.'
* raise AttributeError
* try:
* total = oper[op](decimal.Decimal(num_text1), decimal.Decimal(num_text2))
* except ZeroDivisionError:
* raise ZeroDivisionError
* return total
*
* if __name__ == '__main__':
* instruction = raw_input('Entrez un nombre, un opérateur et un nombre.\n')
* print calc(instruction)���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
Retourner vers Vos questions en Programmation / Création de site
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités