• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

SwapDepth problems PLEASE HELP

Hi,

I have got a movie file that contain 2 movie clips instances: ex1 and ex2. I put them on 2 separate layers. ex2 contains action scripts calling loadMovieNum from several other movies and set target level as 1.

ex1 is a navigation menu and ex2 is the content. How do I get ex1 on top of x2 everytime I have the mouse rollover ex1? and get x2 back on top whenever rollout?

my code looks like this:
on the stage, I wrote loadMovie("movie.swf", "ex1");
on ex1:
on(rollOver){
   _root.ex1.swapDepths(_root.ex2);
}
on(rollOut){
   _root.ex2.swapDepths(_root.ex1);
}
on ex2: nothing

I appreciate any help.
0
ilusi
Asked:
ilusi
  • 14
  • 11
  • 4
  • +1
1 Solution
 
henrywwCommented:
can u explain this a little bit more?

// so when u roll over the button ex1 u have ex1 on top of ex2
on(rollOver){
  _root.ex1.swapDepths(_root.ex2);
}

//and when u roll out of ex1, u want ex2 on top of ex1
on(rollOut){
  _root.ex2.swapDepths(_root.ex1);
}

// what is this???
on ex2: nothing

if u only have 2 and u are planning to add more, then just give it a fix number.

if u have more than 2 u can just swap the lowest with the highest. it will work, but it looks funny.

anyway reason why it won't work sometimes ... is the on rollout if u move mouse very fast out of the ex1 it will not work, flash misses the mouse rollout every now & then. increasing the frame rate will help, but can eliminate the problem.

cheers
0
 
henrywwCommented:
well ... again if there is only ex1 and ex2 ...

show ex2 is the content, can u put a button on top?
it depends if u have any interaction within ex2, if it is only animation, u can put a transparent button on top of ex2 (same size) and have the extra on roll over code

//REMOVE THIS FROM EX1
on(rollOut){
 _root.ex2.swapDepths(_root.ex1);
}


// do this for ex2 - button
on (rollOver) {
  _root.ex2.swapDepths(_root.ex1);
}

that's if u can do with a button on top
or in MX simply
ex2.onRollOver = function () {
 _root.ex2.swapDepths(_root.ex1);
}

without even using a button.

cheers
0
 
rexmorCommented:
the easieast way to implement swapDepths is make a variable that increment whenever you want. you can make also swapDepths using in array index, this approach is applicable when you have many objects.

But on this case, you have only two objects.

Try this.

//initialize mcDepth to 100 in frame 1 scene1
_root.mcDepth = 100;


on(rollOver){
_root.mcDepth +=1 ;
  _root.ex1.swapDepths(_root.mcDepth);
}
on(rollOut){
  _root.ex1.swapDepths(_root.mcDepth-1);
  _root.ex2.swapDepths(_root.mcDepth);
}

regards

rex
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ilusiAuthor Commented:
OK. Details:

I have 20 .swf files in series of animation for a presentation. I created a file1.swf and in its timeline, I wrote action scripts, for example:

frame 1: loadMovieNum("slide1.swf", 1);
frame 30: loadMovieNum("slide2.swf", 1);
frame 65: loadMovieNum("slide2.swf", 1);
.
.
.
frame 3000: loadMovieNum("slide20.swf", 1);

then I have file2.swf containing 3 layers:

layer 1, frame 1:
action script: loadMovie("file1.swf", "ex2");

layer 2, frame 1:
I put ex1 movie clip
action script (on ex1 movie clip):
on(rollOver){
  _root.ex1.swapDepths(_root.ex2);
}
on(rollOut){
  _root.ex2.swapDepths(_root.ex1);
}

layer 3, frame 1:
I put ex2 movie clip and wrote no action script for the instance because it's only used for file1.swf placeholder, right?

I tried the trace(_root.ex1.getDepth()); and it returns -1683 ?

Tried your code and rexmor's setting incremental thing and I still got my ex1 behind the file1.swf (ex2).

Do I have to create a button containing ex1 and ex2??? Can't figure out what's happening.

Thanks again.

0
 
henrywwCommented:
do u have a link to ur file. i don't quite understanding the ur movie's setting.

or u can send it to
henryww@yahoo.com

i will have a look for u.

cheers
0
 
ilusiAuthor Commented:
As much as I want to show it to you, but I can't. The file size is 150mb+ and it's corporate disclosure thing.

