Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-11-2008, 08:35 AM   PM User | #1
Neha Shah
New Coder

 
Join Date: Aug 2008
Location: Mumbai
Posts: 40
Thanks: 8
Thanked 0 Times in 0 Posts
Neha Shah is an unknown quantity at this point
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.
Neha Shah is offline   Reply With Quote
Old 09-12-2008, 09:31 PM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
gnomeontherun is offline   Reply With Quote
Old 11-27-2008, 11:48 AM   PM User | #3
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
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.
Delboy is offline   Reply With Quote
Old 11-27-2008, 01:19 PM   PM User | #4
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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;
}
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.

Last edited by gnomeontherun; 11-27-2008 at 01:22 PM..
gnomeontherun is offline   Reply With Quote
Old 11-27-2008, 02:06 PM   PM User | #5
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
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.
Delboy is offline   Reply With Quote
Old 11-27-2008, 02:10 PM   PM User | #6
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
gnomeontherun is offline   Reply With Quote
Old 11-27-2008, 03:33 PM   PM User | #7
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
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.
Delboy is offline   Reply With Quote
Old 11-27-2008, 04:07 PM   PM User | #8
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
gnomeontherun is offline   Reply With Quote
Old 11-27-2008, 06:14 PM   PM User | #9
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
Smile

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

Try this one...

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

Del.
Delboy is offline   Reply With Quote
Old 11-28-2008, 01:37 PM   PM User | #10
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
Smile

Hi Jeremy,

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

Cheers,

Del.
Delboy is offline   Reply With Quote
Old 11-28-2008, 02:34 PM   PM User | #11
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
gnomeontherun is offline   Reply With Quote
Old 11-28-2008, 03:09 PM   PM User | #12
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
Smile

Fantastic.

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

Thanks Jeremy.

Like I said... owe you one.

Del.
Delboy is offline   Reply With Quote
Old 11-28-2008, 03:13 PM   PM User | #13
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
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.
Delboy is offline   Reply With Quote
Old 11-28-2008, 03:27 PM   PM User | #14
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
gnomeontherun is offline   Reply With Quote
Old 11-28-2008, 04:17 PM   PM User | #15
Delboy
New Coder

 
Join Date: Nov 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Delboy is an unknown quantity at this point
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.
Delboy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:47 PM.


Advertisement
Log in to turn off these ads.