Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,100 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,674 people online right now. Registration is fast and FREE... Join Now!




actionscript Question about a code that I'm doing.

 
Reply to this topicStart new topic

actionscript Question about a code that I'm doing., trying to finish a code but don't know how or what I need to put.

javalearnerman
20 Nov, 2007 - 11:40 AM
Post #1

New D.I.C Head
*

Joined: 4 Nov, 2007
Posts: 7


My Contributions
Hi, everybody, I'm new in these forums, I have been visiting this forum for a while but finally I have registered!

I am learning actionscripting and I'm having a problem with the last part of my project:

can somebody please tell me how I can make this code make my cards change only once, like I only click on the cards once and not change anymore after you click on all five once: Thanyou, here is my code so far:


function randomI(N){
//return numbers 0 up to N - 1
return Math.floor( (N )* Math.random());
}
var cards:String= "joker#ace#deuce#three#four#five#six#seven#eight#n ine#ten#jack#queen#king"
var cardArrayName:Array = new Array();
var cardArray:Array = new Array();// put Card object movieclips
cardArrayName = cards.split("#");
newSpace =32;
newSpaceY=6;

for(i=0;i<5;i++){
newLevel= _root.getNextHighestDepth();
cardArray[i] = _root.attachMovie("Card","cardObject"+newLevel,new Level);
var colorObject:Color=new Color(cardArray[i].bg);
colorObject.setRGB(0xff0000);
pickIndex=randomI(cardArrayName.length);
cardArray[i].cardName = cardArrayName.splice(pickIndex,1);
cardArray[i]._y =newSpaceY;
cardArray[i]._x = newSpace;
newSpace += 72+32;
cardArray[i].onPress = function() {

this.startDrag(false);

}
cardArray[i].onRelease= cardArray[i].onReleaseOutside = function() {

this.stopDrag();
}
if(i==4){
newSpace=32;
newSpaceY+=6+125;
}
if(i==9){
newSpace=32;
newSpaceY+=6+125;
}

}// end of loop

var click:Boolean = true;
cardArray[0].onPress = function(){
if ( click == false) {
click = true;}
else{

click = false;
}
trace(click);
}

cardArray[0].onPress = function(){
trace(cardArray);
pickIndex=randomI(cardArrayName.length);
cardArray[0].cardName = cardArrayName.splice(pickIndex,1);
}


cardArray[1].onPress = function(){
trace(cardArray);
pickIndex=randomI(cardArrayName.length);
cardArray[1].cardName = cardArrayName.splice(pickIndex,1);

}


cardArray[2].onPress = function(){
trace(cardArray);
pickIndex=randomI(cardArrayName.length);
cardArray[2].cardName = cardArrayName.splice(pickIndex,1);

}
cardArray[3].onPress = function(){
trace(cardArray);
pickIndex=randomI(cardArrayName.length);
cardArray[3].cardName = cardArrayName.splice(pickIndex,1);

}
cardArray[4].onPress = function(){
trace(cardArray);
pickIndex=randomI(cardArrayName.length);
cardArray[4].cardName = cardArrayName.splice(pickIndex,1);

}






This post has been edited by javalearnerman: 20 Nov, 2007 - 11:50 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:54PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month