PDA

View Full Version : whatīs wrong with this code (operator ++)?


yker22
01-30-2006, 11:34 PM
fireballDepth = 950000;

function fireball()
{
this.attachMovie("loopedfirebigger_mc", "loopedfirebigger_mc", fireballDepth());
fireballDepth++;
_root.loopedfirebigger_mc._x = 171;
_root.loopedfirebigger_mc._y = 0;
trace("fireball attached");
}


I have this function to attach a fireball mc on stage when a condition is meet... it works... but this fireball mc dissappear when I click on another mc (supposely nothing has to happen here, there is not a remove or delete statement) or if another fireball mc is called... Iīm missing something but canīt see...

Thanks for the help

yker22
01-30-2006, 11:38 PM
if (rnd == 3)
{
updateScore(100);
var posX:Number = this.oldX;
var posY:Number = this.oldY;
_root.attachMovie("bonus100","bonus100", bonus100Depth())
bonus100Depth++;
trace("puntuación de 100");
_root.bonus100._x = posX;
_root.bonus100._y = posY;
}

Iīm using the same logic in this function and I have not problem, thatīs why I canīt understand... why the logic changes?

CyanBlue
01-30-2006, 11:42 PM
You need to get rid of the () for the depth... ;)
this.attachMovie("loopedfirebigger_mc", "loopedfirebigger_mc", fireballDepth);

yker22
01-30-2006, 11:53 PM
You need to get rid of the () for the depth... ;)
this.attachMovie("loopedfirebigger_mc", "loopedfirebigger_mc", fireballDepth);

Thanks cyanblue, now the function works, but fails: I mean, the fireball mc is on stage but has not its code functionality... you know there is a hitArea inside it but now there is not a hitTest, and is not removed by code as intended when intended .... :mad:

Flash Gordon
01-30-2006, 11:53 PM
Welcome back CyanBlue ;)

While we are on this topic, why does:

n=0
trace(n++); trace 0?

EDIT: sorry yeker I thougth you problem was solved.

You better provide some more FORMATED ;) code and the fla. I don't understand what you are asking.

yker22
01-30-2006, 11:55 PM
Welcome back CyanBlue ;)

While we are on this topic, why does:

n=0
trace(n++); trace 0?

hi flash gordon, sorry but this has to do with my problem/thread? I donīt understand...

Flash Gordon
01-30-2006, 11:57 PM
like I said, I thougth you problem was solved (you can see we postd at the same time) and it actually wasn't related to the topic posted. I merely asked a question that was on the topic. I'm not trying to hi-jack your thread.

CyanBlue
01-31-2006, 12:03 AM
There is one more instance if you have not fixed it yet...
_root.attachMovie("bonus100","bonus100", bonus100Depth);

yker22
01-31-2006, 12:14 AM
Sorry CyanBlue, but that doesnīt works... youīll see the whole code that I have sended you...

bonus100 is an animation to be played when a ball score points... If I delete () from bonus100Depth, the animation is played, but there is another "ghost" animation on the left top corner of stage... I donīt know, this is a mess and for now Iīm very tired and I canīt see the solution....


good night.

Isaac

darkzak
01-31-2006, 01:02 AM
Welcome back CyanBlue ;)

While we are on this topic, why does:

n=0
trace(n++); trace 0?


n++ is a post-increment operation, so the trace function gets the value of n and then n is incremented. The post-increment operation just simplifies typing while programming but the actual compiled code is expanded into afunction call to trace(n) followed by an increment n operation.

To get an output of 1 you would use pre-increment trace(++n);