开发者

Resetting target values in a composite effect

We need to be able to handle a "playable" (play/pause/seek) effect in which the nature of the effect cannot be determined at compile time.

The problem we are running into is resetting the target(s) state after the effect has completed. If we manually drag the seek slider back to the beginning, everything works fine. However, if we set the playheadTime of the composite effect back to 0, the effected targets retain their original value until the playheadTime gets to the correct position to effect the target.

Here is a simplified (as much as I could) test case with view source enabled:

http://www.openbaseinteractive.com/_tmp/PlayableEffectTest/

The problem is demonstrated if you let it play to the end, and then hit the play button to start it over.

What is the best way to go about manually resetting the t开发者_C百科arget values given that the exact nature of the effect is unknown?

Many thanks for your time!

edit

I forgot to mention we are using Flex 4.5 preview release.


Have you tried:

effect.reverse()

More info

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/effects/IEffect.html

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/effects/IEffect.html#reverse()


Well it's a little kludgy, but I was able to accomplish this by calling some internal methods on the effect to capture the start values, then assigned those values to the targets on a reset.

import mx.core.mx_internal;
use namespace mx_internal;

private var _propertyChangesArray:Array;

protected function captureStartValues(effect:Object):void
{
    effect.captureStartValues();
    _propertyChangesArray = effect.propertyChangesArray;
}

protected function reset(effect:Object):void
{
    for each(var change:PropertyChanges in _propertyChangesArray)
    {
        var target:Object = change.target;

        for(var p:String in change.start)
        {
            if(target.hasOwnProperty(p))
            {
                var startVal:* = change.start[p];
                var endVal:* = target[p];

                if(!isNaN(startVal) && startVal != endVal)
                {
                    target[p] = startVal;
                }
            }
        }
    }

    effect.playheadTime = 0;
}

I don't know if this is the best way to accomplish this, but it seems to be working so far. I am absolutely open to suggestions for a better method.

Cheers!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