Hello everyone, I am making a website with three buttons on the main page, and they are movieclips with instance names box1, box2, and box3. I had my actions in the movieclips themselves, but I want to move the rollover actions to the main timeline (since I want more than one button to move after box1 is rolled over).
Anyways, the main problem is I do not know how I can target a specific movieclip.
This is my code in my main timeline:
Code:
box1.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
box1.addEventListener(MouseEvent.ROLL_OUT, manageMouseOut, false, 0, true);
function manageMouseOver(event:MouseEvent):void{
gotoAndPlay("Over");
}
function manageMouseOut(event:MouseEvent):void{
gotoAndPlay("Out");
}
My old code (worked perfect except I don't know how to make other buttons move as well as "this.") that I put in each movieclip was:
Code:
this.addEventListener(MouseEvent.ROLL_OVER, gotoOver);
function gotoOver(event:MouseEvent):void
{
gotoAndPlay("Over");
}
this.addEventListener(MouseEvent.ROLL_OUT, gotoOut);
function gotoOut(event:MouseEvent):void
{
gotoAndPlay("Out");
}
import flash.display.MovieClip;
import flash.events.MouseEvent;
box1.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
box1.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler);
box1.addEventListener(MouseEvent.CLICK, onClickHandler);
function onRollOverHandler(myEvent:MouseEvent){
box1.gotoAndPlay("Over");
}
function onRollOutHandler(myEvent:MouseEvent){
box1.gotoAndPlay("Out");
}
function onClickHandler(myEvent:MouseEvent){
box1.gotoAndPlay("Click");
box2.gotoAndPlay("Click");
box3.gotoAndPlay("Click");
}
box2.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler2);
box2.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler2);
function onRollOverHandler2(myEvent:MouseEvent){
box2.gotoAndPlay("Over");
}
function onRollOutHandler2(myEvent:MouseEvent){
box2.gotoAndPlay("Out");
}
box3.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler3);
box3.addEventListener(MouseEvent.ROLL_OUT, onRollOutHandler3);
function onRollOverHandler3(myEvent:MouseEvent){
box3.gotoAndPlay("Over");
}
function onRollOutHandler3(myEvent:MouseEvent){
box3.gotoAndPlay("Out");
}
The problem now is, for some reason, when I roll over box1, the other boxes just look like the "over" frames. They do not play the motion tween that I put to animate. I also tested not using a motion tween but the same thing happens
thats what hes saying, i just put it in laymen terms for you...
currentTarget = box1,box2,box3 ect...
im not sure what the prior event in front of the currentTarget is for or representing though...
The problem now is, for some reason, when I roll over box1, the other boxes just look like the "over" frames. They do not play the motion tween that I put to animate. I also tested not using a motion tween but the same thing happens
im confused... can you post you FLA? im sure I can point you in the right direction if Im looking at what your looking at!
Thank you guys so much for the fantastic help! I'm almost done with my scripting, but I got stuck on this.. I wanted it so that after one of the buttons were clicked (and the buttons all slide down) that a different part would be played on each button movie clip (a part where they don't slide down again). The reason I don't want them to all slide down again is because after the first click, a content box is placed above the buttons after they slide down. Please let me know if this doesn't make sense, or i'm just talking confusing.
This is my script so far:
Code:
import flash.display.*;
import flash.events.*;
//box1
box1.addEventListener(MouseEvent.ROLL_OVER, box1rollin);
box1.addEventListener(MouseEvent.ROLL_OUT, box1rollout);
//box2
box2.addEventListener(MouseEvent.ROLL_OVER, box2rollin);
box2.addEventListener(MouseEvent.ROLL_OUT, box2rollout);
//box3
box3.addEventListener(MouseEvent.ROLL_OVER, box3rollin);
box3.addEventListener(MouseEvent.ROLL_OUT, box3rollout);
//boxclicks
box1.addEventListener(MouseEvent.CLICK, box1click);
box2.addEventListener(MouseEvent.CLICK, box2click);
box3.addEventListener(MouseEvent.CLICK, box3click);
//functions roll in and outs
function box1rollin(myEvent:MouseEvent) {
box1.gotoAndPlay("Over");
}
function box1rollout(myEvent:MouseEvent) {
box1.gotoAndPlay("Out");
}
function box2rollin(myEvent:MouseEvent) {
box2.gotoAndPlay("Over");
}
function box2rollout(myEvent:MouseEvent) {
box2.gotoAndPlay("Out");
}
function box3rollin(myEvent:MouseEvent) {
box3.gotoAndPlay("Over");
}
function box3rollout(myEvent:MouseEvent) {
box3.gotoAndPlay("Out");
}
//fucntions for clicks
function box1click(event:MouseEvent) {
box1.removeEventListener(MouseEvent.ROLL_OVER, box1rollin);
box1.removeEventListener(MouseEvent.ROLL_OUT, box1rollout);
box2.removeEventListener(MouseEvent.ROLL_OVER, box2rollin);
box2.removeEventListener(MouseEvent.ROLL_OUT, box2rollout);
box3.removeEventListener(MouseEvent.ROLL_OVER, box3rollin);
box3.removeEventListener(MouseEvent.ROLL_OUT, box3rollout);
box1.gotoAndPlay("click");
box2.gotoAndPlay("click");
box3.gotoAndPlay("click");
gotoAndPlay("transition");
}
function box2click(event:MouseEvent) {
box2.removeEventListener(MouseEvent.ROLL_OVER, box2rollin);
box2.removeEventListener(MouseEvent.ROLL_OUT, box2rollout);
box1.removeEventListener(MouseEvent.ROLL_OVER, box1rollin);
box1.removeEventListener(MouseEvent.ROLL_OUT, box1rollout);
box3.removeEventListener(MouseEvent.ROLL_OVER, box3rollin);
box3.removeEventListener(MouseEvent.ROLL_OUT, box3rollout);
box2.gotoAndPlay("click");
box1.gotoAndPlay("click");
box3.gotoAndPlay("click");
gotoAndPlay("transition2");
}
function box3click(event:MouseEvent) {
box1.removeEventListener(MouseEvent.ROLL_OVER, box1rollin);
box1.removeEventListener(MouseEvent.ROLL_OUT, box1rollout);
box2.removeEventListener(MouseEvent.ROLL_OVER, box2rollin);
box2.removeEventListener(MouseEvent.ROLL_OUT, box2rollout);
box3.removeEventListener(MouseEvent.ROLL_OVER, box3rollin);
box3.removeEventListener(MouseEvent.ROLL_OUT, box3rollout);
box3.gotoAndPlay("click");
box1.gotoAndPlay("click");
box2.gotoAndPlay("click");
gotoAndPlay("transition3");
}
"I wanted it so that after one of the buttons were clicked (and the buttons all slide down) that a different part would be played on each button movie clip (a part where they don't slide down again). The reason I don't want them to all slide down again is because after the first click, a content box is placed above the buttons after they slide down."
Hey guys, thanks for all the help, my website looks great! One thing, I was trying to set up a preloader, but the problem is that it doesn't really preload everything. When i test it in any browser, its very slow at the beginning (the preloading goes fast but doesnt seem to work).
It looks like my background movieclip needs to be loaded separately or something, im not sure. That's what is making it slow though.
Sadly, i cannot upload the file since its too big (even zipped) so I will show you my script for the preloader:
Code:
import flash.display.*;
this.stop();
this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);
function PL_LOADING(event:ProgressEvent):void {
var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
bar_mc.scaleX=pcent/100;
textBox.text=int(pcent)+"%";
if(pcent==100){
this.gotoAndPlay(2);
}
}