A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: combining two flash files

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    11

    combining two flash files

    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?

  2. #2
    Junior Member
    Join Date
    Apr 2008
    Posts
    19
    Make an empty clip, name it and put it on the scene where you want the game to show.

    Then, when you press the game button or what ever, do a gotoAndPlay to your game page (where the empty movie clip is). After gotoAndPlay(), put:

    "name of the empty movie you created".loadMovie("name of your game's swf.swf")

    So you have to export your game in a swf, and put it in the same folder than your main .fla .

    It should work

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    yeah it does load in my other file. only thing is that it comes up for about ten seconds then disappears.

  4. #4
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    oh and the file i've brought in is a game so i dunno how to make it work as a game?

  5. #5
    Member
    Join Date
    Mar 2008
    Posts
    31
    hi, as for me, it's much easier to:

    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).

  6. #6
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    well its loading in fine but it wont let me interact with the game?!

  7. #7
    Member
    Join Date
    Mar 2008
    Posts
    31
    OK, send source (fla) file to me which loading external swf please, I'll look into and explain to U.

  8. #8
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    here's the .fla
    Attached Files Attached Files

  9. #9
    Member
    Join Date
    Mar 2008
    Posts
    31
    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.

  10. #10
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    ok now it stays but it will not let me play the game

  11. #11
    Member
    Join Date
    Mar 2008
    Posts
    31
    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")
    };

  12. #12
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    okay so now it loads my game and it stays on screen. it scrambles the pieces in my game but it wont let me play the game.

  13. #13
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    here is my game file
    Attached Files Attached Files

  14. #14
    Member
    Join Date
    Mar 2008
    Posts
    31
    Check it please. Problem was in wrong hit test, if ur game is a part of any external file and have it's own root, hit test must check _level0 anyway.
    Attached Files Attached Files

  15. #15
    Junior Member
    Join Date
    Apr 2008
    Posts
    11
    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?

  16. #16
    Member
    Join Date
    Mar 2008
    Posts
    31
    U need:

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center