Event Handler problems MC Button issues

Okay, it’s been a while since I have used Flash and I am doing something which I know should be easy, but after a while of searching this forum and my others sources I still cannot figure it out.
Basically all I want to do is have a mc that does not show when the main movie plays, and show the mc on rollover. Very simple concept I know. It seems as though the onRollover can only be used with a button?

This is what I have- there is an instance of an mc on the stage called Illinois
On the instance of the mc I have this code:

onClipEvent (load) {
_root.Illinois._visible = false;
}
on (rollOver) {
_root.Illinois._visible = true;
}

Now, I cannot see the mc when the movie loads that part works fine. It is the on rollover behavior which I do not know how to address. It says I need an event handler with the mc. Do I have to use the mc as a button to achieve this and if not how would I do it with the mc?

Please help :block:

I think once you make something _visible = false, button events do not work.
Try
onClipEvent (load) {
_alpha = 0;
}
on (rollOver) {
_alpha = 100;
}

Thank you so much that’s it! Now all I need to do is set the on rollOut to fade it back to zero.
So I had the right idea it was setting the visible property to false that was messing me up?

Thank you so much :evil2:

Okay I need more help. I have gone this far with the same fla I was talking about before- Here is the as:

onClipEvent (load) {
_alpha = 0;
}
on (rollOver) {
_alpha = 100;
}
on (rollOut) {
_alpha = 0;
}
on (release) {
loadMovie(“question.swf”,0);
}

Now, once the person has clicked on the mc I have this code on I would like to set the alpha to 100 and make it unclickable. I have been searching through the forum on how to make a link not link once it has been click but have not found anything.

[QUOTE=jillymo]Okay I need more help. I have gone this far with the same fla I was talking about before- Here is the as:

onClipEvent (load) {
_alpha = 0;
}
on (rollOver) {
_alpha = 100;
}
on (rollOut) {
_alpha = 0;
}
on (release) {
loadMovie(“question.swf”,0);
}

to be honest i never code on buttons but on the timeline. You have to use the enabled property so if you give it an instance name btn this might work

on (release) {
loadMovie(“question.swf”,0);
btn.enabled = false;
}

there may be a better way of doing this

Well I don’t have any way of doing it so your way sounds good to me. I will give it a try and see what happens. The reason I am coding on the button/mc is cause this is going to be a US map with the 50 states selectable. I thought it would be easier to keep the code on each state rather than targeting everything through the code. I may be wrong that it is a good way to do it, but that’s how I learn. :mu:

Thanks again Stringy

the only reason I can think of that it wouldnt work is because I think I will have to set the value to false once it has been clicked…and also I will have to figure out how it will remember that once a new swf has been loaded and it goes back to that original swf. But hey tomorrow is another day :z:

Actually, jillymo, if you store all the states’ instances into an array, you can make a loop that sets all the buttons to do the same thing. I think doing this is much more efficient and worth while, not to mention finger saving. You will have to code this on the timeline though.

Sounds good, but one thing that is going to be different about each state is that they will each load a different swf. It is going to be a quiz that has a question for each state then once they answer that question that state should no longer be accessable to them. Would that still work?

I am not very advanced in as capabilities. I am try hard though and would NEVER be able to it without all the help I have had from everyone in this forum…

:party:

Well in that case you would need another array to store the different quiz .swf. It’s a little complicated if you’ve never touched upon arrays before, but nothing you cant handle.

if you label all your buttons btn1,btn2,btn3 etc and all your swfs movie1,movie2,movie3 you can do this very easily from the timeline without any need for arrays.

Well can people give me thier opinions on what would be the most efficient way? arrays vs. AS on its own layer on the timeline?

The array thing I would really have to study up on :cubs:

Niether of them are very comlicated and you may find your self using both.
Heres a quick example which might help you get started
create a button(or mc),give it a linkage identifier of btn and delete from the stage. Type this on the first frame

myArray = ;
for (i=0; i<52; i++) {
myclip = attachMovie(“btn”, “btn”+i, i);
myclip._x = random(600);
myclip._y = random(400);
minorArray = ;
//this is quite a useful thing to do
_root[“btn”+i].ivar = i;
minorArray.push(_root[“btn”+i]);
minorArray.push("Question "+i);
minorArray.push(“Answer “+i);
minorArray.push(“movie”+i+”.swf”);
myArray.push(minorArray);
delete minorArray;
myclip.onPress = function() {
trace(myArray[this.ivar]);
this.enabled = false;
};
}

I realise you are not using attachMovie but this was just for quickness, to demonstrate how useful loops/arrays can be.

Well I have used attachMovie before so that is not too foreign to me, I just thought it may get too complicated for what I was attempting to do. I am currently reading through Senocular’s lesson on OOP hoping to get a better grasp on what I am working with.
I will give your example a try and I really appreciate the help :azn:

yeh, the attachMovie part is irrelevant really, just a way to get mc`s on the Stage quickly so you can test the rest of the stuff.

Wow. I can’t believe how much that seems to accomplish in such a small amount of steps. I feel like such an ActionScript baby :crying:

One of the first things I see though is that I want each mc or button I have to have a unique shape (all the states) Could I still use this set-up along with swap symbol or something? But I guess I can’t use swap symbol too well if my mc’s aren’t actually on the stage…

I think you would be better placing them manually on the Stage and painstakingly give them all instance names but you could still save yourself a lot of work.
eg/
//mcs labelled mystate0,mystate1 etc
swfs to load called movie0.swf,movie1.swf etc
createEmptyMovieClip(“container”, 5);
for (var i = 0; i<52; i++) {
this[“myState”+i].ivar = i;
this[“myState”+i].onPress = function() {
loadMovie(“movie”+this.ivar+“.swf”, “container”);
this.enabled = false;
};
}

hmm…well I will test this out and see what happens before I ask any more questions. I do thank you for all the info you have provided so far. I am pretty amazed that it seems to be so easy to do all these things with just the AS. If only I understood it all better…someday…

Stringy!!
Do you realize that you have done what would have probably taken me like 50 hours to do?? I am so impressed and I don’t know how I could thank you enough.

:bounce: :hugegrin: (-: :beam: :sen: :angel: :sure:

Im glad it helped. Keep on looking at the Senocular tutorials, and youll soon be helping me.

Stringy- I am trying to put this code you so graciously provided me into words so that I can completely understand why it makes what I needed done work. I understand the basic idea but anyway without more bable here is what I am getting out of it:

//mcs labelled mystate0,mystate1 etc
//swfs to load called movie0.swf,movie1.swf etc
[COLOR=Navy][SIZE=1]createEmptyMovieClip(“container”, 5);
[COLOR=DarkRed]for (var i = 0; i<52; i++) {
this[“myState”+i].ivar = i;[/COLOR]
this[“myState”+i].onPress = function() {
loadMovie(“movie”+this.ivar+".swf", “container”);
this.enabled = false;
};
}[/SIZE][/COLOR]

:book: An empty movie clip called container is created on level 5 of my main movie. Now I know what this stuff in the middle (in red)does, but it’s explaining the exactness of the code that gets me. There is a variable and if it is less than 52, than an increment is added…which allows each state to be pressed once, in turn calling the function which loads an swf into the container mc, and once a state has been pressed it is disable.

Anyway, I know this is what happens but know it is missing some explanation. If you could fill in the exact words/process for me I would be so happy.