Copy link to clipboard
Copied
Hi all,
I've got a movieclip named toolbar which is linked to Toolbar class (Tollbar.as).
In this movieclip, there is a dynamic text field named "argent".
I've got an this in my Puzzle.as :
public function blabla:void{
stageRef.dispatchEvent(new Event("checkingMoney"));
}
And in my Toolbar.as :
public class Toolbar extends MovieClip{
private var stageRef:Stage;
private var money:int;
public function Toolbar(stageRef:Stage){
this.stageRef = stageRef;
money = 9999;
argent.text = money.toString();
stageRef.addEventListener("checkingMoney", checkMoney, false, 0, true);
public function checkMoney(event):void{
trace("checking");
if (money < 0){
trace("dangerous");
}
}
I can't see where the problem is. The function checkMoney is called (as I see the trace "checking"), but the
if (money < 0){
trace("dangerous");
doesnt' work. Yet, the number is far below 0....
Do you know what could be the problem ?
Thank you very much.
i don't see a problem with anything in message 2, but there's nothing in message 2 related to the problem in message 1.
in particular, you are not changing the variable money.
possibly you want to do something like:
public function checkMoney(event):void{
trace("checking");
if (Number(argent.text) < 0){
trace("dangerous");
}
}
Copy link to clipboard
Copied
it's not less than zero from the code you showed.
use the trace function to confirm money is still 9999:
public function checkMoney(event):void{
trace("checking",money);
if (money < 0){
trace("dangerous");
}
}
Copy link to clipboard
Copied
You're right. The money is still 9999. Can you tell me what's wrong on my dropMoney function please ?
private function dropMoney(e:MouseEvent):void{
toolbar.argent.text = String( Number(toolbar.argent.text ) - 100 );
(note : "argent" is the dynamic text field in my movieclip "toolbar")
Copy link to clipboard
Copied
i don't see a problem with anything in message 2, but there's nothing in message 2 related to the problem in message 1.
in particular, you are not changing the variable money.
possibly you want to do something like:
public function checkMoney(event):void{
trace("checking");
if (Number(argent.text) < 0){
trace("dangerous");
}
}
Copy link to clipboard
Copied
Exactly ! THANK YOU
Copy link to clipboard
Copied
you're welcome.