heya ...
well couple of things i did.. cleaned ur code.. 'cause i dont like it with warnings on my flex .. :D (u dont have to do it) created a canvas outside the map.. since u are doing too many things on the map canvas . i would recommend keeping it separate from the iris effect.. also you need to end your effects effectively. i would never recommend putting a for loop to simulate a delay. there is startDelay property to make a delay. check the script below .. mebbe it solves ur problem. <?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; private function initApp():void { irisHideCanvas.addEventListener(EffectEvent.EFFECT_END, handleIrisEnd); irisShowCanvas.addEventListener(EffectEvent.EFFECT_START, handleIrisStart); irisShowCanvas.addEventListener(EffectEvent.EFFECT_END, resetAll); } private function addImages():void { for(var i:int = 0; i<50; 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); } } private function resetAll(event:EffectEvent):void { irisHideCanvas.end(); irisShowCanvas.end(); } private function clearAndNew():void { irisHideCanvas.end(); irisShowCanvas.end(); irisHideCanvas.play(); } private function handleIrisStart(event:EffectEvent):void { map.visible = true; } // try to clear all the map's children AFTER the irisHideCanvas //effect is done private function handleIrisEnd(event:EffectEvent):void { map.removeAllChildren(); map.visible = false; addImages(); irisShowCanvas.play(); } // returns an int 0 <= result < top private function nextInt(top:int):int { var temp:int = Math.round(Math.random()*1000); return temp % top; } private function getIntBetween(bottom:int, top:int):int { if(bottom >= top) { return bottom; } else { return bottom + nextInt(10000) % (1+top-bottom); } } ]]> </mx:Script> <mx:Iris id="irisHideCanvas" duration="1000" showTarget="false" target="{outerCanvas}" /> <mx:Iris id="irisShowCanvas" startDelay="500" duration="1000" showTarget="true" target="{outerCanvas}"/> <mx:Canvas id="outerCanvas"> <mx:Canvas id="map" x="10" y="10" width="360" height="201" backgroundColor="#000000" visible="{cb1.selected}" > </mx:Canvas> </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> On Mon, Mar 3, 2008 at 12:36 PM, Brian <[EMAIL PROTECTED]> wrote: > I posted this last Friday. I'm bumping to try to get you smart people > to take another look at this, earlier in the week; hope that's ok. > > > --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>, "Brian" > <[EMAIL PROTECTED]> wrote: > > > > 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> > > > > >