Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple Mouse Click Counter help

Guest
Oct 03, 2010 Oct 03, 2010

Goal to make a mouse click counter. (a simple clicker/tally button that keeps track of the number of clicks a user makes).

  1. Progress -
    1. Button completed
    2. variable passed to text field completed.
    3. script passing correct variable to text field incomplete.
  2. Problem -

          1. Counter Variable stays at 1 and does not increase by 1 when the button is clicked.

Link to .fla

script

var myVar=0;

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

var fl_TF:TextField;

var fl_TextToDisplay:String = myVar;

function fl_ClickToPosition(event:MouseEvent):void

{

fl_TF = new TextField();

fl_TF.autoSize = TextFieldAutoSize.LEFT;

fl_TF.background = true;

fl_TF.border = true;

fl_TF.x = 100;

fl_TF.y = 100;

fl_TF.text = fl_TextToDisplay;

addChild(fl_TF);

myVar++;

}

any and all help greatly appreciated.

Thank You

TOPICS
ActionScript
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 03, 2010 Oct 03, 2010

Try:

var myVar=0;

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

var fl_TF:TextField;
fl_TF = new TextField();
fl_TF.autoSize = TextFieldAutoSize.LEFT;
fl_TF.background = true;
fl_TF.border = true;
fl_TF.x = 100;
fl_TF.y = 100;
fl_TF.text = String(myVar);
addChild(fl_TF);

function fl_ClickToPosition(event:MouseEvent):void
{
     myVar++;
     fl_TF.text = String(myVar);
}

Translate
Community Expert ,
Oct 03, 2010 Oct 03, 2010

use:


var myVar:uint=0;

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

var fl_TF:TextField = new TextField();

fl_TF.autoSize = TextFieldAutoSize.LEFT;

fl_TF.background = true;

fl_TF.border = true;

fl_TF.x = 100;

fl_TF.y = 100;

fl_TF.text = myVar.toString();

addChild(fl_TF);

function fl_ClickToPosition(event:MouseEvent):void

{

myVar++;

fl_TF.text=myVar.toString();

}


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 03, 2010 Oct 03, 2010

Try:

var myVar=0;

button_1.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);

var fl_TF:TextField;
fl_TF = new TextField();
fl_TF.autoSize = TextFieldAutoSize.LEFT;
fl_TF.background = true;
fl_TF.border = true;
fl_TF.x = 100;
fl_TF.y = 100;
fl_TF.text = String(myVar);
addChild(fl_TF);

function fl_ClickToPosition(event:MouseEvent):void
{
     myVar++;
     fl_TF.text = String(myVar);
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2010 Oct 03, 2010

?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 03, 2010 Oct 03, 2010

??  We posted pretty much simultaneously if you're wondering why I'm almost mirroring your response. I did check before submitting and you weren't there beforee, but were there after.  It's not the first time that's happened either way between us.  I could say that great minds think alike, but that'd be too much of a stretch for me.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2010 Oct 03, 2010

i know about the near-simultaneous posting stuff (as you know).

but your response was to me, not the op.  that's what i was questioning but it must some kind of forum artifact.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 03, 2010 Oct 03, 2010

Hah... I didn't even notice that... Maybe I have to count to three or something just for measure... or maybe my eyes were playing tricks on me when I checked.  I've been on breaks between reseedings of a lawn all day, so maybe it's time for a nap instead of foruming.... just one more row to go though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 03, 2010 Oct 03, 2010

(that doesn't sound like a lot of fun.  and weren't you supposed to reseed one month ago?)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 03, 2010 Oct 03, 2010

( I have been seeding, weeding, and reseeding all summer... an extended heat spell arrived just in time to destroy my first attempt... then weeds grew in nice and thick during the heat spell where I hadn't seeded at all ... it's a longer story, but I'll stop here... )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 03, 2010 Oct 03, 2010
LATEST

It works.....

Thank you for all your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines