Groups | Blog | Home
all groups > flash actionscript > july 2004 >

flash actionscript : var / function problem


hemendras NO[at]SPAM mindfiresolutions.com
7/21/2004 10:20:04 PM
Hi,

If you just want the value to be checked out side the function and the value is
modified in side the function make it global, if you want the function variable
to retain the value over the deifferent calls to the function make the variable
static.

If you can provide the peice of code you are trying to it will help us helping
you better.

Good luck

Hemendra Singh Shaktwat

Mindfire Solutions
Colour Bleu
7/21/2004 10:33:23 PM
Help please. I know nothing,
Im trying to minipulate a var outside of a function.

I have a function that onRelease dose this... and outside of the
function I would like to compaire the var between two similar functions
to do that..

what am I missing?

many thanks

Colour Bleu
7/22/2004 3:21:12 PM
Hi thanks for you help.

This is the code Im playing with:

stop();
myCounter = 0
yourCounter = 0
left_mc.onRelease = function() {
myCounter = (myCounter + 1);

if (myCounter == 1) {
var hairColor:Color = new Color(left_mc);
hairColor.setRGB(0xffffff);
};
if (myCounter == 2) {
var hairColor:Color = new Color(left_mc);
hairColor.setRGB(0xff0000);
};
if (myCounter == 3) {
var hairColor:Color = new Color(left_mc);
hairColor.setRGB(0x000000); myCounter = 0;
};



}

right_mc.onRelease = function() {
yourCounter = (yourCounter + 1);

if (yourCounter == 1) {
var hairColor:Color = new Color(right_mc);
hairColor.setRGB(0xffffff);
};
if (yourCounter == 2) {
var hairColor:Color = new Color(right_mc);
hairColor.setRGB(0xff0000);
redRight =
};
if (yourCounter == 3) {
var hairColor:Color = new Color(right_mc);
hairColor.setRGB(0x000000);
yourCounter = 0;
};


}
// this is where I want to put in a condition, that is if one of the
MovieClips named left/right_mc is a certian colour then do something.
But I cannot get the var to be recognised outside of the function. You
mention make it global, this I am not sure how to do. Do you mean by not
putting var at the begining when I declar the var? thanks again for any
insights.

if (right_mc == 0) {nextFrame();
};



[quoted text, click to view]
hemendras NO[at]SPAM mindfiresolutions.com
7/23/2004 1:50:47 AM
Hi,

There are two ways to do what you are trying to do,

1. In your left_mc or right_mc's onRelease use fully qualified path to the
variable like if you have declared them on root use _root.myCounter;

2. The syntax for global variable is

_global.myCounter = 0

and then

if (_global.myCounter == 1)

Hope this helps

Good Luck

Hemendra Singh

Mindfire Solutions
AddThis Social Bookmark Button