Groups | Blog | Home
all groups > flash actionscript > march 2006 >

flash actionscript : swapDepths Syntax


TiJayOldroyd
3/7/2006 9:24:18 PM
This is the same thing I've been working on for the past 3 days (i know, I'm
slow) As those who have helped me before have seen/known/read/forgotten - I'm
a noob, and learning Flash...that being said...the swapDepths function eludes
me...I understand the just of of - but the syntax and placement has me all
bumblef**ked...With what I have so far, when I go to 'Test Movie' it does a
pretty job of swapping depths...but, erm....it doesn't do the gotoAndPlay("blah
blah blah") and I'm just looking at a ball that's closer to my face that
before the onRollOver...(go ahead...laugh - you know you want to)

here is the code I used - this is the first instance I decided to use it
at...and I've moved it around a bit throughout the function () { string...HELP
MEH



this.ball4.onRollOver = function() {
if (move_var == 0) {
if (ball1_var == 1) {
gotoAndPlay("_1over4")
}
if (ball2_var == 1) {
gotoAndPlay("_2over4")
}
if (ball3_var == 1) {
gotoAndPlay("_3over4")
}
if (ball4_var == 1) {
gotoAndPlay("_4over4")
}
if (ball5_var == 1) {
gotoAndPlay("_5over4")
}
if (ball6_var == 1) {
gotoAndPlay("_6over4")
}
if (ball1_var == 0){
if (ball2_var == 0) {
if (ball3_var == 0) {
if (ball4_var == 0) {
if (ball5_var == 0) {
if (ball6_var == 0) {
gotoAndPlay("_over4")
}
}
}
}
}
}
}
this.swapDepths(ball6)
this.swapDepths(ball4)
}
TiJayOldroyd
3/7/2006 9:25:39 PM
note:

blemmo
3/7/2006 9:59:34 PM
Hi,
I have seen this.swapDepths(100) somewhere, so it seems that you can put in a
number too.
MCs created in the Flash IDE all have the same depth, iirc, only dynamically
attached or created MCs get other numbers.

cheers,
blemmo
TiJayOldroyd
3/8/2006 2:22:33 PM
I tried adding this.swapDepths(100), and It changed the depth - and put the MC
up front, but It doesn't do the tween, now...then, when I rollOver again, it
does the tween, but at the origional depth, showing basically the outline of my
ball/box holding my ball growing...I'm gonna fiddle with it some more - if you
have any suggestions on why it isn't working, let me know...thanks again
TiJayOldroyd
3/8/2006 4:06:44 PM
I am completely flabberghasted...Then again, I've only been coding for 2 weeks
now...I sent my .fla to a friend who is a flash wiz - a last resort...if he can
figure out what is wrong with it, I'll post it for the next person with my
problem...
TiJayOldroyd
3/8/2006 6:57:52 PM
*bump*

Scottie_Too_Hottie7
3/8/2006 7:15:52 PM
STUPID QUESTION ALERT!!! DO NOT LOOK AT THIS MESSAGE IF YOU HATE STUPID
QUESTIONS CAUSE I AM ABOUT 2 ASK ONE
-------------------------------

stupid question #1 : are you still stumped with the gotoAndPlay()'s not
working. if not, then stupid question #2 is N/A
stupid question #2 : if the answer to #1 is yes, then where have you assigned
the 'move_var' and 'ballx_var'? the way that code is presented, it is looking
for them variables in ball4.

-------------------------------

If the author of this thread thinks theese questions are so totally
unnessacerry, then post saying so and i will delte my post :p

Oh and also, why have all them ugly if's at the end? which is nicer.


if (ball1_var == 0 && ball2_var == 0 && ball3_var == 0 && ball4_var == 0 &&
ball5_var == 0 && ball6_var == 0) {
gotoAndPlay("_over4")
}

or

if (ball1_var == 0){
if (ball2_var == 0) {
if (ball3_var == 0) {
if (ball4_var == 0) {
if (ball5_var == 0) {
if (ball6_var == 0) {
gotoAndPlay("_over4")
}
}
}
}
}
}


