howdy alhurayas,
not completely sure what you are having trouble with...the sort fxn appears to work;
if the problem is that you want to display the entire list of terms (the whole array), then where you have this in the AS of the btns:
Code:
//_root.framtext.dynamicTxt = (myLetters25[i]);
and
_root.framtext.dynamicTxt = (myLetters24[i]);
try this:
Code:
_root.framtext.dynamicTxt = (myLetters25);
and
_root.framtext.dynamicTxt = (myLetters24);
Maybe you could describe what you want to happen at each btn click...
Also, do you intend to have blank spaces after the array elements 'yes' and 'zero'?
the idea is read game for kids where in text display a word ( arrayA words starting with the letter a ......arrayz words starting with the letter z)
then the array have been all words call ( read ) i wnat the button to be disable preventing the same words to start again
when i used your code all the words of the array displayed on the text i juist want word by word until the end of the array .
ps there another problem which i will tell you about but for now letts solve this one thankkkkkss for your replay
Okay, now i understand. Here are some things to consider:
First: You have used a single variable (i) as a counter for both buttons. If you click nutton2 twice and then click nutton1, you will get the third element of the Z array - even though you have only clicked nutton1 once. Rather, you want to have each button increment its own variable. You could use "i" with the particular letter (such as ia, ib, ic,... iz). It is best to declare such variables on the main timeline (in the actions layer, frame 1) so they are accessible by all scripts throughout the movie. Then you will just need refer to each variable using the path
Code:
_root.myLetters25[i]
Second: There is another way to 'pull' the words from the array that might work better for you: You can use the Array.shift method to remove the first element of an array. (Look at this page for more about Array.shift) In this way, you would not need to track 26 variables. You could just check the array after each shift, and disable the button if the array is empty
Third: Will you eventually have 26 buttons? Consider using a loop to create/name/place each of the 26 buttons. That is how the buttons are created for this demo
Also: Where you have _root.nutton2.enabled = false; you can just use this.enabled = false;
thank you alot i tried it this was but did not word
code:
on (press) {
//checks to see if i isn't higher than the length of the array
if (ia<myLetters25.length) {
_root.framtext.dynamicTxt = (myLetters25[ia]);
trace(myLetters25[ia]);
//increments i
ia++;
//else, if i is the same as the length of the array, perform an action:
} else {
_root.nutton2.enabled = false;
_root.nutton2._alpha = 20;
trace("end 2");
}
}
but did not work another thing is the use of this.enabled = false; did not work now iam using flash mx2004
it worked in mx
thank again you are a great help
hello fellas,
i was going to sit back and let azwaldo do all the dirty work on this one, but was too intrigued by the concept to let it go.
also it seems we are all in significantly different time zones so i thought i could help speed things up.
alhurayas, i like your game concept and commend you on your flash and english skills. keep at it.
it seems the biggest problem with your original file was that (as azwaldo noted) you were using the same counter variable "i" for determining the position in multiple arrays.
the first thing i did was initiate counter variables for each myLetters array:
code:
// c is for counter, the number is for which myLetters array it is for.
c23 = 0;
c24 = 0;
c25 = 0;
once i added this, both buttons went through the arrays as planned and disabled the buttons if their were no items left in the array.
Next, I figured that since you are going to have 26 buttons, it would be a real shame if you wanted to change your on(press) behavior and have to edit all 26 buttons.
being that each array has a number in its name and that same number is now being used as a counter variable for that array, i figured each button could have a number (counter) that tells a function which array to access and which array counter variable to update.
code:
//this function is on the main timeline
//each button has its own counter# that it sends to this function on(press)
button_press = function (counter) {
//set a variable that holds the name of the array to be referenced
arrayname = "myLetters"+counter;
//set a variable that holds the name of the counting variable we will increment
countervar = "c"+counter;
trace(newline+"***")
trace("arrayname= "+arrayname+newline+"countervar= "+countervar+newline+countervar+"= "+_root[countervar]);
//if our countervar is less than the arrays length than do things
if (_root[countervar]<_root[arrayname].length) {
_root.framtext.dynamicTxt = _root[arrayname][_root[countervar]];
trace(_root[arrayname][_root[countervar]]);
_root[countervar]++;
} else {
//i also gave your buttons appropriate names like button23, button24, button25
_root["button"+counter].enabled = false;
_root["button"+counter]._alpha = 20;
trace("end 2");
}
};
//each button now has a script like this:
on (press) {
button_press(24);
}
also as azwaldo noted, you could use a loop to place all the buttons on the stage, at the same time you could initiate your counter variables and button actions. if you need help let us know.
mx2004 attached if you need mx, let me know (i found that saving as mx puts my super long functions on one line which is annoying).
also I put in a few traces that will better illustrate what is going on.
this is an interesting project. many techniques that have not been mentioned yet can be used - several concepts that will probably be new to you, but stay with it and you will probably learn a lot. and, now that meglomor has joined the thread this is really a graduate-level flash lesson...
azwaldo here you are but there is a bug in it plays the last element of an array twice why
how to play
all of the player in the game use the keyboard while the teacher have control over the game using the mouse
play1 use the letter a ( it first )
play2 use the letter 5
play3 use the letter h
play4 use the letter n
thank you simple ha
azwaldo here you are but there is a bug in it plays the last element of an array twice why
how to play
all of the player in the game use the keyboard while the teacher have control over the game using the mouse
play1 use the letter a ( it first )
play2 use the letter 5
play3 use the letter h
play4 use the letter n
thank you simple ha
tried to attach it but too large 328k
there is the swf
Wow! Nice job in the design, al. And the interaction is very clean, too. I am impressed.
The bug might be in how you are looping or handling the counter variable... for example, there is a difference between using this:
thank for all your help i willtry to fix it , about
play1 use the letter a ( it first )
play2 use the letter 5
play3 use the letter h
play4 use the letter n
spelling hit first 4 players who it the keyboard first get the chance to answer ( read) the letter are a for player1, n for player2 5 for player3 and h for player4
thankssssssss
"...spelling hit first 4 players who it the keyboard first..."
Still not understanding this completely - the "spelling hit" (this is done by different players? do four people sit at the monitor with a finger on a different key?)
if you get stuck with the counter/frameNumber bit, maybe you can just post the code for the fxn you are working on (if the file is too big to attach)
same mistake
i made the same mistake again (it for hit)
try to play it choose a letter the word will be display try to player 4 players useing the keyboard
( hit first ,his letter first)
play1 use the letter a
play2 use the letter 5
play3 use the letter h
play4 use the letter n hope i made myself clear
back to the code i tried
_root[countervar]++;
it this way
_root[++countervar]; one word each time
and i tried it this way
_root++[countervar];
err
there is the complete code thank you
_root[countervar]++; should work, if not, the problem may be elsewhere in your code...do you use the trace command to check (debug) your scripts? you can check out this tute for more on errors and debugging
have opened the text file you attached, but it is difficult to study AS code in that format* - but, i may have found one problem: you have used the same word ("counter") for a function name that you use elsewhere for a variable...try renaming the fxn
it is also helpful to use descriptive verbs for function names,
like function countClicks()
*I am also wondering why the file is so large at this point: are you using a lot of images? large sound files? maybe you could create a dummy copy of the fla ("Save as" with different name) and remove large sound files and images, then you could attach the fla here
thank you will i try again and agian to fix it
but still i think i need you help
this game is main your work and other flash pro ( from actionscrpit.org ) who helped me with button listern code
give me a day ... for trying .
thaaaaaaaaanks