Skip to main content
Igor_R__Gomes
Known Participant
January 28, 2011
Answered

Bring obj to front with tween?

  • January 28, 2011
  • 2 replies
  • 2132 views

How can i make the obj change to front of another when the mouse roll over, and come back when out?


I look for "setChildIndex with tween" but i don't found...
This topic has been closed for replies.
Correct answer Ned Murphy

Very thankful.. just one problem, when i leave the mouse over, the animation start over and over again. Appears like horrible error.

I want, while mouse over mc, the animation start once one time.

Have any ideia how fix it?

Change MOUSE_OVER to ROLL_OVER!

Startindex its great! Thank you!

Message was edited by: Igor R. Gomes


It sounds like whatever the mouse is over is changing shape which causes it to repeatedly trigger the over and out interactions while the mouse sits there.  To fix this you will need to have some solid shape that covers the area intended for mouseover.  YOu can use a shape that has its alpha value set to 0 so that it is invisible but still reacts to mouse interaction.

2 replies

Igor_R__Gomes
Known Participant
January 28, 2011

Now:

stop();

import fl.transitions.Tween;

import fl.transitions.easing.*;

var inmageTween:Tween = new Tween(content_mc, "x", Regular.easeOut, content_mc.x, -1123.15, 1, true);

content_mc.inmage_mc.envelope_mc.envelopeB_mc.addEventListener(MouseEvent.MOUSE_OVER, OverB2F);


function OverB2F(evtObj:MouseEvent) {
    //trace ("Button Over!");
    //setChildIndex(content_mc.inmage_mc.envelope_mc.envelopeB_mc, 0);
    this.content_mc.inmage_mc.envelope_mc.envelopeB_mc.setChildIndex(1)
}

Now appears this error...

ArgumentError: Error #1063: Argument count mismatch on flash.display::DisplayObjectContainer/setChildIndex(). Expected 2, got 1.
    at siteteste_fla::MainTimeline/OverB2F()

Ned Murphy
Legend
January 29, 2011

The setChildIndex method requires two arguments.  Refer to the help documentation for details, or look at your previous attempt..

Igor_R__Gomes
Known Participant
January 28, 2011

The "Trace" works,


content_mc.inmage_mc.envelope_mc.envelopeB_mc.addEventListener(MouseEvent.MOUSE_OVER, OverB2F);
function OverB2F(evtObj:MouseEvent) {
    //trace ("Button Over!");
    setChildIndex(envelopeB_mc, 1);
}

But when i put the SetChild... appears this error.

"1120: Access of undefined property envelopeB_mc."

Ned Murphy
Legend
January 29, 2011

If you know which object you are bringing the object in front of, then you could just use swapChildren() instead of setChildIndex().

If you want to place that object atop all other content within its parent container, then you could first save its index value (for putting it back later using setChildIndex()), and then just use the addChild() method to get it in front.

Igor_R__Gomes
Known Participant
January 30, 2011

there.. what i do...


import fl.transitions.Tween;
import fl.transitions.easing.*;

var maxIndex:Number=this.numChildren -1;

//Bring to Front

card_mc.addEventListener(MouseEvent.MOUSE_OVER, OverB2F);

//Bring to Back
card_mc.addEventListener(MouseEvent.MOUSE_OUT, OutB2B);

function OverB2F(e:Event):void {
    this.setChildIndex(e.currentTarget as MovieClip, maxIndex);
    this.Tween = new Tween(e.currentTarget, "alpha", Regular.easeOut, 0, 1, 0.5, true);
}

function OutB2B(e:Event):void {
    var maxIndex:Number=this.numChildren +1;
    this.setChildIndex(e.currentTarget as MovieClip, maxIndex);
    trace ("Mouse OUT");
}

What i want..

I want, when the mouse out of card_mc, the instance_mc back to position. But did not work. The card_mc go to the front, and all time that mouse_over, they do the animation.  But they have to back to position.

Understand? (Sorry for my poor english)