I'll try this out, but I can pretty much guarantee that I used to the exact
same logic of checking with using Effect.isPlaying prior, instead of doing
what you're checking if the instance of the event exists or not. I've got
months worth of use of the following and I never got the canceling of the
events before (because right now, isPlaying of the opposite effect is never
true now).
private function onFadeOut(event:EffectEvent):void {
if (fadeIn.isPlaying) {
fadeIn.reverse();
fadeOut.end();
}
}
private function onFadeIn(event:EffectEvent):void {
if (fadeOut.isPlaying) {
fadeOut.reverse();
fadeIn.end();
}
}
On 6/25/07, Jason Szeto <[EMAIL PROTECTED]> wrote:
Jonathan,
Nothing has changed with Effect events since the hotfix. The issue that
you are running into is that our effects don't automatically reverse
themselves when the "opposite" effect is run. You have to program that
yourself. The reason that the first effect is ending is because when you
start a new effect that is affecting the same property on the same target as
a currently running effect, we end that currently running effect. Otherwise,
you'd get two effects changing the same property on the same target at the
same time.
What you want to do instead is to add in some logic to reverse the effect
based on some user action. I've included a basic example here:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
*import* mx.effects.*;
*import* mx.effects.effectClasses.*;
*import* mx.events.*;
*import* mx.core.*;
*public* *var* resizeInst:ResizeInstance;
*public* *function* handleMouse(event:MouseEvent):*void*
{
*if* (resizeInst)
resizeInst.reverse();
*else*
r.play([event.currentTarget],
event.type==MouseEvent.MOUSE_OUT);
}
</mx:Script>
<mx:Resize id="r" heightTo="100" heightFrom="22"
effectStart="resizeInst = ResizeInstance(event.effectInstance);"
effectEnd="resizeInst=*null*"/>
<mx:Button width="200" mouseOver="handleMouse(event)"
mouseOut="handleMouse(event)" />
</mx:Application>
HTH,
Jason Szeto
------------------------------
*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On
Behalf Of *Jonathan Miranda
*Sent:* Monday, June 25, 2007 3:18 PM
*To:* [EMAIL PROTECTED]; [email protected]
*Subject:* [flexcoders] What happened to events? Did Adobe affect event
code with the hotfix?
Either I'm completely missing some notice of hotfix changes, or the
effect events have changed in the last hotfix (I just finally
installed it today). I'm trying to do something very basic - when the
mouse rolls out, I want to fade out an object. When the mouse rolls
over, I want the object to fade in. If you roll back over/out while an
effect is running, I want it to end running the new event and just
*reverse* the last effect. Simple right? Not after 4 hours of drilling
at this...and here's why:
Using the hideEffect/showEffect, let's say you mouse over a button,
setting some canvas.visible=true, and it starts to fade in. Now before
it finishes, you mouse out, causing canvas.visible=false, which should
check "if fade in is playing, reverse fade in" *but* soon as
visible=false goes, the original fade in effect is canceled! Check out
the code (I've stripped out the isPlaying logic to make this easier to
see) - if you mouseOver the button and mouseOut immediately, you will
see an "EFFECT ENDED" even though I never tell it to end the original
mouseOver. Somehow changing the visible property is causing the event
to end prematurely, so isPlaying isn't true when the mouseOut event
triggers, so I can't ever reverse it! Help! Why would changing the
visible property cancel any event attached to show/hide?
I'm about 99% sure this code worked before the hotfix (SVN, gotta love
it) since I was checking for isPlaying and it would correctly reverse
the effect. Any ideas?
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.events.EffectEvent;
private function onEffectStart(event:EffectEvent):void {
trace("EFFECT STARTED:"+event.target);
trace("FadeOutPlaying:"+fadeOut.isPlaying);
trace("FadeInPlaying:"+fadeIn.isPlaying);
}
private function onEffectEnd(event:EffectEvent):void {
trace("EFFECT ENDED:"+event.target);
trace("FadeOutPlaying:"+fadeOut.isPlaying);
trace("FadeInPlaying:"+fadeIn.isPlaying);
}
]]>
</mx:Script>
<mx:Fade id="fadeOut" duration="3000" alphaTo="0.0"
effectStart="onEffectStart(event)" effectEnd="onEffectEnd(event)" />
<mx:Fade id="fadeIn" duration="3000" alphaTo="1.0"
effectStart="onEffectStart(event)" effectEnd="onEffectEnd(event)" />
<mx:Canvas id="canvas1"
x="50"
width="300" height="300"
visible="false" backgroundColor="red" backgroundAlpha="1"
hideEffect="fadeOut" showEffect="fadeIn" />
<mx:Button id="button1" rollOut="canvas1.visible = false"
rollOver="canvas1.visible = true"/>
</mx:Application>