A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [CS3] AS3 Creating a project with multiple .swf files

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    15

    [CS3] AS3 Creating a project with multiple .swf files

    Help would be greatly appreciated.

    I have created a series of educational activities, each of which is a seperate flash / swf file.

    I would now like to be able to create a menu from which these seperate files can be accessed.

    I am really struggling to understand how to reference the files and bring them together as a project.

    I have created a new flash file called menu, in which are a number of buttons that I hope to link to the different existing files (eg game1.swf game2.swf etc.)

    But how do I call these files from the menu?

    I have tried putting the files together in a project (menu.fl, game1.swf, game2.swf etc) but cannot figure out what to put in the menu.fl buttons eventlistener.

    I had hoped this would do it:

    PHP Code:
    level1btn.addEventListener (MouseEvent.CLICKplaygame1)
    function 
    playgame1(event:MouseEvent):void {game1.swf.gotoAndPlay(1)} 
    but alas no.

    Do I need to specify the file path of game1? Should I reference it as game1.fla?

    As you can probably tell I am completely new to this, and would really appreciate guidance.

    Thanks

  2. #2
    Jack Foster cabbar's Avatar
    Join Date
    Feb 2007
    Location
    England
    Posts
    111
    well, it's not as straight forward as that,
    you need to load your file.
    here is an example how you can load a swf file into your main,

    var box:Sprite = new Sprite;
    box.x = 0;
    box.y = 100;
    addChild(box);
    var loader = new Loader();
    var swfURLReq:URLRequest = new URLRequest("game1.swf");
    loader.load(swfURLReq);
    box.addChild(loader);

    this loads the file into a container called box, you can of course load it into MovieClip if you had one on the stage.
    then you can create listeners for your buttons to load each swf.
    This may not seem the solution you're looking for but it will give you an idea how you can load an external swf file.

    Quote Originally Posted by theobob
    Help would be greatly appreciated.

    I have created a series of educational activities, each of which is a seperate flash / swf file.

    I would now like to be able to create a menu from which these seperate files can be accessed.

    I am really struggling to understand how to reference the files and bring them together as a project.

    I have created a new flash file called menu, in which are a number of buttons that I hope to link to the different existing files (eg game1.swf game2.swf etc.)

    But how do I call these files from the menu?

    I have tried putting the files together in a project (menu.fl, game1.swf, game2.swf etc) but cannot figure out what to put in the menu.fl buttons eventlistener.

    I had hoped this would do it:

    PHP Code:
    level1btn.addEventListener (MouseEvent.CLICKplaygame1)
    function 
    playgame1(event:MouseEvent):void {game1.swf.gotoAndPlay(1)} 
    but alas no.

    Do I need to specify the file path of game1? Should I reference it as game1.fla?

    As you can probably tell I am completely new to this, and would really appreciate guidance.

    Thanks

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Posts
    15
    Thanks so much!

    I have created a movie clip on the stage and in the movie clip added this code:

    PHP Code:
    var request:URLRequest = new URLRequest("game1.swf");
    var 
    loader:Loader = new Loader()
    loader.load(request);
    addChild(loader); 
    It works a treat, thanks again.

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