View Full Version : to insert one flash(.swf) file into another?
Neha Shah
09-11-2008, 08:35 AM
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.
gnomeontherun
09-12-2008, 09:31 PM
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
loadMovie("external.swf", "_level0.swfHolderMC");
Delboy
11-27-2008, 11:48 AM
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...
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.
gnomeontherun
11-27-2008, 01:19 PM
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.
if (loady) {
_root.loady._x = 1000;
_root.loady._y = 1000;
}
Delboy
11-27-2008, 02:06 PM
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. :confused:
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.
gnomeontherun
11-27-2008, 02:10 PM
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).
Delboy
11-27-2008, 03:33 PM
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.
gnomeontherun
11-27-2008, 04:07 PM
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?
Delboy
11-27-2008, 06:14 PM
Ah... that would be because I made a typo... DOH!
Try this one...
http://www.rockandindie.com/ayrplay/ayrplay.zip
Del.
Delboy
11-28-2008, 01:37 PM
Hi Jeremy,
Just checking if that second link worked for you? If so, I'll remove that now.
Cheers,
Del.
gnomeontherun
11-28-2008, 02:34 PM
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.
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.
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.
Delboy
11-28-2008, 03:09 PM
Fantastic.
I'll try this now and get back to you.
Thanks Jeremy.
Like I said... owe you one.
Del.
Delboy
11-28-2008, 03:13 PM
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.
gnomeontherun
11-28-2008, 03:27 PM
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.
Delboy
11-28-2008, 04:17 PM
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.
Delboy
11-28-2008, 05:31 PM
Doh! You meant on the stage of course. I clearly need more sleep than I've been getting.
Anyway... not quite there, yet.
When I preview that, it constantly rotates through all the pages until I hit a button, then changes pages as it should do, on the respectve button clicks. However... it doesn't display the form on any of the pages, let alone the page it's supposed to display on???
I reset the x-y coordinates to those I had originally, so when it was supposed to display... it should have done so in the same place I had it.
In the compiler errors info pane it's giving me the following output:
"Mouse events are permitted only for button instances"
Does that make any sense to you? I thought they were button instances???
Del.
gnomeontherun
11-28-2008, 06:40 PM
Ok undo anything you've done back to what you had sent me. You need to make these changes in the Actions Panel, not the Library. (Press F9 to bring it up) I'll post the FLA as well on my site for you to load.
http://www.jeremywilken.com/ayrplay09-1a.fla (will remove it after you give me the word)
Delboy
11-28-2008, 08:51 PM
Ok, mate... I' back to the start, again. :)
I've got the fla you posted, exactly as my original aside from the script I had on the form layer having been removed, yes?
So... for the idiot that needs proofing against... what's next! ;)
Del.
gnomeontherun
11-28-2008, 09:00 PM
It is what you posted with my changes.
Really one of the best things you can do is to familiarize yourself with how the various parts of Flash function. There is a sticky thread at the top of this forum with tutorials, and I would look at some that help to explain the basic functionality of Flash. Its not simple! I've done this for years, but at first it was hard to learn how the parts interacted with each other.
Also, if you do tutorials (or if you get a book, which is always good too), start with new files.
Also, there are a lot of things which could ultimately improve your file, such as finding ways to reduce it from 1/3 of a MB. However these are not along this thread topic and should be other threads.
Delboy
11-28-2008, 10:44 PM
Aha! At first I was confused there, as I couldn't see where you'd placed the actions, but... now I see them, and how it works.
I should have got that long before now.
Thanks so much for your patience, Jeremy. It is genuinely appreciated. Will have to make that at least a couple of beers. ;)
I'm not planning on doing many things that require me to mess around with flash, but after that carry on... I'll definitely read a few of the tutorials to at least get the basics, instead of relying on my usual routine of just being able to figure it out by pulling it apart and putting it back together again.
Once again... Thanks!
Don't forget my offer, and keep me posted on your travel plans.
Many thanks,
Del.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.