# Help and Advice needed AS2 Flash CS4

**URL:** <https://forum.kirupa.com/t/help-and-advice-needed-as2-flash-cs4/308313>\
**Category:** flash\
**Created:** [April 20, 2010, 9:19pm UTC](https://forum.kirupa.com/t/help-and-advice-needed-as2-flash-cs4/308313 "2010-04-20T21:19:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![romandog](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@romandog](https://forum.kirupa.com/u/romandog)\
**Post date:** [April 20, 2010, 9:19pm UTC](https://forum.kirupa.com/t/help-and-advice-needed-as2-flash-cs4/308313/1 "2010-04-20T21:19:09Z")

</div>

Hi all,

I am using the brush transition from senocular…its great but try as I might I cannot get it to go to the next frame after the transition. I have tried giving the frame a label and adding gotoAndPlay but this is not working.

Has anyone else used this transition successfully with other movieclips?

The AS2 code looks like this:

Stage.scaleMode = ‘noScale’;

var speedfactor = 2; // integer (runs through speedfactor frames of brush animation each frame)  
// the smaller speedfactor is, the more efficient the trnasition, however, you may need  
// to increase the speed of the brush animation if you want to cover all the area of the  
// image as well as allow the transition to play at a reasonable (fast) speed  
var images = [“hil”, “mtn”, “ice”]; // linkage ID list for bitmaps to transition to and from

var imagesindex = 0; // index for position in images list  
var basepoint = new flash.geom.Point(0,0); // 0,0 point

// create bitmap instances  
var displaybmp = new flash.display.BitmapData(1024,768); //  
var transbmp = new flash.display.BitmapData(1024,768); //  
var brushbmp = new flash.display.BitmapData(1024,768, true, 0); // brush shape for whipe effect

loadTransBitmap(images[imagesindex]);  
displaybmp.draw(transbmp);

// attach brush animation which will be used to  
// brush on transbmp to displaybmp  
this.attachMovie(“brush”, “brush\_mc”, 1);  
brush\_mc.\_visible = false; // dont allow brush to be seen

this.createEmptyMovieClip(“display\_mc”,2); // create movie clip to show main bitmap  
display\_mc.attachBitmap(displaybmp, 1); // attach main bitmap

click\_mc.swapDepths(3); // show click button above others

// when the mouse is clicked, initiate the transition  
function onEnterFrame(){  
// use loadTransBitmap to set transbmp to the next  
// bitmap in the images list  
loadTransBitmap( getNextImage() );

```
// begin the transition effect
startTransition();

```

}

function getNextImage(){  
imagesindex++;  
imagesindex %= images.length;  
return images[imagesindex];  
}

function loadTransBitmap(id){  
var tempbmp = flash.display.BitmapData.loadBitmap(id);  
transbmp.copyPixels(tempbmp, tempbmp.rectangle, basepoint);  
tempbmp.dispose();  
}

function startTransition(){  
brush\_mc.gotoAndStop(1);  
drawBrushToDisplay();  
onEnterFrame = transOnEnterFrame;  
}

function transOnEnterFrame(){  
var i = speedfactor;  
while (i–){  
brush\_mc.nextFrame();  
drawBrushToDisplay();  
if (brush\_mc.\_currentframe \>= brush\_mc.\_totalframes){  
displaybmp.draw(transbmp);  
delete this.onEnterFrame;  
break;  
}  
}  
}  
function drawBrushToDisplay(){  
brushbmp.fillRect(brushbmp.rectangle,0);  
brushbmp.draw(brush\_mc);  
displaybmp.copyPixels(transbmp,transbmp.rectangle,basepoint,brushbmp,basepoint,true);  
}
