all groups > flash actionscript > february 2006 >
You're in the

flash actionscript

group:

Help referencing array


Help referencing array stinsong
2/8/2006 8:57:23 PM
flash actionscript:
Hi All

I'm a new actionscript user. I'm building a memory type game without the
random background cards.

I have created a couple of arrays one for the colour that I'll use to compare
cards with and one for the cards covering the background image.

My problem is referencing the array then setting the property of the card
clicked to be false to show the background image.
I have tried a couple of ways without luck.

Here is the code:

initGame();


// Global variables
function initGame() {
arrColour=new Array();
arrColour=,,,,,,,,,,,,,,,];
arrCards=new Array()
arrCards=,,,,,,,,,,,,,,,];
count = 0;
};


// Update all GUI elements
function updateGUI() {
count = 0;
};


// Check for match
function checkCard(cardGuess) {
count = count + 1;
cardNumber = cardGuess + 1;
cardFinal = "card" add cardNumber;
//trace (cardNumber);
//trace (cardFinal);

if (count == 1){
//cardFinal._visible = false;
arrCards._visible = false;
trace (arrCards);
}
else{
trace (arrColour);
updateGUI();
}
}

};


My calling code is on a button:
on (release) {
_root.checkCard(0) ;
}
Can anyone point me in the right direction?
Re: Help referencing array NSurveyor
2/8/2006 10:30:01 PM
You shouldn't use add, its deprecated and you can't even use it in Flash Player
8. Use + instead.

Also, the elements in your array are strings, not movieclips. If those are all
instance names of movieclip, you could use something like:

this]._visible = false;

Re: Help referencing array Jeckyl
2/9/2006 12:00:00 AM
[quoted text, click to view]

eh?

Re: Help referencing array Jeckyl
2/9/2006 12:00:00 AM
Still no better :)

[quoted text, click to view]

Re: Help referencing array ImagicDigital
2/9/2006 12:00:00 AM
This bracket issue is a serious flaw, for a forum where using brackets are
pretty necessary in descriptions. Much worse than the italics problem. LuigiL
suggested a very longhand work around, in another post.

Question for Newsgroup Users: can you see any of the square brackets, like the
ones in the array definitions?


Re: Help referencing array NSurveyor
2/9/2006 2:16:57 AM
That's really messed up. From macromedia.com, it is shown correctly, but on newsreaders it looks as you saw it.... some weird problem?! Anyways, here's what I suggested:

Re: Help referencing array stinsong
2/9/2006 2:26:18 PM
Thanks NSurveyor !

Re: Help referencing array LuigiL
2/9/2006 2:34:50 PM
[quoted text, click to view]
Well, I noticed that anything between the square brackets disappears for
Newsgroup Readers, so I just typed /squarebracket/ to clarify why the posted
code wasn't working. Something must have been changed because this never was an
issue, at least to my knowledge.
Re: Help referencing array ImagicDigital
2/9/2006 2:39:51 PM
Yes, thanks, LuigiL -- I meant it as a great thing that you noticed this. Just
was commenting that it would be rough to have to always do that /squarebracket/
thing. I hear you, something must have changed.
AddThis Social Bookmark Button