Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-02-2003, 10:23 AM   #1
maxdido
Registered User
 
Join Date: Apr 2003
Posts: 18
Default dynamically loading images?

who can help me with these 2 things. i downloaded the tip of the week at macromedia.com (about loading images dynamically into a movieclip) and i like to change several things. i like to trigger it from a button instead of a listbox. this i already implemented. you can download the fla file and images (82kb) at :

http://gelectronics0.tripod.com/twan/dynamically-loading-images.zip

1) what i want to do is to load the image into the movieclip and center the image in such a way that the reference point of the movieclip is in the middle of the loaded image. right now the reference point is in the top-left position.

2) i like to put a preloader in front so that people know how much percentage is done.

thanks,
max.
maxdido is offline   Reply With Quote
Old 04-02-2003, 12:05 PM   #2
avatar
Senior Member
 
avatar's Avatar
 
Join Date: May 2002
Location: Belgium - Antwerp
Posts: 456
Default

1. get the width and heigth of your MC using _width and _heigth. Than get the middle of the MC by dividing these values by 2. Reposition the MC as you like.
2. Search through the forums: loads of people already asked this question...
__________________
Cheers,
Avatar
http://www.12create.be
avatar is offline   Reply With Quote
Old 04-02-2003, 12:58 PM   #3
Lynx75
Guest
 
Posts: n/a
Default

u should use this function:

_root.total_bytes = getBytesTotal();
_root.loaded_bytes = getBytesLoaded();
percent_done = int((loaded_bytes/total_bytes)*100);

percent_done is a dynamic text field. when the user click on the single images,just call the function...

let me know..

bye
  Reply With Quote
Old 04-03-2003, 06:42 AM   #4
maxdido
Registered User
 
Join Date: Apr 2003
Posts: 18
Default

how can i know the width and height if the different images are loaded dynamically into an empty movieclip that i create with the createEmptyMovieclip action?
maxdido is offline   Reply With Quote
Old 04-03-2003, 07:00 AM   #5
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy...

You can only check the properties of the movieclip when the JPEG file is fully loaded... Try this...
ActionScript Code:
_level0.createEmptyMovieClip("holder", 100); _level0.holder.loadMovie("Collage.jpg"); _level0.onEnterFrame = function () {     if (this._width > 0)     {         trace("Loading Done..........  " + this._width + " : " + this._height);         delete this.onEnterFrame;     }     else     {         trace("Loading In Progress...  " + this._width + " : " + this._height);     } }
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 04-03-2003, 08:45 AM   #6
maxdido
Registered User
 
Join Date: Apr 2003
Posts: 18
Default

i'm not so good with actionscript, so this is a tough one for me.
this is the code i put on the button :

on (release) {
gotoAndStop(10);
// create an empty movieclip
_root.createEmptyMovieClip("jpgmovieclip", 1001);
// place the movieclip coordinates
jpgmovieclip._x = 197.7;
jpgmovieclip._y = 27.4;
// load the images in the emptymovieclip from a specified directory
jpgmovieclip.loadMovie("images/picture03.jpg");
// how to center the image over the _y in the movieclip ??
_root.jpgmovieclip.onEnterFrame = function() {
if (this._width>0) {
trace("Loading Done.......... "+this._width+" : "+this._height);
delete this.onEnterFrame;
} else {
trace("Loading In Progress... "+this._width+" : "+this._height);
}
};
}

but how do i center it? do you center the image in the movieclip or do you have to reposition the movieclip on the stage?
maxdido is offline   Reply With Quote
Old 04-03-2003, 11:11 AM   #7
avatar
Senior Member
 
avatar's Avatar
 
Join Date: May 2002
Location: Belgium - Antwerp
Posts: 456
Default

Hi maxdido,

try this:
ActionScript Code:
_root.jpgmovieclip._x = 197.7-(_root.jpgmovieclip._width/2);     _root.jpgmovieclip._y = 27.4-(_root.jpgmovieclip._height/2);
So idd you reposition the MC...

Maybe it's better to keep the AS in the thread above out of the button...
__________________
Cheers,
Avatar
http://www.12create.be
avatar is offline   Reply With Quote
Old 04-07-2003, 12:45 PM   #8
maxdido
Registered User
 
Join Date: Apr 2003
Posts: 18
Default preloading dynamically loaded images

when i preload the dynamically loaded image with this code, it works fine.

*********************************

* in frame 1 :

stop();
images._visible = false;

frame preloadit :

preload = _root.images.replacedbyimage.getBytesLoaded()+" bytes loaded of total ("+images.replacedbyimage.getBytesTotal()+")";

frame checkit :

if (_root.images.replacedbyimage.getBytesLoaded() == _root.images.replacedbyimage.getBytesTotal()) {
gotoAndPlay("doneloading");
} else {
// leave this empty and put the gotoAndPlay action in the next line behind the }
// don't ask me why, but only then the bytes are shown correct in the dynamic textfield???
}
gotoAndPlay("preloadit");

* in frame "doneloading" :

x = 200;
y = 200;
// now we get the image size
imgwidth = images._width;
imgheight = images._height;
// finally, set new _x and _y position to center the image to the centerpoint
// images._x = x-(imgwidth/2);
images._y = y-(imgheight/2);
// set the "images" movieclip visible
images._visible = true;
stop();

* the push button :

on (release) {
images.createEmptyMovieClip("replacedbyimage", 1);
images.replacedbyimage.loadMovie("image1.jpg");
gotoAndPlay("preloadit");
}


*********************************************
I want to make use of a preloader beam. not only the bytes.
but when i preload it like this, then it doesn't work and i don't have a clue why?

*********************************************

* in frame "preloadit" :

// size
total = _root.images.replacedbyimage.getBytesTotal();
loadedbytes = _root.images.replacedbyimage.getBytesLoaded();
// preloader beam, a movieclip with instance name "mcpreloading"
mcpreloading._xscale = Math.floor((loadedbytes/total)*100);
// percentage dynamic txt field
perc = mcpreloading._xscale+"%";

* in frame "checkit" :

if (total>loadedbytes) {
gotoAndPlay("preloadit");
} else {
gotoAndStop("doneloading");
}


you can check out the file at: //members.tripod.com./gelectronics0/twan/preloadit-image.zip

thanks,
max.
maxdido is offline   Reply With Quote
Old 04-14-2003, 07:44 AM   #9
avatar
Senior Member
 
avatar's Avatar
 
Join Date: May 2002
Location: Belgium - Antwerp
Posts: 456
Default

Hi there maxdido,

Sorry for the late reply. Just came back from a week in the French Alpes -> snowboarding! And it was great!

OK back to the real world...
When I make a preloader I don't put my code in frames but in a MC and use onEnterFrame.
Maybe this isn't much help but I'm just gonna run through my mails now and if you still need some help just let me know...
__________________
Cheers,
Avatar
http://www.12create.be
avatar is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading an object from an array NateVeronica ActionScript 2.0 1 03-30-2004 10:53 PM


All times are GMT. The time now is 12:29 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.