How do I make this code correct in different frame rate in 3 different scenes? Any examples?
Original from Actionscript 3.0 - Changing FPS for scenes won't work:
function modifyFrameRate():void {
stage.frameRate = this.currentScene.name == 'Scene 1' ? 2 : 40;
}
modifyFrameRate();
My code:
function modifyFrameRate():void {
stage.frameRate = this.currentScene.name == 'Title' ? 'Game' : 60;
stage.frameRate = this.currentScene.name == 'Intro Scene' ? 'Game' : 60;
stage.frameRate = this.currentScene.name == 'Game' ? 'Ending Scene' : 24;
}
modifyFrameRate();
The original code chooses between two modes, that's why ternary operator is used. If you have more scenes, there's much more sense to create a key:value dictionary where scene names are the keys and the frame rates are values: