|
-
Duplicate Movie problem. s
How come when I tried to assign the x and y of a duplicated 'laser1' mc to the xy of the movie clip inside a movieclip, the xy of the laser mc is zero. (sorry for the bad english)
The movie clip(cannonmc) that contains the script is inside another movie clip(cannon) followed by a 'ship' mc.
This is the script of the 'cannonmc' mc.
Code:
onClipEvent(load) {
shots = 0;
}
onClipEvent(enterFrame) {
if(Key.isDown(Key.SPACE)) {
duplicateMovieClip(_root.laser1, "shootlas1"+shots, 7000+shots);
_root["shootlas1"+shots]._x = this._x+20;
_root["shootlas1"+shots]._y = this._y+10;
if(shots != 99) {
shots++;
} else { shots = 0; }
}
}
When 'ship' mc moves, the duplicated movie doesn't follow the moved 'cannon' mc.
Please help me.
Checkout my site:
Click HERE
Checkout my games:
Oops! No game for now!
-
try:
var temp = duplicateMovieClip(_root.laser1, "shootlas1"+shots, 7000+shots);
temp._x = this._x+20;
temp._y = this._y+10;
-
Flash Gordon
Watch out theTick !
duplicateMovieClip(target,newname, depth) does not return the copied instance.. it's wrong in help...
only MovieClip.duplicateMovieClip(newname,depth) does !!!
(this has been corrected in Flash8 help / LiveDocs)
[edit] from here i first wrote BS...
@your problem:
You just set the x/y position of the laser shot only once, on duplication...
that's where it will stay.
Last edited by McUsher; 11-25-2005 at 02:10 PM.
My letters on the F1 key have faded, how are yours today?
-
ah...thanks. that slipped my attention. i usually use the MovieClip method...
-
Hmm...maybe showing me the code would help.
Checkout my site:
Click HERE
Checkout my games:
Oops! No game for now!
-
PHP Code:
duplicateMovieClip(_root.laser1, "shootlas1"+shots, 7000+shots);
_root["shootlas1"+shots].onEnterFrame = function ()
{
this._x +=20;
}
_root["shootlas1"+shots].onEnterFrame = function ()
{
this._y +=10;
}
thus, you assign an onEnterFrame event to all newly created shots that continuously adds to its _x or _y position...although you might want to decrease the value you add...
-
I wonder how do you get the xy of a movie clip(that is in another movie clip) on the stage...
I tried tracing the xy of the 'cannonmc' mc and the result is 0...
edit:
'cannon' mc is actually attached into the 'ship' mc through actionscript. Could this be part of the problem?
Last edited by Gamerflash; 11-25-2005 at 08:41 PM.
Checkout my site:
Click HERE
Checkout my games:
Oops! No game for now!
-
Checkout my site:
Click HERE
Checkout my games:
Oops! No game for now!
-
you can use the MovieClipMethod localToGlobal() to transform cannonmc's local coordinates (which will always be the same inside the ship mc, because i suppose you don't move the cannonmc around inside the ship mc) to stage coordinates.
there's a good example how to correctly use the method in the help files.
Last edited by theTick; 11-26-2005 at 06:49 AM.
Please sign here
-
Flash Gordon
Hmm.. i think it would be easier, if you post the fla
My letters on the F1 key have faded, how are yours today?
-
THANK YOU theTick! Special thank to McUser too!
localToGlobal() is just what I needed.
Now my ship can shoot laser from the cannonmc.
:smile:
Checkout my site:
Click HERE
Checkout my games:
Oops! No game for now!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|