ok i'll try to explain it simply and clearly. i have looked for a solution for a long time but they either didnt work and were too complicated for my little skill.
so i have a main .swf which im working on. i then have buttons which when clicked, launch a panorama. the problem is that this panorama is created with a 3rd party program and is a .swf. now. i curretly have the follwoing script to launch the panorama

on(release){
loadMovieNum ("foyer_pano.swf", _root)
}

however this opens the swf in a new tab of my web browser. now that is not too bad, but i would like and it would be much better if the panorama would open inside my current swf. i remember i managed to do this. (sorry i forgot the code for it!!!) but when this was done, it would cover all my other buttons. i tried different things with changing levels and those sort of things, but nothing seemed to worked. (i was able to display a button on top of the swf but its AS woudlnt work)

does anybody know how to do this? can someone explain it quite simply and in detail? i just want to load an swf in my project, and have a button on top of it with which i can unload this swf. (note that i cannot edit the settings of the panorama swf except for its size and dimensions and stuff, i cannot add a button or AS into it)

thank you very much for your help :)

using AS2

Recommended Answers

All 9 Replies

Assuming that the .swf for your panorama is an external .swf that you are trying to load into your main.swf...

Perhaps try something like this inside your on(release) function...

on(release)
{
	// Create a blank movieclip to load the external clip into...
	// we'll create it outside of your button in the _parent clip
	_parent.createEmptyMovieClip("external_mc", _parent.getNextHighestDepth());

	// set it's x and y coords... 
	_parent.external_mc._x=300; 
	_parent.external_mc._y=300; 

	// Now load the external .swf into the blank clip (external_mc)
	_parent.external_mc.loadMovie("foyer_pano.swf")

	// Now would be a good time to add an instance of a button to remove the panorama clip
	// we'll add it to a new layer in the parent of this button...... 
	// Note: you'll need to have your button item set up in your library so it's linkage 
	// is set to 'export for actionscript'
 
	// The code looks something like this if memory serves......
	_parent.attachMovieClip("btn_library_name", "btn_instance_name", _parent.getNextHighestDepth() [_x=50, _y=50]);

	// finally we'll set up some script on the 2nd buttons onRelease function
	// to remove the panorama and itself from the stage.
	_parent.btn_instance_name.onRelease = function()
	{
		removeMovieClip(_parent.external_mc);
		removeMovieClip(this);
	}

}

That's about the simplest thing I can come up with based on the info you've given.

If the panorama is a really large .swf that might take a while to load, you could perhaps use a MovieClipLoader. But give the above code a go first and let me know how you get on!

Cheers for now,
Jas.

p.s. I've not done any AS2 for a considerable amount of time, so I can't guarantee that the code its 100% accurate.. But I'll try to have a go at knocking up a flash 8 file to demonstrate this concept in action at some point!

thanks for your help :)
however i seem not to fully understand. sorry. so i have made a button on stage and given it the following code:

on(release)
{
_parent.createEmptyMovieClip("external_mc", _parent.getNextHighestDepth());
_parent.external_mc._x=300;
_parent.external_mc._y=300;
_parent.external_mc.loadMovie("foyer_pano.swf")
}

till there i think everything is clear. but then i get lost. what do you mean with
"// Now would be a good time to add an instance of a button to remove the panorama clip
// we'll add it to a new layer in the parent of this button......
// Note: you'll need to have your button item set up in your library so it's linkage
// is set to 'export for actionscript"?
can you please try to explain it in a bit more detail? sorry im not very good at this. im not sure whether that means im supposed to make a new button on my layer or inside the button?
and what do you mean by this "// finally we'll set up some script on the 2nd buttons onRelease function
// to remove the panorama and itself from the stage."?
please help me out :) im very happy im getting some help

Ah, yes, sorry if I confused you there...Perhaps I misunderstood something!

You said something about when the panorama had loaded, you wanted a button to appear so you could click on the button and the panorama would disappear.

So after the panorama creation code, the following code dynamically creates an additional button using a button in your movies library....

_parent.attachMovieClip("btn_library_name", "btn_instance_name", _parent.getNextHighestDepth() [_x=50, _y=50]);

Before I go much further, I'll explain a bit about the library...
You know when you click on an object and press F8 (or right click on an object and select 'convert to symbol'), you get that dialog appear asking what type of symbol you're creating (graphic, movieclip or button)??...

Whenever you do that, a new symbol is added to the library.
Whatever you enter in the 'Name:' field of the dialog is what the new symbol will be called in the library.

