updateAfterEvent

ok, i made a form and i want to count how many characters you can type so i got this far…

[AS]
mlength = message.length;
charsleft = 466-mlength+" characters left";
[/AS]

that works except when i made the movie 2 frames and looped it back the form wont work

so i tried

[AS]
on (keyPress) {
updateAfterEvent();
}
[/AS]

but im not quite sure how to use the updateAfterEvent, i tried a few different was like putting it on a movie clip and put the dyanmic text box to show the characters left on it but still nothing?

any help how to use it, or another way to refresh the dynamic text box without having more than 1 frame looped?

Hmm, I was covering something similiar just a minute ago…

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=32837

updateAfterEvent() is used after a codeblock so that Flash will update the new values outside of the framerate speed.

Hi,

That can be done usig the keyDown eventhandler. You don’t need to use the function updateAfterEvent(); for this. The function updateAfterEvent(); is only used to kind of refresh the Flash player after an event has happened.

First convert your form into a movie clip if your form is not yet a movie clip. Also note that this works on an INPUT textfield. Then place this script: (I assume that you are using Flash 5)


onClipEvent (keyDown) {
mlength = message.length;
charsleft = 466-mlength+" characters left";
trace(charsleft);
}

if you are using Flash MX use this code and place it on a frame in the same timeline as your textfield:


charCount = new Object();
charCount.onChanged = function(){
//here the textfield should have an instance name
//(not a variable name) of message.
charsleft = 466-message.length+" characters left";
trace(charsleft);
}
message.addListener(charCount);

Goodluck! :thumb:

comicgeek, you don’t need to use an listener for onChanged in a textfield :wink:

ok, can you do it without putting it into a movie clip,
like

[AS]
message.onChanged = function() {
mlength = message.length;
charsleft = 466-mlength+" characters left";
}
[/AS]

but i need to update outside of the frame rate because the movie is stopped on frame 1 then when i click submit it goes to frame 2 and thats it…

with onChanged framerate doesn’t matter, it will update the information when the textbox is changed. That is what the onChanged() handler is for. It basically says…

If them message textbox value is changed run these actions to update the information.

so then
[AS]
message.onChanged = function() {
mlength = message.length;
charsleft = 466-mlength+" characters left";
}
[/AS]

should work?

Should

cool, thanks for the help…

on an unrelated note, im just wondering if you can see the picture in my signature?

No I cannot…

Tip: Change the extension of your image on your server to .txt instead of .jpg. Then when you link to it use…

http://www.geoc**ities.com/mentoflav/footer.txt

It is a little geocities cheat trick… but for the record, this DOES break the hotlinking rules you agree to when you sign up, so this is not a method I would support, but it does work if you want to do it.

really?
ok cool, thanks again…