Skip to main content
Participant
December 1, 2011
Answered

Mouseover move 1 of 6 buttons to front for simple gallery

  • December 1, 2011
  • 4 replies
  • 1073 views

OK this is crazy. I have tried so many solutions and nothing seems to work. I have six images on a frame as buttons with rollovers making them expand on the button frames. The issue is when the mouse goes over they only expand over the other buttons they are above stackingwise in that layer. I really was hoping to create just a simple bit of code, but it seems that things like containers and children are all needed?

My code is thus...

dig1.addEventListener(MouseEvent.MOUSE_OVER, over1);

function over1(event:MouseEvent):void
{
addChild(event.currentTarget);
}

dig2.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig3.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig4.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig5.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig6.addEventListener(MouseEvent.MOUSE_OVER, over1);

The little line of code was my most recent attempt but it pulled up an error about things I have no clue on (1118). Is there a simple code to move the current button on top with out having to say "forget AS3!" and just make a 5 frame webpage a 60 frame one?

P.S. what is the best format to import videos into a flash project? I went with a swf version, but I was not sure if the mov or other formats would be better.

This topic has been closed for replies.
Correct answer iFlashAppsToo

//reference to the movieclip timeline the "digs" are on

var t = this;

function over1(event:MouseEvent):void{
    t. addChild(event.currentTarget);
}

dig1.addEventListener(MouseEvent.MOUSE_OVER, over1);

dig2.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig3.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig4.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig5.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig6.addEventListener(MouseEvent.MOUSE_OVER, over1);

4 replies

Inspiring
December 2, 2011

it's hard to help with this one because i dunno what you want as an end result or what your setup is...

//---

"the items stay on the screen once rolled over even on other frames"

-sounds like you don't want them on screen, so you removed them...

"but it deletes them completely until the frame is reselected"

-you don't want them on screen, right?

//---

there are several scenarios this could be happening in, each of which could have have many solutions or band-aids...

Inspiring
December 2, 2011

your main timeline has dig1-dig6

your main timeline has the code:

var t = this;

t.addChild(dig1)

t is the main timeline

the main timeline adds dig1

//---

your main timeline has a container movieclip named "container" and dig1-dig6 are inside container

your main timeline has the code:

var t = container;

t.addChild(dig1)

t is the container

the container adds dig1

//---

if dig1 is already on the stage when you addChild(dig1), it gets moved to the top of the display list (sort of like swapping it's depth to the uppermost depth)

//---

note to kglad:

you're right, it does not appear to be losing scope- but when running the code as is, it failed.

JayRootAuthor
Participant
December 2, 2011

Thanks, professor never touched on that. Ran into a new issue, the items stay on the screen once rolled over even on other frames. Added a out event to remove them from the var, but it deletes them completely until frame is reselected. (remove child)

Not sure about the overflow, will try a few more things when I get this maya project done.

Sent from my iPod

iFlashAppsTooCorrect answer
Inspiring
December 1, 2011

//reference to the movieclip timeline the "digs" are on

var t = this;

function over1(event:MouseEvent):void{
    t. addChild(event.currentTarget);
}

dig1.addEventListener(MouseEvent.MOUSE_OVER, over1);

dig2.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig3.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig4.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig5.addEventListener(MouseEvent.MOUSE_OVER, over1);
dig6.addEventListener(MouseEvent.MOUSE_OVER, over1);

JayRootAuthor
Participant
December 1, 2011

Awsome thanks that worked, can you explain what the first part was in a simple way? It seems like you are making the buttons children, is that the container thing they are talking about? What is "this"? Once I added that part if functioned perfectly.

kglad
Community Expert
Community Expert
December 1, 2011

that doesn't make sense unless you're losing scope and i don't see that.  use the trace() function to see:

function over1(event:MouseEvent):void{

trace(this.name,t.name);

    t. addChild(event.currentTarget);

}

kglad
Community Expert
Community Expert
December 1, 2011

that line of code is correct.

comment it out to verify your overflow is coming from else where.