TiJayOldroyd
3/8/2006 7:30:07 PM
1) The problem isn't the gotoAndPlay, it is the fact that when I add the
swapDepths code to it - it swaps the depth onRollOver, but then it doesn't play
the frame I told it to play...or any frame for that - from that point on in the
project, ball4 and ball6 (the two I'm swapping) sit there and do absolutely
nothing. I am trying to figure out to to change the depth of ball 4 - making
it the top layer, at the beginning of the onRollOver frame.

2) as for all of those 'if' statements - I am still learning all sorts of
shortcuts - that is one I haven't picked up until now. Thanks - should shorten
my coding a little...
Scottie_Too_Hottie7
3/8/2006 7:40:33 PM
TiJayOldroyd
3/8/2006 8:10:26 PM
Scottie_Too_Hottie7
3/8/2006 8:19:14 PM
kglad
3/8/2006 8:30:13 PM
TiJayOldroyd
3/8/2006 8:31:23 PM
http://users.fdn.com/~alteer/OML/NewButton.fla

That is where it is...sorry for the annoyance of the maticulaty of the code (i
just made that word up, by the way - I have OCD and try to make it look pretty
no matter what - IE maticulous(sp?))

check it out - i know some of the buttons don't work, I'm not so much worried
about that...open 'test movie' click the blue ball (ball1) and they scatter -
when you look at it - ball4 (yellow) and ball6 (dark pewter) are
overlapping...ball6 being a higher layer - is on top of ball4...I want ball4 to
swapDepths with ball6 onRollOver...

I did a depth trace - and it showed ALL the symbols (ball1 - ball6) were at
-16382...

when I add 'swapDepths(ball6)' - it swaps, but the balls don't do ANYTHING
after that...
TiJayOldroyd
3/8/2006 8:32:20 PM
kglad
3/8/2006 9:00:54 PM
if you want a rolled over ball to be at the highest depth and to return when
rolled-off you can add the following to your rollOver handlers:

this.dep=this.getDepth();
this.swapDepths(1);

and add to your rollOut handers:

this.swapDepths(this.dep);
Scottie_Too_Hottie7
3/8/2006 9:02:46 PM
im stumped atm. ill try to have another look tommorow cause im signing out for
tonight.
heres my current thoughts thow

Ive tried DepthManager, but it seems when ive tried to use setDepthAt or
setDepthAbove, it just simply is not changing the depths.

This could be to do that the balls are only named at frame 1. once you have
moved on to the next 'release series of frames' and got to the 'stop()'
actionscript (in the layer 'label'), the balls are not named anymore.

Unfortunally, it would be a long job to give all of them names, and atm ive
not got time :-p

Till Tomoz..

Scottie_Too_Hottie7 Signing Out

Note : kglad, if the depths arn't being changed when they are told to change,
what is the point in your last post?
TiJayOldroyd
3/8/2006 9:07:53 PM
once again, kglad - I tried your method, and it did the same thing - i am stuck
with one of the following - swapDepths working and ball4 becoming completely
comatose - or ball4 working like it's supposed to, but in the background...
Jeckyl
3/9/2006 12:00:00 AM
A clip cannot serve two maters. It cannot both be under the control of
script AND of the timeline. So if you start changing depths or _x, _y etc
then any timeline-based actions (like motion tweens etc) will no longer work
... as the clip is now under control of script instead timeline.
--
Jeckyl

Scottie_Too_Hottie7
3/9/2006 12:00:00 AM
Manifest Interactive
3/9/2006 5:56:56 AM
Greetings,

Just a quick question for you. I noticed that you are calling the
function by onRollOver of "ball4" (this.ball4.onRollOver). This would
imply that you have a movie clip that has another movie clip in it
called "ball4" that you have given an <instance name>. This also means
that "ball4" is the first frame in the movie clip of "this" that has
your code on it.

I am just trying to get a grasp of how you set up your timeline. It
might help to get an idea of how you structured the locations of where
these balls are at on your timline. Are they all on their own layer and
with one frame a piece? Is that why you want to swap depths, because
they are currently on top of one another?

Something like:

_root > this (current clip) > ball4

could give us an idea where you movie clip is located from the root of
your movie. Also, I see that you are defining variables (ball1_var).
Where are these being set to 0|1 and have you traced the value of these
to see what their values are?

Finally, for your gotoAndPlay commands, the code below indicates that
you want "this" to gotoAndPlay a frame. If this is correct, you could
make it absolute by saying this.gotoAndPlay("_1over4"). If you are
trying to control "ball4" then you will need to do something like
this.ball4.gotoAndPlay("_1over4");

Hope this helps, any answers you can give us on where these balls are
in your FLA and how you have them layed out on the stage will help.

- Peter Schmalfeldt

[quoted text, click to view]
AddThis Social Bookmark Button