Targets within loaded movies

OK,

I know this isn’t new to some but I have a main.swf and it has a target called “pageTarget”. From “main we tell page1.swf to load onto target pageTarget”. Then from main.swf we ask photo1.jpg to load onto page1.swf’s target called photoTarget.

How do I script that?

Thankshttp://www.kirupa.com/forum/images/smilies/sen.gif

Do you want the items just to automatically load when your website comes up or via the click of a button?

I assume it will be by the click of a button.

Let’s say you’ve given your button an instance name of (just to keep this really simple) button.

In your very main movie timeline you have a layer named actions. Click in the first frame of the actions layer and open your actions panel.

The following tells pageTarget to load the external movie “page1.swf” into itself.

In the panel put this code:

button.onRelease = function () {
pageTarget.loadMovie(“page1.swf”, pageTarget);
}

I assume that photo1.jpg is imported into your page1.swf’s library.

The photo1.jpg has to be first converted to a movie clip so that it can be linked from the library via Actionscript.

Drag the photo to the stage and convert it to a movie clip. Then delete it from the stage. In the library right click on the new movie clip that holds the photo and go to the linkage option. In the dialogue box that comes up click on the box Export for Actionscript. This will also automatically do two things. (1.) it will also check Export to First Frame (which is fine) and (2.) it will fill in the name section with whatever name you gave the movie clip when you created it.

Click OK.

In the main timeline of page1.swf it sounds like you already have the empty target movie clip created. (If not the code would be something like this:

this.createEmptyMovieClip(“target”, this.getNextHighestDepth());
target._x = 50;
target._y = 50;

(the x and y positions can be any number you want them to be)

then add this code to have the target movie clip attach the linked movie clip (with the photo) from the library:

target.attachMovie(“photo1.jpg”, “photo”, this.getNextHighestDepth());

The three parameters (the stuff between the ()) are: (1.) in quotes the name of the movie clip you are loading from the library as the name is in the linkage dialogue box; (2.) the second parameter is its new, unique name…in some cases, depending upon what it is you are doing, the new name should be different from the original name. In something simple like this the new name could be the same as the original name. But Flash is looking for/expects to find 3 parameters filled in in order to make this work. So even if you use the same name as the new name it still must be filled in a second time. (3.) In a Flash movie everything exists on its own depth level. For the most part - except when you want to make sure that something at one depth is higher or lower then something at another depth) you can use the this.getNextHighestDepth()

Save and publish the page1.swf so that it will load from the main movie.

As you perhaps know, make sure that everything (original main movie, the page1.swf and the photo are all in the same file folder/directory on your computer. Otherwise none of this will work as Flash cannot “guess” where the pieces you are working with might be on your computer.

I hope this helps.

[QUOTE=edgewood58;2353351]OK,

I know this isn’t new to some but I have a main.swf and it has a target called “pageTarget”. From “main we tell page1.swf to load onto target pageTarget”. Then from main.swf we ask photo1.jpg to load onto page1.swf’s target called photoTarget.

How do I script that?

Thankshttp://www.kirupa.com/forum/images/smilies/sen.gif[/QUOTE]

in short… how do I code? :stuck_out_tongue:

look at tutorials noob