-
Loading External JPG -- what's wrong?
Alright I'm trying to load an external jpg. I'm using createEmptyMovieClip(Image1,1) and then Image1.loadMovie(1.jpg)
The problem is when I do _root.createEmptyMovieClip(Image1,1) and load the image it appears in the upper left hand corner of my movie, but I can't do anything with it. I try to set x and y values and it does nothing. If I do trace(Image1._x) or _y it returns undefined. So I created a container at the location I wanted it to load and did container.createEmptyMovieClip(Image1,1). When I do that I can movie the container and what not, but I don't even see the image on the image load. My eventual intent is to load the image, detect when it's loaded off screen and then scroll it on screen. When it's scrolled off screen i plan to destroy the empty movie clip. Please help. Thanks.
-
Senior Member
You were right to create a container.
This code won't work:
_root.createEmptyMovieClip("mc", 1);
mc.loadMovie("myjpeg.jpg");
mc._x = 100;
mc._y = 100;
It won't work because loadMovie works asynchronously, and wipes out the clip that is being loaded into. So after you set _x and _y, the clip gets stomped on.
This should work:
_root.createEmptyMovieClip("container", 1);
container.createEmptyMovieClip("mc", 1);
container.mc.loadMovie("myjpeg.jpg");
container._x = 100;
container._y = 100;
This works because even though container.mc gets wiped, container itself does not.
It sounds like you tried to do this, and it didn't work exactly right because of a syntax error. The above code is correct, assuming the code is executing at the _root level.
If you can't figure out your syntax error from this, post your code.
- Jim
-
Senior Member
try this
code:
//_x & _y are the co-ordinates which u wish the movie to be ok
on (release){
loadMovie ("1.jpg", "Image1");
_root.Image1._x = 0;
_root.Image1._y = 0;
}
-
Yeeeeeaaaaahhh!!!!! It works! Actually, I was doing something much more stupid than that, but looking at your code made me realize.
I did container.createEmptyMovieClip(Image1, 1)
when I SHOULD have had container.createEmptyMovieClip("Image1", 1)
darn quotes. Man that was stupid.
I pity the fool who don't use quotes.
-
Just one problem
Is it possible to load diferent size jpgs allways to the center of the movie?
For example if I use that code to load an external jpg, as other methods, they appear aligned to the top left corner of the movie. thats not a problem if you use same size pictures, but is there any code to center that loaded picture to the movie??? for example not making difference if the picture is horizontal or vertical, it allways appear on center, kind like a listener for the size of the picture?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|