Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    New Coder
    Join Date
    Aug 2008
    Location
    Mumbai
    Posts
    40
    Thanks
    8
    Thanked 0 Times in 0 Posts

    to insert one flash(.swf) file into another?

    Hi to all,
    Is it possible to insert 1 flash file into another?
    Basically i m having the flash file which contains only actionscripts.
    No items in liabrary.no items on stage.
    Nothing.this file I want to inert that action scripts in my another flash file.
    Is it possible?
    will the objects will be created?

    thanks in advance.

  • #2
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    This is possible, at least in the sense of being able to embed one SWF inside of another.
    Here is the code you will use to load it into a movieClip named swfHolderMC
    Code:
    loadMovie("external.swf", "_level0.swfHolderMC");
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #3
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile I solved it like this...

    Realise this is a little old, and I'm assuming you figured it out, but...

    I used the following actionscript to load a flash form into another flash document...

    Code:
    stop();
    
    ///this creates an mc to hold your swf
    
    this.createEmptyMovieClip("loady",5);
    loady._x = -60;///whatever x coordinate you want
    loady._y = -205;///whatever y coordinate you want
    
    //event that calls your load function
    loady.onEnterFrame = loadIt;
    
    ///function that loads into the mc you created
    
    function loadIt()
    {
    loady.loadMovie('entry.swf');
    
    }
    I found that elsewhere, while searching for answers to the same problem as you.

    HOWEVER... it has presented me with another problem, that I don't know how to fix, so... any help would be appreciated...

    If you look at a preview of what I'm trying to do at http://www.rockandindie.com/ayrplay/index.htm and click on the 'Enter' link in the main flash element, you'll see the page on which I've loaded one flash document into another.

    The problem is tho... once you've viewed that page, it then loads on every other page, too.

    So, how do I change the code so that it only loads when viewing that page???

    Thanks in advance.

    Del.

  • #4
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    You need to hide the movieClip somehow, because its dynamically created by Actionscript.

    So when other links are pressed they should do something like this idea,

    1. Check if the new movieClip is there
    2. If No, display page
    3. If yes, then move the clip off the stage

    There are other ways, such as removing the clip completely, but that seems like it would cause more loading for people who look around more. This code is untested, but its the idea.

    Code:
    if (loady) {
       _root.loady._x = 1000;
       _root.loady._y = 1000;
    }
    Last edited by gnomeontherun; 11-27-2008 at 02:22 PM.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #5
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile No luck. :(

    Tried that, and no luck.

    Mind you... I haven't really a clue what I'm doing.

    I've built that site purely by reverse engineering a template I found, and googling for code snippets to achieve what I was wanting to do with it.

    Thus, I just copied and pasted the code you gave me above. If I was supposed to add anything to it... I didn't.

    I am learning stuff as I go, but for the most part... actionscipt is still only marginally more coherent to me than hieroglyphics.

    Looking through the pre-set code options (it's Flash CS3 with AS3), I see there's a 'removeMovieClip' instruction in the Global Functions-Movie Clip Control menu... is that a way to do it?

    Alternatively, I have that entire loader on a layer of it's own... is it possible to make the layer only visible on the time-line where the page sits that I want it to appear on?

    Thanks for the help Jeremy.

    Del.

  • #6
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Well good to know, that code isn't just pasted in! Also as I said it was untested, because I'm not at work right now with Flash available.

    Your code is not AS3, it is AS2. So don't add that preset code.

    Can you post the FLA or the actionscript? The FLA would be best (zip it though).
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #7
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Ah, now... you've mentioned something there...

    I started this project on the office PC, using Flash 8 pro.. actionscript 2, and have now moved the project onto my laptop... Flash CS3, with actionscript 3.

    So... possible conflicts with doing that? I keep saving the file as a Flash 8 file.

    Anyway, I've put the .fla in a .zip file and uploaded it to my webspace at:

    http://www.rockandinde.com/ayrplay/ayrplay.zip

    It was too big to just attach to this post. I don't know if the .fla file contains the entire library associated with the file, if it does, then that'll explain the size of the file. With all the trial ad error I've been doing, I no longer know what is vital and surplus in the libray!

    So, it's at that link if you want to have a look at it.

    Your help is very much appreciated.

    Cheers,

    Del.

  • #8
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    There aren't conflicts if you set up to export your project as AS2, not AS3. This is done via the Publish Settings. The library contains anything you import, so that can make it very large. One of the concepts of advanced Flash is to reduce the size of the library by loading from external sources, just FYI.

    Your link doesn't work though...ideas?
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #9
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Ah... that would be because I made a typo... DOH!

    Try this one...

    http://www.rockandindie.com/ayrplay/ayrplay.zip

    Del.

  • #10
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Hi Jeremy,

    Just checking if that second link worked for you? If so, I'll remove that now.

    Cheers,

    Del.

  • #11
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    Ok found issues, mostly with the placement of the code. First, go to the Actions panel.

    You need to find the moveClip named Main Contents - and delete any code on the Layers under that clip. Then you have to scroll up and see your multiple buttons called flashmo 009. The third one is for the Enter button and put this code there. You may need to change the x and y, depending on where you want it.

    Code:
    on (release) {
    	change_page("p3");
    	
    	if (_root.loady) {
    	_root.loady._x = 400;///whatever x coordinate you want
    	_root.loady._y = 150;///whatever y coordinate you want
    	///this creates an mc to hold your swf
    	
    	}
    	else {
    		
    	this.createEmptyMovieClip("loady",5);
    	_root.loady._x = 400;///whatever x coordinate you want
    	_root.loady._y = 150;///whatever y coordinate you want
    	
    	//event that calls your load function
    	_root.loady.loadMovie('entry.swf');
    	
    	///function that loads into the mc you created
    
    	}
    }
    On the rest of the buttons put this code (of course change the change_page() for the appropriate page. Again you might need to change the x and y, to hide it enough.

    Code:
    on (release) {
    	change_page("p1");
    	if (_root.loady) {
    	   _root.loady._x = 1000;
    	   _root.loady._y = 1000;
    	}
    }
    You were putting the code onto a group of buttons, which means that every click the code was reloading and placing the entry.swf in the same place everytime. This way now it only displays it when the button for Enter is pressed, otherwise it checks if the loady movieClip is loaded and moves it.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #12
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Fantastic.

    I'll try this now and get back to you.

    Thanks Jeremy.

    Like I said... owe you one.

    Del.

  • #13
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Oh... just to be sure.. does that mean I should now delete the layer I originally created within the main content clip to hold the form?

    Del.

  • #14
    Senior Coder gnomeontherun's Avatar
    Join Date
    Sep 2007
    Location
    Houston
    Posts
    2,846
    Thanks
    10
    Thanked 238 Times in 229 Posts
    No, just alter the actionscripts as I described, the visual aspects of the file stay the same.

    I think I described everything I did, but if it doesn't work I'll load the FLA.
    jeremy - gnomeontherun
    Educated questions often get educated answers, and simple questions often get simple answers.

  • #15
    New Coder
    Join Date
    Nov 2008
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Ok... I've fallen at the first hurdle!

    In the library, I can only see one 'button' labelled flashmo009 and the 3 flashmo 009 movie clips for the graphical display of the buttons.

    I guess this is where me lack of discipline in making sure I labelled everything in the library and kept it tidy by discarding everything I didn't need... is coming back to bite me.

    So... sorry for inducing an 'idiot proof' solution, but... how am not seeing what you obviously are???

    Del.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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