Forum Topic: combine two movie clips using AS?

(132 views • 10 replies)

This topic is 1 page long.

<< < > >>
Questioning

nickelwise

Reply To Post Reply & Quote

Posted at: 7/16/06 07:10 PM

nickelwise NEUTRAL LEVEL 06

Sign-Up: 07/16/06

Posts: 17

I'm trying to make an army vs army type game, but the way of battle I came up with is a little to complex for me to code at my current stage of Flash knowledge. So I have two questions for everyone:
Is it possible to combine two Movie Clips using ActionScript and have them keep their respective X, Y coordinates?
and:
Can you horizontally flip a Movie Clip in ActionScript.
Help is appreciated.


None

Johnny

Reply To Post Reply & Quote

Posted at: 7/16/06 07:22 PM

Johnny DARK LEVEL 20

Sign-Up: 04/17/04

Posts: 3,698

At 7/16/06 07:10 PM, nickelwise wrote:
Is it possible to combine two Movie Clips using ActionScript and have them keep their respective X, Y coordinates?

How can you combine something, but have it stay in the same place? You mean, follow one other? Clarify this one.

Can you horizontally flip a Movie Clip in ActionScript.

this._x *=-1


None

nickelwise

Reply To Post Reply & Quote

Posted at: 7/16/06 07:26 PM

nickelwise NEUTRAL LEVEL 06

Sign-Up: 07/16/06

Posts: 17

thanks,
I mean like have two movie clips be combined, but not both be automatically centered, so they stay where they were until they get moved.


None

nickelwise

Reply To Post Reply & Quote

Posted at: 7/16/06 07:38 PM

nickelwise NEUTRAL LEVEL 06

Sign-Up: 07/16/06

Posts: 17

or heres another alternative to that:
im trying to make it so when you click somewhere on the one side of the screen, it creates a splatter on the opposite side of the screen. so lets say the screen is 550 pixels wide, and I have a line running down the middle at 275. Im trying to make it so that when you click, let's say on the right side somehwere, it creates a splatter on the x opposite of the screen. So if i placed my click at X:276, right next to the middle, the splatter would appear at x:274, the mirror area.

So one way i could do it would be combining the middle line and the splatter on whatever side i clicked, horizontally flipping it, and centering the middle line.

Or so I think. I hope I didn't confuse anyone TOO much.


None

dragonjet

Reply To Post Reply & Quote

Posted at: 7/16/06 08:09 PM

dragonjet LIGHT LEVEL 20

Sign-Up: 12/02/05

Posts: 557

alright i really didnt understand it even with your last explanation.
but with what i know, here's what you need to do... or add to the frame script....

setInterval(function(){ Movieclip1._x=Movieclip2._x; Movieclip1._y=Movieclip2._y; },1);

just change the movieclip names...
if youre using lines as your movie clip, thats another code....

linemovieclip.moveto(movieclip2._x,moviecl
ip2._y);

did i help? i know some more things but... try these ones first...


None

nickelwise

Reply To Post Reply & Quote

Posted at: 7/16/06 08:20 PM

nickelwise NEUTRAL LEVEL 06

Sign-Up: 07/16/06

Posts: 17

thanks, im experimenting with that now, i'll utell you if it works or not.


None

DingoEatingFuzz

Reply To Post Reply & Quote

Posted at: 7/16/06 08:25 PM

DingoEatingFuzz LIGHT LEVEL 18

Sign-Up: 06/18/05

Posts: 1,130

At 7/16/06 07:22 PM, Johnny_Krysys wrote:
Can you horizontally flip a Movie Clip in ActionScript.
this._x *=-1

shouldn't it be this._xscale *= -1?


None

dragonjet

Reply To Post Reply & Quote

Posted at: 7/16/06 08:37 PM

dragonjet LIGHT LEVEL 20

Sign-Up: 12/02/05

Posts: 557

OH WAIT! Now I Understand!
I was wrong i know your problem....
i know the solution too... here... wait... oh...


onMouseDown=function(){
if(_xmouse>275){
x1=_xmouse; y1=_ymouse;
mc._x=550-x1;
mc._y=y1;
}}

mc is your "splatter" Movie Clip...

NOTE:
the 550 is your flash width...
works even if your attack screen is left or right, just change the > or < in the if statement... if(_xmouse > 275){


None

nickelwise

Reply To Post Reply & Quote

Posted at: 7/16/06 08:39 PM

nickelwise NEUTRAL LEVEL 06

Sign-Up: 07/16/06

Posts: 17

okay, i finally got it.
---
on (press) {
xmouse = _root._xmouse;
middle = 275;
smallnum = xmouse - middle;
difference = middle - smallnum;
_root.my_mc._x = difference;
}
---
was the code that finally ended up working, not that it could help anyone at all. i'll post the link to the final game here in a few hours probably, if anyone cares.


None

dragonjet

Reply To Post Reply & Quote

Posted at: 7/16/06 08:44 PM

dragonjet LIGHT LEVEL 20

Sign-Up: 12/02/05

Posts: 557

oh... i got classes later on so i cant see... but next time ill find it...
hope it works well... good luck on the flash...


None

Johnny

Reply To Post Reply & Quote

Posted at: 7/16/06 09:02 PM

Johnny DARK LEVEL 20

Sign-Up: 04/17/04

Posts: 3,698

At 7/16/06 08:39 PM, nickelwise wrote: okay, i finally got it.
---
on (press) {
xmouse = _root._xmouse;
middle = 275;
smallnum = xmouse - middle;
difference = middle - smallnum;
_root.my_mc._x = difference;
}

You can simplify that by adding things together too, like an algebra equation.

on(press){
middle = 275;
_root.my_mc._x = (middle - (_root._xmouse - middle));
}

or even better, because you don't have to define the width of the stage...

on(press){
_root.my_mc._x = (Stage.width/2 - (_root._xmouse - Stage.width/2));
}


All times are Eastern Standard Time (GMT -5) | Current Time: 08:37 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!