To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 04-09-2004, 04:38 PM   #1
Jackbunny
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.
Jackbunny is offline   Reply With Quote
Old 04-09-2004, 04:47 PM   #2
jbum
Senior Member
 
jbum's Avatar
 
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
__________________
jbum is offline   Reply With Quote
Old 04-09-2004, 04:48 PM   #3
liquidfists uk
Senior Member
 
liquidfists uk's Avatar
 
Join Date: Mar 2003
Location: uk
Posts: 318
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;
}

liquidfists uk is offline   Reply With Quote
Old 04-09-2004, 04:54 PM   #4
Jackbunny
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.
Jackbunny is offline   Reply With Quote
Old 11-09-2007, 03:41 PM   #5
rjgviegas
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?
rjgviegas is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:37 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.