Now, as mentioned; with objects in the library, you can create them dynamically at runtime. So instead of dragging items out from the library and placing them onto the stage in your .FLA, you can actually create them using actionscript..

But you can't do it with any library objects by default. What you first need to do is set the appropriate linkage settings for the library items you want to create dynamically.

In order to be able create an instance of a library item using code:
Open the library
Right click on an item you want to be able to create dynamically and select 'Linkage'.
In the linkage dialog, tick the 'Export for Actionscript' box and then OK it.

Now you've got a library item that you can create using code!

Try doing this with one of the buttons that you've created and then in the above code:
Replace "btn_library_name" with the library name of the button you want to appear.
Replace "btn_instance_name" with whatever instance name you want to give your button.

So that's how you dynamically create something from the library..
Now the final bit of code from my original post overrides the new buttons on(release) function.

_parent.btn_instance_name.onRelease = function()
	{
		removeMovieClip(_parent.external_mc);
		removeMovieClip(this);
	}

What this will cause the new button to do is remove the panorama and remove itself (so when clicked, the new button gets rid of the panorama and then disappears, is gone, no more!). ;)
(Again replace "btn_instance_name" in the above code with whatever instance name you've used!)

Like I said, it may or may not be what you were after, but if not, I guess you at least learnt something new eh? heh heh!

And as mentioned before I'll try to post some simple examples at some point!
Cheers for now,
Jas.

thanks again.
i have done as you said (i think). however still no success. i have attached the files (sorry cant include the .swf into the attachement...wont let me for some reason) in both cs3 and cs4 format. i hope you can take a look at them and tell me whats wrong? (just made quick buttons. black one is supposed to load it and red one to unload it) btw notice that i used a different panorama. now named SSIS3_out.swf
however if you do need the panorama, i have uploaded it to rapidshare. you can use the link if you like to download it. its only 3.5mb
http://rapidshare.com/files/284917995/SSIS3_out.swf.html

thanks a lot.
by the way, you understood my problem perfectly :)

No probs.
I've downloaded the files, but my Wife's currently working on the windows machine. So I'm on my Linux box at the moment (no flash!), but I'll take a look at the files at some point this weekend and I'll let you know what I've come up with!

Cheers for now,
Jas.

thanks a lot for taking a look at it! :)
let me know if you figure out whats wrong.
sorry for taking up so much of your time.. but i really appreciate the help:icon_smile:

Member Avatar for rajarajan2017

Hi theonlyhugeg,

This is Raja, I am here to help you until JasonHappy come!!!

I look into your file, and I decided to create a new file in different way without going to most script part as you told that you have little knowledge in flash. Let get into the file, I had attached the source here, please try this.

Actually the problem is in the loaded swf (ie. SSIS3_out.swf) . This swf occupy the whole space of your main timeline by the script written in that swf file (which is not able to see or edit?). The trick is to resize the loaded swf into your main timeline, so you can ultilize the button part to load and unload the SSIS3_out.swf.

My source has the following functionalities:

Layers:
placeholder : An empty movieclip positioned in x:0, y:0 and with the name instance name empty_mc
load, unload: Two buttons with the instance name load_btn and unload_btn
trick: An empty movieclip with the instance name dummy_mc
text: Just for fun, to surprise you

load_btn:
on (release)
{
	loadMovie("SSIS3_out.swf","_level1")
	_root.load_btn._visible=false;
	_root.unload_btn._visible=true;
	_root.txt_mc._visible=false;
}
unload_btn:
on (release)
{
	unloadMovie("_level1");
	_root.load_btn._visible=true;
	_root.unload_btn._visible=false;
	_root.txt_mc._visible=true;
}
dummy_mc
onClipEvent(enterFrame){
	_level1._xscale = 100;
	_level1._yscale = 90;
}

make adjustment as you need

Note: I had attached only fla and published swf, please paste your
SSIS3_out.swf in the same location.

Please tell me, if you have any details. Hope this solve!!!

thanks rajarajan! your method works and with some changes i was able to use it for my virtual tour. thanks a lot.
thanks a lot also to jasonhippy for your help. feel welcome to still post your solution if you have already worked one out. it would be interesting to see how this problem can be approached in different ways. and also some people out there may need one way or another.
anyway thanks a lot guys for your help :)

Sorry, had a manic weekend and a long week at work this week!

Still not had a chance to get onto the ol' desktop at home to fire up CS3 yet.

But from what I can see of Raja's solution, it looks pretty good. But I'm determined to take a look at your files at some point!
If/when I do, I'll post anything I come up with.

Cheers for now,
Jas.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.