View Full Version : position not changing correctly
josbosmans
07-13-2004, 09:36 AM
I'm writing a breakout-clone as my first flash-program.
The position of my paddle is updated in _root['palet']._x but I dont see a change on the screen (position changes internally, because I can still deflect the ball, and my debug-output says so).
Some code :
/*new position this.x is calculated before this*/
_root[this.naam]._x = this.x;
message += ' ' + _root[this.naam]._x + ' ' + _root['palet']._x;
The debug output (message) prints the correct value twice.
I'ld really appreciate it if someone could point out what I'm doing wrong.
Thanks
i really think the problem is this part of script:
_root[this.naam]._x = this.x;
message += ' ' + _root[this.naam]._x + ' ' + _root['palet']._x;
the pathing will cause confusion for flash...
what is "naam" ?
is it a movieclip on the root timeline?
if thatīs the case you have to write: _root.naam._x = this.x;
what is "palet" ?
is it a movieclip on the root timeline?
if thatīs the case you have to write: _root.palet._x;
an other problem could be that you try to mix up strings with numbers...
cobo
josbosmans
07-13-2004, 10:21 AM
this.naam is the name of the object, in this case : 'palet'
I tried the naming you suggested (_root.palet._x instead of _root['palet']._x), but nothing changed.
The mixing of strings and numbers only happens in the debug-output, and it doesn't seem to cause any trouble.
I'm not completely familiar with the terminology (movieclip, root timeline), but I think that 'palet' is the name of a movieclip. (it's a red rectangle that I drew previously, that was added to the flash-movie under the name 'palet').
Perhaps some more code would help clarify. This is some code that moves the ball :
this.updatepos = function () {
/*new position this.x and this.y calculated before this*/
_root[this.naam]._x = this.x;
_root[this.naam]._y = this.y;
};
Here, this.naam == 'ball', and this code works correctly (ball moves across the screen).
if you post your zipped fla file i will have a look at it later this day... ;)
cobo
josbosmans
07-13-2004, 10:46 AM
I don't really know what fla-files are. I don't use a Macromedia-program, but Ming, an open-source project that allows you to write PHP-code that represents Flash and actionscript-code (the actionscript code is a string), which is directly compiled into a swf-file.
Should I just post all my source code instead?
yip... give it a try mate... :)
now i have a question:
is there a way to create swf files out of .wav (audio file) with ming?
cobo
huh... a warm welcome to the boards at least... :D
josbosmans
07-13-2004, 11:01 AM
I've attached the code as a txt-file. I'm afraid that most of the comments are in Dutch (have to leave soon so I don't have time to change them anymore before the evening).
I've only started learning flash saturday, so I don't know much about the capabilities of Ming, but the only sound-related function I've seen thus far is the streammp3 function that allows you to play an external mp3-file.
huh... a warm welcome to the boards at least...
Thanks :)
mate... thatīs completly different to everything what iīve seen by now...
i know php and also actionscript... but i think ming needs also some special knowledge...
try to post your code to the serverside section... http://www.actionscript.org/forums/forumdisplay.php3?f=45
sorry, and good luck... :)
cobo
josbosmans
07-14-2004, 01:28 PM
I finally found the problem : the graphic object I was manipulating was called 'palet', but I also had a function called 'Palet', being the constructor for the paddle-object. Apperently actionscript or Ming or Flash isn't case-sensitive, which caused the problem ...
I guess that from now on I'll be using some sort of Hungarian notation (adding the type of the object/variable to its name) to avoid further problems of this kind.
Thanks for your efforts
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.