Basically, there are 2 main .fla files: file1.fla that contains my navigation movi clip and another movie clip that is loaded file2.swf (which is a loaded movie of 20 different .swf files).

Let me know where I might have not explained better.
0
 
rascalpantsCommented:
are you trying to put the below code on a movieclip?

on(rollOver){
 _root.ex1.swapDepths(_root.ex2);
}
on(rollOut){
 _root.ex2.swapDepths(_root.ex1);
}


this can only be done on a button...

use this instead:

onClipEvent(mouseDown){
 _root.ex1.swapDepths(_root.ex2);
}

or better yet, put an invisible button on a layer above the graphics/content in the ex1 or ex2 movieclips...


try that....  currently I have created simple .fla example that uses a button to switch the Depths of two movie clips...

if you want to see it for reference, then post you email address...

rp

 
0
 
ilusiAuthor Commented:
ilusi@yahoo.com

Thanks in adv.
0
 
ilusiAuthor Commented:
ilusi@yahoo.com

Thanks in adv.
0
 
henrywwCommented:
so ... let me say it again

u have a movie call file1.swf (funny name) which in turn load the slide1.swf, slide2.swf ... & so on ... right?

ok ... then u have another movie call file2.swf ...
which has 3 layer ... fine ....
and it loads the file1.swf into a movieclip call "ex2"

============================================
// LAYER 1
layer 1, frame 1:
action script: loadMovie("file1.swf", "ex2");
// this is OK - but the naming is confusing!!!

============================================

// LAYER 2 - where u have a clip call "ex1" here
on(rollOver){
 _root.ex1.swapDepths(_root.ex2);
}
on(rollOut){
 _root.ex2.swapDepths(_root.ex1);
}
// ??? NOW HERE  - this applies to a button?? or what?

==============================================

// LAYER 3, frame 1:
I put ex2 movie clip and wrote no action script for the instance because it's only used for file1.swf placeholder, right? < ---- **** YES OK .. right ...

==============================================



????????????????????????????????????

I tried the trace(_root.ex1.getDepth()); and it returns -1683 ?

now is "ex1" a movieclip u have from file2.swf, and not loading from anywhere?? what is in "ex1"?? the navigation buttons?

????????????????????????????????????


............!
explaination!
............!

1) from what it looks like u will probably has some error in the output window, u can simply write the on(rollOver) or on(rollOut) on the timeline, if that's what u are doing ... no it will not work.

2) if "ex1" is ur navigation menu, then ... it is very much depending what it looks like and what u want to do. if u can avoid having the slide1.swf (in "ex2") to go on top of "ex1" then the problem half-solved

if not ...  u can't put a button on top of ex1 ... any buttons below will not work (ie. no more navigation buttons will work)

3) if the slide.swf in the "ex2" has no interaction (ie. no button, nothing for the user to click" , u can put a button ontop of "ex2" and write script for the button.
make sure u are not writing on the main timeline, click on the button and write it for the button ...
on (rollOut) {
 // do the swapdepth
 _root.ex2.swapDepths(1000);
 _root.ex1.swapDepths(1001);
 // this will make sure ex2 is below ex1 when mouse is roll out of "ex2"
}

on (rollOver) {
 _root.ex1.swapDepths(1000); // below
 _root.ex2.swapDepths(1001); // on top
}


4) for each navigation menu .. do it the reverse way
if u have a navigation menu in "ex1" do that


on (rollOver) {
 // do the swapdepth
 _root.ex2.swapDepths(1000);
 _root.ex1.swapDepths(1001);
 // this will make sure ex1 menu is on top of the content "ex2" when user roll over the button
}

on (rollOut) { // reverse order
 _root.ex2.swapDepths(1001);
 _root.ex1.swapDepths(1000);

}

no u write actions in both ex2 & ex1 it will make sure the roll out & roll over action will work even when u are moving out of the object very fast.

cheers
0
 
ilusiAuthor Commented:
Sorry about the naming confusion.

I just learned swapDepth() can also work on movie clips, and on buttons, of course, the way you explain it.

The file2.swf that loads slide1.swf through slide20.swf is loaded into ex2 movie clip in file2.swf.

no buttons here whatsoever. and I'm using onClipEvent(mouseDown) instead of on(rollover) on the movie clip ex1 in file2.swf.

