PDA

View Full Version : myPosition="help!"


lorenz
09-08-2005, 09:17 AM
Hi guys,
I'm new here and rather new to Flash AS as well, so here we go.

I am setting up a page with 5 movie clips as the main navigation. Each movie clip has an animation of a page folding into view. At the advice of a teacher, when the page is open, I have a variable saying: myPosition="open" and when it is closed, myPosition="closed".

This is because when another MC is "open" (by pressing the necessary nav button), the other MCs should close to get out of the way.

I've tried using this script on a button:

on(press){
if(_root.instancename.myPosition="open"){
_root.instancename.play();
}

The thing is, the button doesn't seem to recognise the "open" or "closed" states of the MC and just plays them regardless.

I need to be able to say to a movie clip (in plain English): When you open, make sure the other movie clips will close (if they happen to be open).

I'd really appreciate some help here.
Thanks guys,
L.

suisei
09-08-2005, 09:53 AM
hi and welcome

first when u reference variable in an if statement use == not just the one
on(press){
if(_root.instancename.myPosition=="open"){
_root.instancename.play();


}
At the advice of a teacher, when the page is open, I have a variable saying: myPosition="open" and when it is closed, myPosition="closed".
where are u putting these variables

mayur_vnit
09-08-2005, 10:09 AM
try this :
on(press){
if(_root.instancename.myPosition+""="open"){
_root.instancename.play();
}

it converts the _root.instancename.myPosition referance to string dataType

mayur_vnit
09-08-2005, 10:11 AM
ya sorry!!!

u have to use the == opertator instead of asighnment opertator (=)

lorenz
09-08-2005, 10:20 AM
The variables are placed on a button that resides in a movie clip.

Thanks mayur_vnit, I tried it (with ==) and it didn't work.

suisei
09-08-2005, 10:25 AM
baically if ur movies are all named in order eg: page1 page2 etc
u could write

on(press){
for(i=1;i<=5;i++){
if(_root["page"+i].myPosition=="open"){
_root["page"+i].play()//or what ever u want to do to close the page
this.gotoAndPlay("open")//again however ur pages work
}
}
}

EDIT: sorry didnt copy paste correctly missed the last 2 curly braces.

lorenz
09-08-2005, 10:57 AM
I've done it like this:

This is more indicative of what I'm trying to do:

If I want to view MC2, when I click on it, it will force MC1 to shove out of the way. If I want to see MC3, then both MC1 and MC2 will move out of the way. But when I do click on another part of the navigation (say, MC4), it has to know what position the other movies are at (eg. "open" or "closed" / "in" or "out" etc) so it can then move them into place.

So, if MC1 is "out" when I click on MC5, it will not only shove MC4 out of the way, but it will also bring MC1 back "in".

That's what I'm trying to do ;)

lorenz
09-08-2005, 12:06 PM
So the question is:

What script do I put on the button that's inside a movie clip to make this happen? At least point me in the right direction!

mayur_vnit
09-08-2005, 12:12 PM
chk this attached fla.. it may help you

lorenz
09-08-2005, 12:28 PM
Thanks. It seems to work alright, though I got a lot of errors such as:

dfgdf undefined

That came up several times off one click of MC3

mayur_vnit
09-09-2005, 04:24 AM
ya i forgot to remove that trace...but i hope the fla.. solved your problem