00:00
00:00
Newgrounds Background Image Theme

Kurmudgen just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

variable problem

688 Views | 26 Replies
New Topic Respond to this Topic

variable problem 2005-05-20 05:52:29


as the name of the subject implies I have a variable problem.

I need to know how to access and modify the variables in an mc from another mc.

kind of like

_root.player(variablename(I don't know the method of inplementing this))(rest of condition code code here)

help

Response to variable problem 2005-05-20 05:56:15


path.variablename;

where path can be _root.mc1.mc2
or _parent.mc1.mc2
or just mc1.mc2 if it's inside the other mc

Response to variable problem 2005-05-20 06:05:38


ok that dosen't seem to work what i have now is:
if (_root.enemy.hitTest(this._x, this._y-10, true)) {
_root.enemy.life -= 10;
deathtime = 2;
}

life is the varibale please help

Response to variable problem 2005-05-20 06:13:12


the code is flawless, watch the life variable with the debugger

Response to variable problem 2005-05-20 06:18:12


this is the code I have in my eneny mc at the moment:

onClipEvent (load) {
life = 100;
}
onClipEvent (enterFrame) {
if (life<1) {
this.removeMovieClip();
}
}

this is waht I have in the bullet:

this.onEnterFrame = function() {
_xscale += 5;
_yscale += 5;
deathtime -= 1;
_x += 10;
if (deathtime<10) {
this.removeMovieClip();
}
if (_root.ground.hitTest(this._x, this._y-10, true)) {
this.removeMovieClip();
}
if (_root.enemy.hitTest(this._x, this._y-10, true)) {
_root.enemy.life -= 10;
deathtime = 2;
}
};

Response to variable problem 2005-05-20 06:20:04


and you're sure you haven't mixed instance names and clip names up?

Response to variable problem 2005-05-20 06:21:59


the bullet clip removes itself when it hits the enemy, but after 10 hits the enemy dosen't remove itself

Response to variable problem 2005-05-20 06:23:10


i am positive because the rest of the code works flawlesly

thinks i am trying to double post:
ghdasgtfeghfefghjdffdghjfyerfbdsdhufvnmdfhyacm,sdhfuknsdkhfyknvsdfhyukfhsvh
vnfdvuifbnf,vhdfg,nvfdugruhgse

Response to variable problem 2005-05-20 06:23:04


stuff in flash can't remove itself, it must be removed by something else,
removeMovieClip(this)
or this.removeMovieClip()

don't work

Response to variable problem 2005-05-20 06:42:10


so how do I do this.
put the remove movieClip in the bullet?

Response to variable problem 2005-05-20 06:47:04


so how would that be done:

if (_root.enemy.life<1){
this.removeMovieClip.enemy
}

how would you state that?

Response to variable problem 2005-05-20 15:04:37


please someone help I need to know.

Response to variable problem 2005-05-20 15:10:28


At 5/20/05 06:05 AM, TheLordOfDisarray wrote: ok that dosen't seem to work what i have now is:
if (_root.enemy.hitTest(this._x, this._y-10, true)) {
_root.enemy.life -= 10;
deathtime = 2;
}

I am not trying to access a mc in another mc I am trying to access a variable

Response to variable problem 2005-05-20 15:36:20


At 5/20/05 06:23 AM, Inglor wrote: this.removeMovieClip()
don't work

erm, yes it does. I used it on the last frame of the (duplicated) enemies in OII, and it worked fine.

At 5/20/05 06:18 AM, TheLordOfDisarray wrote:
if (_root.enemy.hitTest(this._x, this._y-10, true)) {
_root.enemy.life -= 10;
deathtime = 2;
}
};

I think your problem is that you're not targetting the duplicated enemies (I'm assuming your enemies are being duplicated, since removeMovieClip won't work otherwise). When you create your duplicated enemies, you give them individual names, eg "enem"+i - you need to find out which one you're shooting, and target that one with your life-=10
If you're not duplicating your enemy, you can get rid of it by using
this.swapDepths(99999);
this.removeMovieClip();

Once you've swapped its depth, it will be removeable the same as a duplicated MC


- - Flash - Music - Images - -

BBS Signature

Response to variable problem 2005-05-20 15:38:53


never mind think i fixed it

Response to variable problem 2005-05-20 15:41:54


At 5/20/05 03:36 PM, Denvish wrote:
At 5/20/05 06:23 AM, Inglor wrote: this.removeMovieClip()
don't work
erm, yes it does. I used it on the last frame of the (duplicated) enemies in OII, and it worked fine.

doesn't work in MX very well, still buggy in MX 2004 they even ask to evade doing it on livedocs

Response to variable problem 2005-05-20 16:24:35


I am currently having a problem this is my code. It is in the first frame of my animation:

onEnterFrame = function () {
if (_root.enemy.alphadeath<0) {
this.removeMovieClip;
}
};

I have traced the alphadeath variable but when it goes lower than 0 the mc is not removed please help

Response to variable problem 2005-05-20 16:29:11


If it's not a duplicated MC, you can't remove it until you use swapDepths on it, like I mentioned in my previous post

this.swapDepths(99999);
this.removeMovieClip();


- - Flash - Music - Images - -

BBS Signature

Response to variable problem 2005-05-20 16:33:14


if (_root.enemy.alphadeath<50) {
this.swapDepths(99999);
this.removeMovieClip();
}

didn't work

I have traced all of the variables and the work properly so do you know what the problem is?

Response to variable problem 2005-05-20 16:40:30


At 5/20/05 04:33 PM, TheLordOfDisarray wrote: if (_root.enemy.alphadeath<50) {
this.swapDepths(99999);
this.removeMovieClip();
}

didn't work

I have traced all of the variables and the work properly so do you know what the problem is?

No idea. Last suggestion: replace "this." with "_root.enemy."

if (_root.enemy.alphadeath<50) {
_root.enemy.swapDepths(99999);
_root.enemy.removeMovieClip();
}

Are you using duplicateMovieClip to create your enemies? Or is it just one MC?


- - Flash - Music - Images - -

BBS Signature

Response to variable problem 2005-05-20 16:41:53


ok I think I know what the problem is how do I check for a hittes on a duplicated object

I have:

this.onEnterFrame = function() {
_xscale += 5;
_yscale += 5;
deathtime -= 1;
_x += 10;
if (deathtime<10) {
this.removeMovieClip();
}
if (_root.ground.hitTest(this._x, this._y-10, true)) {
this.removeMovieClip();
}
if (_root.["enemy"+y].hitTest(this._x, this._y-10, true)) {
_root.["enemy"+y].life -= 10;
deathtime = 0;
}
};

but the hittest cratera dosen't work

please help

Response to variable problem 2005-05-20 16:43:28


I was using nonduplicated

but am now using duplicated

kdhdhsh fhjygbvh dfsfbvdf ukbdfjkg hudfjk sfhdskgjsrgbdfmsf hsrugdfshu g

Response to variable problem 2005-05-20 16:49:14


At 5/20/05 04:41 PM, TheLordOfDisarray wrote: ok I think I know what the problem is how do I check for a hittes on a duplicated object

You'll have to use a loop to check each of your duplicated enemies for a hitTest
So if your duplicated enemies are named enemy1 to enemy10:

for(i=1;i<11;i++){
if (_root.["enemy"+i].hitTest(this._x, this._y-10, true)) {
_root.["enemy"+i].life -= 10;
deathtime = 0;
}
}


- - Flash - Music - Images - -

BBS Signature

Response to variable problem 2005-05-20 17:49:28


**Error** Symbol=bullett, layer=Layer 1, frame=1:Line 14: Expected a field name after '.' operator.
if (_root.["enemy"+x].hitTest(this._x, this._y-10, true)) {

what does that mean?

Response to variable problem 2005-05-20 17:54:17


this is waht I ahve in the bullet:

this.onEnterFrame = function() {
_xscale += 5;
_yscale += 5;
deathtime -= 1;
_x -= 10;
if (deathtime<10) {
this.removeMovieClip();
}
if (_root.ground.hitTest(this._x, this._y-10, true)) {
this.removeMovieClip();
}
for(x=1;x<11;x++){
if (_root.["enemy"+x].hitTest(this._x, this._y-10, true)) {
_root.["enemy"+x].life -= 10;
deathtime = 0;
}
}
}

this is what I have on frame one (this is just to see in the spawn works):

if (Key.isDown(Key.SHIFT)) {
x++;
_root.attachMovie("enemy", "enemy"+x, x);
_root["enemy"+x]._x = _root.buddy._x;
_root["enemy"+x]._y = _root.buddy._y;
_root["enemy"+x].deathtime = life=100;
}

neither work

Response to variable problem 2005-05-20 17:56:22


ok the second works now
but not the first please help

Response to variable problem 2005-05-20 18:03:14


ok the second code seems to spawn 1 clip only that changes positions with the plarer how do I get it to stay in one spot?