I'm trying to get a sequence of Iris effects working. I think I'm this
'' close but just have one bug I can't squash. I made the following
example to post here to show what I'm doing, but unfortunately it's
not reproducing the error.

What I've got is a Canvas full of objects. At a certain point, I want
to wipe (not the effect) the canvas clean, and then re-populate it
with a few new objects. I'm doing a sequence of Iris effects to hide
the canvas, then do the processing of removing objects and adding new
ones, then use the iris effect to re-show the canvas.

The bug is, there is a delay on the iris effect when showing the
canvas. It often re-appears about halfway done, instead of the smooth
hide-and-show in this example. I thought the event handling of the
handleIrisHideEnd with the pause and resume would have taken care of
this, but it acts as if there is no pause, and the removing-and-adding
of canvas objects is happening at the same as the 2nd iris effect.

Any ideas?

Thanks

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="initApp()">
        <mx:Script>
                <![CDATA[
                        import mx.events.EffectEvent;
                        import mx.controls.Button;
                        
                        function initApp() {
                                
irisHideCanvas.addEventListener(EffectEvent.EFFECT_END,
handleIrisEnd);
                        }

                        function addImages() {
                                for(var i:int = 0; i<5; i++) {
                                        var button:Button = new Button();
                                        button.label = "Button " + i;
                                        button.x = getIntBetween(0, map.width);
                                        button.y = getIntBetween(0, map.height);
                                        map.addChild(button);
                                }
                        }
                        
                        function clearAndNew() {
                                irisSequence.play();
                        }
                        
                        // try to clear all the map's children AFTER the 
irisHideCanvas
effect is done
                        function handleIrisEnd(event:EffectEvent) {
                                irisSequence.pause();
                                map.removeAllChildren();
                                for(var i:int = 0; i < 100000; i++) {
                                        // trying to simulate long processing
                                }
                                addImages();
                                irisSequence.resume();
                        }
                        
                        // returns an int 0 <= result < top
                        function nextInt(top:int):int {
                                var temp:int = Math.round(Math.random()*1000);
                                return temp % top;
                        }
                        
                        function getIntBetween(bottom:int, top:int):int {
                                if(bottom >= top) {
                                        return bottom;
                                } else {
                                        return bottom + nextInt(10000) % 
(1+top-bottom);
                                }
                        }
                
                ]]>
        </mx:Script>
        <mx:Sequence id="irisSequence">
                <mx:Iris id="irisHideCanvas" duration="1000" showTarget="false"
target="{map}"/>
        <mx:Iris id="irisShowCanvas" duration="1000" showTarget="true"
target="{map}"/>
        </mx:Sequence>

        <mx:Canvas id="map" x="10" y="10" width="360" height="201"
backgroundColor="#000000" visible="{cb1.selected}"
                showEffect="{irisShowCanvas}" hideEffect="{irisHideCanvas}" >
        </mx:Canvas>
        <mx:Button x="58" y="219" label="Add Images" click="addImages()"/>
        <mx:Button x="160" y="219" label="Clear Images" click="clearAndNew()"/>
        <mx:CheckBox id="cb1" x="266" y="221" label="visible" selected="true"/>
        
</mx:Application>


Reply via email to