|
|
|
#1 |
|
Junior Member
Join Date: Jul 2002
Posts: 10
|
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. |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
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 |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Mar 2003
Location: uk
Posts: 318
|
try this
|
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jul 2002
Posts: 10
|
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.
|
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Nov 2007
Posts: 14
|
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? |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|