Link to home
Start Free TrialLog in
Avatar of Dada44
Dada44Flag for Spain

asked on

Loading a movie in a x and y position, simple but it does not work

Hi all,

I have a Flash movie with a movieclip inside called main (main has been dragged into the stage).
In main at certain frame I have:
loadMovie("teletipo.swf", 1);

Which loads teletipo.swf but in a x=0 and y=0 position. As I need it in a x=320 and y=165 position I've done:

this.createEmptyMovieClip("container", 1);
container._x =320;
container._y =165;
container.loadMovie("teletipo.swf");

But this does not load the teletipo.swf ... what am I doing wrong? How should I fix it?
Thanks a ton in advance!

Avatar of biyik
biyik

Hi!
You can try
loadMovie("teletipo.swf", container);

Avatar of Dada44

ASKER

Hi biyik, thanks for answering.
I am doing oadMovie("teletipo.swf", container); and it is not working, is not loading the movie :(
I have put the line by itself and created a movie clip called container .. but it does not work
Creating a holder movieclip is a good solution. But can't understand why your codes don't work (by the way, container.loadMovie("teletipo.swf") is same with loadMovie("teletipo.swf", container); I just wanted to try...
Avatar of Dada44

ASKER

thanks biyik .. don't know why it isn't loading the movie and if I do just loadMovie("teletipo.swf", 1); it does .. can I postion teletipo.swf from this line?
Avatar of Dada44

ASKER

I don't get it .. why loadMovie("teletipo.swf", 1) works and not the other code ??

Just in case something is bothering the main movie here's teletipo.fla (26kb)
www.vivocom.es/test/teletipo.rar

Please help me with this, I'm going nuts!!
Thanks again!
Avatar of Dada44

ASKER

Any ideas? Please I'm going nuts!!
ASKER CERTIFIED SOLUTION
Avatar of Dada44
Dada44
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The problem is that you are trying to assign an x & y value to the container before it's content exists.

You need to create a listener so once the movie starts to load and the contents exists you assign the values to it.

Below is the code, let me know if you need more info.
//Create your Container Movieclip
this.createEmptyMovieClip("container", 1);
//Create the Listener Object, it will act as the object to trigger events off
var loadcheck:Object = new Object();
//Run the event once the movie starts to load
loadcheck.onLoadInit = function(target_mc:MovieClip) {
        //target_mc is the movie you are listening for.  This allows you to reuse the listener object.
	target_mc._x = 320
	target_mc._y = 165
}
//Create a Movie Clip Loader
var loadswf:MovieClipLoader = new MovieClipLoader();
//Add the listener to the Movie Clip Loader
loadswf.addListener(loadcheck);
//Load content into the loader
//Args are (Name of Movie Clip, Movie Clip to Load into)
loadswf.loadClip("teletipo.swf", container)

Open in new window

Wow that looks a mess here is the code without the comments:
this.createEmptyMovieClip("container", 1);
var loadcheck:Object = new Object();
loadcheck.onLoadInit = function(target_mc:MovieClip) {
        target_mc._x = 320
        target_mc._y = 165
}
var loadswf:MovieClipLoader = new MovieClipLoader();
loadswf.addListener(loadcheck);
loadswf.loadClip("teletipo.swf", container)

Open in new window