List Info

Thread: "Void" function in Flash Lite 2.x




"Void" function in Flash Lite 2.x
country flaguser name
United States
2007-09-28 17:21:04

I am making one game and I have found already made this code:

/* -------------------- start coding -------------------- */
guessWord_txt._visible = false;
var welcomePart1:String = "Welcome to the hangman game! To, win you
must try to guess the name of ";
var welcomePart2:String = ". Press the play button below to start.";
var guessTopic:LoadVars = new LoadVars();
guessTopic.onLoad = function(success:Boolean) {
if (success) {
startScreen_mc.message_txt.text =
welcomePart1+this.myTopic+welcomePart2;
} else {
startScreen_mc.message_txt.text = "The data failed
to load. I am sorry!";
}
};
guessTopic.load("guessword.txt");

/* -------------------- setting the variables -------------------- */
var words:Array = new Array();
var alphabet:String = "abcdefghijklmnopqrstuvwxyz";
var chosenWord:String = new String();
var displayedText:String = new String();
var playAgain:Boolean = false;
/* -------------------- loading XML -------------------- */
var wordsLoader:XML = new XML();
wordsLoader.ignoreWhite = true;
wordsLoader.onLoad = function(success) {
if (success) {
parseWords();
} else {
guessWord_txt.text = "Sorry dude, the data just
didn't load.";;
}
};
wordsLoader.load("words.xml");
/* -------------------- parsing XML -------------------- */
function parseWords():Void {
if (wordsLoader.firstChild.nodeName == "gamedata") {
var rootNode:XMLNode = wordsLoader.firstChild;
for (i=0; i<rootNode.childNodes.length; i++) {
if (rootNode.childNodes[i].nodeName
== "word") {
var currentWord:String =
rootNode.childNodes[i].firstChild.nodeValue.toString();
words.push(currentWord);
}
}
}
}
/* -------------------- choosing a random word --------------------
*/
function randomize(playAgain):Void {
var randomNumber:Number = random(words.length);
chosenWord = words[randomNumber];
if (playAgain) {
guessWord_txt.text = "&quot;;
}
for (var i:Number = 0; i<chosenWord.length; i++) {
guessWord_txt.text = guessWord_txt.text+&quot;.";;
}
displayedText = _root.guessWord_txt.text;
}
/* -------------------- placing the letter buttons ------------------
-- */
function placeLetters():Void {
this.createEmptyMovieClip("allLetters_mc&quot;, 1);
allLetters_mc._y = 300;
allLetters_mc._x = 20;
for (var i:Number = 0; i<alphabet.length; i++) {
var newLetter:MovieClip = allLetters_mc.attachMovie
(&quot;letterButton", "letter"3;alphabet.charAt(i), i);
newLetter.letter_txt.text = alphabet.charAt(i);
if (i<8) {
newLetter._y = 0;
newLetter._x = i*40;
} else if (i>=8 && i<16) {
newLetter._y = 40;
newLetter._x = (i-8)*40;
} else if (i>=16) {
newLetter._y = 80;
newLetter._x = (i-16)*40;
}
/* -------------------- scripting the buttons to be clickable -------
------------- */
newLetter.onRelease = function() {
var matchFound:Boolean = false;
var clickedLetter:String = this._name.charAt
(this._name.length-1);
/* -------------------- checking to see if the hidden word contains
the clicked letter -------------------- */
for (var j:Number = 0; j<chosenWord.length;
j++) {
if (chosenWord.charAt(j) ==
clickedLetter) {
_root.guessWord_txt.text =
displayedText.substr(0, j)+clickedLetter&#43;displayedText.substr((j+;1));
matchFound = true;
this._visible = false;
}
displayedText =
_root.guessWord_txt.text;
}
/* ------ if the word was guessed, the endOfGame function is
invoked, with the parameter set as true ----- */
if (displayedText == chosenWord) {
endOfGame(true);
}
/* ------ if the clicked letter isn't found inside the hidden word,
the animation advances ----- */
if (matchFound == false) {
this._visible = false;
_root.hangman_mc.play();
/* ------ if the word wasn't guessed and the character was hanged,
the endOfGame function is invoked, with the parameter set as false --
--- */
if (hangman_mc._currentframe == 22) {
endOfGame(false);
}
}
};
}
}
/* -------------------- the endOfGame function --------------------
*/
function endOfGame(success:Boolean) {
allLetters_mc.removeMovieClip();
startScreen_mc._visible = true;
/* -------------------- the start screen message if the word was
successfully guessed -------------------- */
if (success) {
startScreen_mc.message_txt.text = "Congratulations!
You did it! Want to try again? Press the play button below.&quot;;
/* -------------------- the start screen message if the character
was hanged -------------------- */
} else {
startScreen_mc.message_txt.text = "GAME OVER!
Aaargh! You killed the little guy! Want to try again? Press the play
button below.&quot;;
}
playAgain = true;
}
/* -------------------- functionality of the PLAY! button -----------
--------- */
startScreen_mc.play_mc.onRelease = function() {
this._parent._visible = false;
guessWord_txt._visible = true;
hangman_mc.gotoAndStop(1);
randomize(playAgain);
placeLetters();
};
/* -------------------- end coding -------------------- */

Now, this code perfectly function in "normal" flash player&quot;, but
when I try this in Flash Lite mode, I get this error:

(Location) Scene=scene 1, layer=actionscrypt, frame 166, line 37
(descritpion) '{'expected (Source) function parseWords():Void {

(this is inside line 37): function parseWords():Void {

And other error is:

(Location) Scene=scene 1, layer=actionscrypt, frame 166, line 47
(descritpion) Unexpected'{'encountered (Source) }

I do not know what to do. Are this codes compatible with Flash Lite
2.x?

Can someone help me please? Thanks! ;)

__._,_.___
.

__,_._,___
Re: "Void" function in Flash Lite 2.x
country flaguser name
United States
2007-10-04 13:28:36

Anyone, please?

This code normaly works on compter, in normal flash player, but when I
try to start it in mobile player, error appears. Is it maybe that
voide function works in flash lite in other way?

__._,_.___
.

__,_._,___
Re: Re: "Void" function in Flash Lite 2.x
country flaguser name
United States
2007-10-05 07:41:54

in flash you can remove a function by using null

var myFunction : Function = function()
{
}

// to kill it
myFunction = null;



hope this helps

Oki

On 10/4/07, Um < um_forumyahoo.com">um_forumyahoo.com> wrote:

Anyone, please?

This code normaly works on compter, in normal flash player, but when I
try to start it in mobile player, error appears. Is it maybe that
voide function works in flash lite in other way?




--
 &nbsp; &nbsp; &nbsp; - OQ -
oludiroludiro.com">oludiroludiro.com

01001100 01101111
01110110 01100101
00100000 01010011
01101111 01100110
01101001 01100101

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )