I am making a Flash application which will contain a series of "pages" that are placed at diffferent points of the timeline and I'm using buttons to jump to these points. I also have a Flash game which I created separately in a different file. I am wondering how I can bring this game in to use it on one of my pages? I've tried but it doesn't seem to work. Don't know if this is to do with the Actionscript?
1. create empty movie clip by ActionScript (createEmptyMovieClip method);
2. make it with it's own variables and timeline ([movie name]._lockroot = true) - it's important (!);
3. place it wherever U wish (_x and _y properties);
4. load ur game in it (loadClip method or MovieClipLoader class);
5. make it invisible if U with and appear when U need (_visible property).
OK, why it's happening: U have "empty" movie clip on 150th frame, and it's on ur timeline till frame 163. When playhead moving on 164 frame - "empty" disappearing and ur game too. To fix it U can call gotoAndStop (150) (now it's gotoAndPlay (150)).
Another variant - continue layer with "empty" mc till the end of ur timeline and on the last frame call stop ().
Last edited by Seraphim-AT; 05-05-2008 at 10:36 AM.
I added my game and it's ok on my machine; add so:
Code:
btn_fun.onPress = function() {
gotoAndStop (150);
empty._lockroot = true; // if I'm adding my game without this string - it's not working too
empty.loadMovie("[your game].swf")
};
that's brilliant. Thank you very much. Do you know how I could get my game to recognise when it's complete and then to say congratulations to the user?
1. in game create any variable "finished" = false which will become true if game finished;
2. in application do the next (on ur 150 frame, where empty movie clip inited):
Code:
var gameOverListener_mc:MovieClip = _root.createEmptyMovieClip ("gameOverListener_mc", _root.getNextHighestDepth ());
gameOverListener_mc.game_mc = empty;
gameOverListener_mc.onEnterFrame = function ():Void {
if (this.game_mc.finished) {
delete this.onEnterFrame;
_root.doSomethingFunction ();
}
}
it's an example of course, U can expand/improve it as U wish.