I am trying to add in a shared object so that I can save and load the game from a local computer. I have followed a tutorial on Kirupa tutorials section but my expierence with this is limited. Can anyone help me out with this night mare of a problem.
I have added in the action script so you can get a better understanding of what i am trying to accomplish.
Thanks in advance for any help.
I am willing to pay to get this working as I have been trying for 3 or 4 months now.
Fergal
I have also added a link to the SWF so you can see how the game works. Click Here
The FLA is also available on request.
fscommand("fullscreen", true);
fscommand("allowscale", false);
fscommand("showmenu", false);
// setup our variables
var count = 0; // count variable
var xp = 125; // starting _x position (horizontal)
var yp = 160; // starting _y position (vertical)
var vs = 10; // vertical space between cards
var hs = 10; // horizontal space between cards
var rows = 6; // how many rows?
var cols = 9; // how many columns?
var mc = null; // refrence current movieclip
var deck = []; // list all the playable cards
// function used to shuffle the deck of cards
function shuffle() { return Math.floor(Math.random() * 2) }
// initiate our stage
function initStage() {
// list all available cards (linkage identifier)
var spades = ['2S','3S','4S','5S','6S','7S','8S','9S','10S','JS','QS','KS','AS'];
var clubs = ['2C','3C','4C','5C','6C','7C','8C','9C','10C','JC','QC','KC','AC'];
var hearts = ['2H','3H','4H','5H','6H','7H','8H','9H','10H','JH','QH','KH','AH'];
var diamonds = ['2D','3D','4D','5D','6D','7D','8D','9D','10D','JD','QD','KD','AD'];
var dummy = ['DMY'];
// list our deck of cards
deck = spades.concat(clubs, hearts, diamonds, dummy);
// add our winning card
deck.push('YW');
// shuffle the deck around
deck.sort(shuffle);
// attach cards from our library
for (var i = 0; i < rows; i++) {
for (var j = 0; j < cols; j++) {
// attach and resize the current cards
// but first check if its one of the winning cards
if (deck[count] == 'YW') {
// give it a unique number at the end of its instance name
mc = attachMovie(deck[count], deck[count] + count, count, {_xscale:40, _yscale:40});
// replace YW with its new name
deck[count] = deck[count] + count;
} else {
// keep the same name used in the array
mc = attachMovie(deck[count], deck[count], count, {_xscale:40, _yscale:40});
}
// create movieclip where we'll place a number to identify its order
mc.createEmptyMovieClip('txt_mc', mc.getNextHighestDepth());
// create a textfield inside that movieclip & refrence it with variable _txt
var _txt = mc.txt_mc.createTextField('txt', 0, -45, -30, 50, 50);
_txt.autoSize = true
_txt.text = count + 1;
// create a textformat for our textfield & refrence it with variable _fmt
var _fmt:TextFormat = new TextFormat();
_fmt.bold = true;
_fmt.align = 'center';
_fmt.font = 'Veranda';
_fmt.size = 100;
_fmt.color = 0xFF0000;
// apply the textformat to the textfield
_txt.setTextFormat(_fmt);
// position the cards
mc._x = xp + (mc._width + hs) * j;
mc._y = yp + (mc._height + vs) * i;
// give the cards a button handler
mc.onPress = function () {
this.enabled = false; // disable the card's button handler
this.gotoAndPlay(2); // play its timeline
this.txt_mc.txt.text = '';
switch (this._name) {
case 'JS':
case 'JH':
case 'JD':
case 'JC':
var showGood=true;
break;
}
if (showGood==true) {
attachMovie('try_againJ_mc', 'try_againJ_mc', 100000);
try_againJ_mc.try_again_btn.onRelease=function () {
removeMovieClip(this._parent);
}
return;
} else {
removeMovieClip(_root.congrats);
}
this.txt_mc.txt.text = '';
switch (this._name) {
case 'QS':
case 'QH':
case 'QD':
case 'QC':
var showGood=true;
break;
}
if (showGood==true) {
attachMovie('try_againQ_mc', 'try_againQ_mc', 100000);
try_againQ_mc.try_again_btn.onRelease=function () {
removeMovieClip(this._parent);
}
return;
} else {
removeMovieClip(_root.congrats);
}
this.txt_mc.txt.text = '';
switch (this._name) {
case 'KS':
case 'KH':
case 'KD':
case 'KC':
var showGood=true;
break;
}
if (showGood==true) {
attachMovie('try_againK_mc', 'try_againK_mc', 100000);
try_againK_mc.try_again_btn.onRelease=function () {
removeMovieClip(this._parent);
}
return;
} else {
removeMovieClip(_root.congrats);
}
this.txt_mc.txt.text = '';
switch (this._name) {
case 'AS':
case 'AH':
case 'AD':
case 'AC':
var showGood=true;
break;
}
if (showGood==true) {
attachMovie('try_againA_mc', 'try_againA_mc', 100000);
try_againA_mc.try_again_btn.onRelease=function () {
removeMovieClip(this._parent);
}
return;
} else {
removeMovieClip(_root.congrats);
}
this.txt_mc.txt.text = '';
switch (this._name) {
case 'DMY':
var showGood=true;
break;
}
if (showGood==true) {
attachMovie('try_againD_mc', 'try_againD_mc', 100000);
try_againD_mc.try_again_btn.onRelease=function () {
removeMovieClip(this._parent);
}
return;
} else {
removeMovieClip(_root.congrats);
}
checkCard(this._name); // call function & pass its name
}
// increase variable
count++;
}
}
}
function checkCard(card) {
// is it the winning cards?
if (card.slice(0,2) == 'YW') {
// disable all the cards
for (mc in this) { // search through every object on our timeline
if (typeof(this[mc]) == 'movieclip') { // if current object is a movieclip
this[mc].enabled = false; // disable its button hanlder
}
}
// create a delay
var si = setInterval(function() {
// when day is over clear the interval function
clearInterval(si);
// attach our congrats screen
_root.attachMovie('congrats', 'congrats', _root.getNextHighestDepth());
// add button handler to our play again movieclip
congrats.congrats_btn.onPress = function () {
// clear the board
for (mc in _root) { // search through every object on our timeline
if (typeof(_root[mc]) == 'movieclip') { // if current object is a movieclip
_root[mc].removeMovieClip(); // remove it from the stage
}
}
// shuffle the deck of cards again
deck.sort(shuffle);
// revert count variable
count = 0;
// initiate the stage again
initStage();
}
}, 500); // how long is the delay?
}
}
// start game
initStage();