Skip to main content
Participating Frequently
April 25, 2006
Answered

attachmovie twice.. it disapears.

  • April 25, 2006
  • 6 replies
  • 379 views
I have two attachmovies on different frames. And above these movies I have another "static" movie clip. I run this code first:
I want the static movie clip above everything else.
------------------------------
Frame1:
this.attachMovie(my_array[random_film], "movie1", -16368, {_x:424.5, _y:117});
---------------------------

This works the "static" movie clip is above this movieclip.. but on another frame later on I have this code:

-------------------------------------
Frame100:
this.attachMovie("pause", "movie1", -16368, {_x:424.5, _y:117});

function randRange(min, max)
{
var randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}

var paustid = randRange(15,20);
-----------------------------------------------

------------------------------------------------
Frame:103
if(firstloop != 1)
{
pauseDuration = paustid*1000;
framesInLoop = 3;
if (startTime == null) {
startTime = getTimer();
gotoAndPlay (_currentframe-framesInLoop);
} else {
lapsedTime = getTimer()-startTime;
if (lapsedTime < pauseDuration) {
gotoAndPlay (_currentframe-framesInLoop);
} else {
startTime = null;
}
}
}
-------------------------------------------------------

It loops for a few seconds and then it goes back to frame1
My problem is that the second movieclip won't load properly.. if I change the depth form -16368 to this.getNextHighestDepth() on both attachmovies it will load both movieclips but they will be above the static movieclip.. what's the deal here? How can I fix this?
This topic has been closed for replies.
Correct answer Harmeet_S__Vohra
Hi,
I have seen ur file, now do following things :-

1. make an empty movie clip and then add new layer above the Layer9
2. place empty movieclip on new layer, position of empty clip must be top left corner of the stage.
3. Now give an instance name my_mc to newly created empty clip.
4. now on start frame change the first line of code :-

_root.my_mc.attachMovie(my_array[random_film], "movie1", 1, {_x:424.5, _y:117});

5. And then delete following line of code:
movie1.swapDepths(blommor);

6. Now on Pause frame add following line in place of first line of code

_root.my_mc.attachMovie("pause", "movie1", 1, {_x:424.5, _y:117});

7. And then delete following line of code:
movie1.swapDepths(blommor);

8. Now in library, edit following movie clips:-
apmovie, automobile, faglarmovie, gubbemovie

In the last frame of movie clips replace the first line of code with following code :-
_root.gotoAndPlay("pause");

and then test ur movie.

Cheers
H

6 replies

Harmeet_S__VohraCorrect answer
Participating Frequently
April 25, 2006
Hi,
I have seen ur file, now do following things :-

1. make an empty movie clip and then add new layer above the Layer9
2. place empty movieclip on new layer, position of empty clip must be top left corner of the stage.
3. Now give an instance name my_mc to newly created empty clip.
4. now on start frame change the first line of code :-

_root.my_mc.attachMovie(my_array[random_film], "movie1", 1, {_x:424.5, _y:117});

5. And then delete following line of code:
movie1.swapDepths(blommor);

6. Now on Pause frame add following line in place of first line of code

_root.my_mc.attachMovie("pause", "movie1", 1, {_x:424.5, _y:117});

7. And then delete following line of code:
movie1.swapDepths(blommor);

8. Now in library, edit following movie clips:-
apmovie, automobile, faglarmovie, gubbemovie

In the last frame of movie clips replace the first line of code with following code :-
_root.gotoAndPlay("pause");

and then test ur movie.

Cheers
H
Urme39Author
Participating Frequently
April 25, 2006
Thanks alot!

I changed _root. to _parent._parent etc because this swf is loaded into another one.

But everything works, thanks!
Urme39Author
Participating Frequently
April 25, 2006
okey here is the source code:
http://www.urme.com/urme-flash.zip

Don't laugh at the animations
Participating Frequently
April 25, 2006
If u release source file, it will lot easier for me to fix the prob.

H
Urme39Author
Participating Frequently
April 25, 2006
Okey here it goes

I have a frame named "pause" (frame 40) and one frame named "start" (frame50).

On the first frame (frame 1) I have this AS code:

[AS]
var my_array = ["faglarmovie", "automobile", "gubbemovie", "apmovie"];
var apmovie_nr = 3;
var gubbemovie_nr = 2;
var automobile_nr = 1;
var faglarmovie_nr = 0;
var antal_movies = 4;
var firstloop = 1;
var random_film = random(antal_movies);
gotoAndPlay("start");
[/AS]

On the "Start" frame I have this code

[AS]
this.attachMovie(my_array[random_film], "movie1", this.getNextHighestDepth(), {_x:424.5, _y:117});
trace(movie1.getDepth()); //returns 0
movie1.swapDepths(blommor);
trace(movie1.getDepth()); //returns -16366
[/AS]

As you can see I load a movie with this array: my_array[random_film]. Let's say my_array[random_film] = "faglarmovie"

On the last frame of "faglarmovie" I have this code:

[AS]
_parent.gotoAndPlay("pause");
gotoAndStop(1);
[/AS]

So it jumps to Pause frame. The pause frame contains this code:

[AS]
this.attachMovie("pause", "movie1", this.getNextHighestDepth(), {_x:424.5, _y:117});
trace(movie1.getDepth()); //returns 0
movie1.swapDepths(blommor);
trace(movie1.getDepth()); //returns -16366

function randRange(min, max)
{
var randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}

var paustid = randRange(15,20);
[/AS]

The pause frame loops between 15-20 seconds.
The next frame contains this AS code for the loop:

[AS]
pauseDuration = paustid*1000;
framesInLoop = 3;
if (startTime == null) {
startTime = getTimer();
gotoAndPlay (_currentframe-framesInLoop);
} else {
lapsedTime = getTimer()-startTime;
if (lapsedTime < pauseDuration) {
gotoAndPlay (_currentframe-framesInLoop);
} else {
startTime = null;
}
}
[/AS]


My problem is that when I enter the pause frame and load the movie called "pause" it won't show if I change the depth to -16366. It's just blank. If I remove that line it will show the movieclip but then it appears above my movieclip called "blomman" that I want above everything else.

Hmm I can probably release the source file if it's necessary
Participating Frequently
April 25, 2006
Now I'm little confused about ur problem, plz. post more details regarding ur problem and also put more details about ur requirments.

H
Participating Frequently
April 25, 2006
Hi Urme39,

After loading both movie clips using getNextHighestDepth() method you can swap the depths of both movieclips. E.g :-

my_mc.swapDepths(target)

you can pass the name of first movieclip in place of my_mc and name of second movieclip in place of target.

Cheers
H
Urme39Author
Participating Frequently
April 25, 2006
Okey I swapped the depths on the movie clips like this.
"blommor" is my static movie clip.

this.attachMovie(my_array[random_film], "movie1", this.getNextHighestDepth(), {_x:424.5, _y:117});
movie1.swapDepths(blommor)
trace(movie1.getDepth()); //Outputs -16366

But I still have the same problem.. the "pause" movie disapears when I have that depth.

this.attachMovie("pause", "movie1", this.getNextHighestDepth(), {_x:424.5, _y:117});
movie1.swapDepths(blommor)
trace(movie1.getDepth()); //Outputs -16366