Set movieclip default properties in flash June 26, 2008
Posted by sdpurtill in : Flash, ActionScript , trackbackI had to write a function to reset any movieclip in Flash. It’s very simple — you have an array with all the default properties you want to have in the reset. Then you pass any movieclip to the setDefaultProperties function to set the defaults. Now whenever you want to reset the movieclip, just pass it as the first parameter to resetMovieClip.
Done.
var aDefaultProps:Array = new Array('_width', '_height', '_x', '_y', '_alpha');
function setDefaultProperties(mMovieClip:MovieClip):Void {
for(sProperty in aDefaultProps) {
mMovieClip['default' + aDefaultProps[sProperty]] = mMovieClip[aDefaultProps[sProperty]];
}
}
function resetMovieClip(mMovieClip:MovieClip):Void {
for(sProperty in mMovieClip) {
if (sProperty.substr(0, 8) == 'default_') {
mMovieClip[sProperty.substr(7)] = mMovieClip[sProperty];
}
}
}
Comments»
no comments yet - be the first?