I tested a movie from rascalplants, I'll send it 2u.

I think it's probably that file1.fla loadMovieNum("slideN.swf", 1) <-- the level here: I tried -1, 0, and 50. won't work weither.

Also on file2.fla, I tried swapDepths() the ex1, and ex2 high enough adn getting the same results.
0
 
henrywwCommented:
well ... it is not something very hard.

u've just have to have a clear mind and know which one u are swapping up or down. this is very common like floating control panels ... 2 object is the simplest ... u can swap the depth with each other easily.

so it is file if u have the "ex2" with no buttons or interaction then u can put a button on it to do the job for u ... is the slide SWFs all equal size?

can u give us at least a screen cap of the movie, just to see what it looks like?

that will help to understand ur situation and determine where it goes wrong ...

cheers
0
 
henrywwCommented:
i've got the file, but it doesn't explain ur problem.

so after seeing rp's example, do u know what's wrong with ur code? can u figure out how to do with swapDepths now?

0
 
rascalpantsCommented:
I am confused...  not sure what is going on any more :)


rp
0
 
henrywwCommented:
ilusi just send ur file to me rp ... hmmmm ....
i don't know ... LOL ....

that's why i ask if he understand how to do the swapDepth with ur fla ...

if not ... maybe i should do another fla to explain then .... !
0
 
ilusiAuthor Commented:
just sent u guys some files...
0
 
henrywwCommented:
got them ... so u want me to load the make up something similar using the files u sent us?
0
 
henrywwCommented:
can u send the file with the ex1 (navigation)

how are the elements aligned?
so the file1.swf is taking up the whole screen and the ex1 will be block some by ex2 sometimes ... ?

the buttons are horizontally arranged??
0
 
ilusiAuthor Commented:
just sent u guys some files...
0
 
ilusiAuthor Commented:
henrww wrote:
can u send the file with the ex1 (navigation)

- the ex1 is the red block movie clip in swapDepth.fla

how are the elements aligned?

- ex1 (red block movie clip) is at the bottom (why anyway?)
 
so the file1.swf is taking up the whole screen and the ex1 will be block some by ex2 sometimes ... ?

- yes the file1.swf is taking up the whole screen and no, the ex1 will be block by ex2 ALWAYS.

the buttons are horizontally arranged??

- no buttons no buttons no buttons ignore the buttons, please

:)
0
 
henrywwCommented:
ok ... no buttons ... so the ex1 is navigation but no buttons ...

are u using MX or 5 // different code can be used.

u were right i was not reading carefully.
the loadMovieNum is preventing it from do the swapdepths ...
0
 
rascalpantsCommented:
you should be using the loadMovie() method and loading into a movieclip...

rp
0
 
ilusiAuthor Commented:
henrww wrote:
can u send the file with the ex1 (navigation)

- the ex1 is the red block movie clip in swapDepth.fla

how are the elements aligned?

- ex1 (red block movie clip) is at the bottom (why anyway?)
 
so the file1.swf is taking up the whole screen and the ex1 will be block some by ex2 sometimes ... ?

- yes the file1.swf is taking up the whole screen and no, the ex1 will be block by ex2 ALWAYS.

the buttons are horizontally arranged??

- no buttons no buttons no buttons ignore the buttons, please

:)
0
 
henrywwCommented:
yeah ... the loadMovieNum overrides the swapDepths i think ...
0
 
ilusiAuthor Commented:
I think I might be close to the solution here. I put a button about the size of the screen size on file1.swf. and swapDepth() on(rollover).

But, I now the problem is how can one make a transparent button?

rascalplant: sorry the files bounced back to me. exceed quota.

0
 
henrywwCommented:
done .. sent to ur yahoo ...
900+ k is that ok?


let me know if u don't get it

cheers
0
 
henrywwCommented:
arrrr .... rp didn't get the file .... ?

hey rp .. if u need a email address with more space let me know, i can give u one ... not too much say 10-20 MB ...

it might be a little slower if u are checking from US -> HK ... but ... if u need that let me know.

cheers
0
 
ilusiAuthor Commented:
Thanks a bunch Henry W

Thanks to you too RascalPlant.

Peace Out
0
 
henrywwCommented:
welcome :)
0
 
rascalpantsCommented:
rascalpants, not RascalPlant :)


rp
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 14
  • 11
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now