So I had been working on this issue where I couldn’t get a swf to reload in the same state it was originally loaded. Well further testing leads me to believe that my Model class is being persisted over multiple sessons in the player. Here is my model class:
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]private[/COLOR] [COLOR=#0000FF]static[/COLOR] [COLOR=#000000]**var**[/COLOR] _instace:ModelLocator;
[COLOR=#0000FF]public[/COLOR] [COLOR=#0000FF]static[/COLOR] [COLOR=#000000]function[/COLOR] getInstance COLOR=#000000[/COLOR]:ModelLocator [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]_instance == [COLOR=#000000]null[/COLOR] | _instance == [COLOR=#0000FF]undefined[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
_instance = [COLOR=#000000]new[/COLOR] ModelLocatorCOLOR=#000000[/COLOR];
[COLOR=#0000FF]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]‘ModelLocator new Instance’[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#0000FF]return[/COLOR] _instance;
[COLOR=#000000]}[/COLOR]
[COLOR=#0000FF]public[/COLOR] [COLOR=#0000FF]static[/COLOR] [COLOR=#000000]function[/COLOR] removeInstance COLOR=#000000[/COLOR]:[COLOR=#0000FF]Void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]if[/COLOR] [COLOR=#000000]([/COLOR]_instance != [COLOR=#000000]null[/COLOR] | _instance != [COLOR=#0000FF]undefined[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]‘destroying instance’[/COLOR][COLOR=#000000])[/COLOR];
_instance = [COLOR=#0000FF]undefined[/COLOR];
_instance = [COLOR=#000000]null[/COLOR];
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]‘no previous instance’[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[/LEFT]
[/FONT]
And somewhere on the main timeline in frame one i have:
ActionScript Code:
[FONT=Courier New][LEFT]ModelLocator.[COLOR=#000080]removeInstance[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
_model = ModelLocator.[COLOR=#000080]getInstance[/COLOR]COLOR=#000000[/COLOR];
[/LEFT]
[/FONT]
So when I fire up the swf the first time in the IDE’s player, i get ‘no previous instance’ as you would expect, then I hit ctrl + enter to restart the swf in the IDE’s player and I get ‘destroying instance’.
So this tells me that the Model instance is getting persisted over player sessions. Unless I am mistaken, and correct me if I am wrong, I would assume clicking ctrl + enter (i.e refreshing the swf in the player) would act like a new swf session.
Any thoughts?