Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Preloading External Swf With Dynamic Images...



Hi i am hoping someone can help me with this problem. It is to do with preloading external swfs. I have some script which puts a preloader on external swfs that load into my main movie (which works). This is as follows...


Code:
bar._visible = false;
border._visible = false;
my_mc = new MovieClipLoader();
preload = new Object();
my_mc.addListener(preload);
preload.onLoadStart = function(targetMC) {
trace("started preloader loading "+targetMC);
loader_mc._visible = false;//an empty mc already on the main stage
bar._visible = true;
border._visible = true;
pText._visible = true;
};
preload.onLoadProgress = function(targetMC, lBytes, tBytes) {
bar._width = (lBytes/tBytes)*100;
pText.text = "Loading..."+Math.round((lBytes/tBytes)*100)+"%";
};
preload.onLoadComplete = function(targetMC) {
loader_mc._visible = true;
border._visible = false;
bar._visible = false;
pText._visible = false;
trace(targetMC+" finished preloading");
};
//default image
my_mc.loadClip("about.swf", loader_mc);
//buttons
currentStock_btn.onPress = function() {
my_mc.loadClip("scrollContent.swf",loader_mc);
};
This works but one of the swfs that is loaded in, has dynamically loaded jpegs in it. The preloader works but the loader_mc is unhidden before the dynamic jpegs have been loaded into the external swf. Ideally I would like it if I could get the preloader to keep running until the jpegs are fully loaded.

Any suggestions would be great



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 07-13-2006, 08:50 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Error Preloading External Dynamic Images
I try to load into a movie an external dinamic image like dinimage.php?source=myimage.php&width=300;

When i try this, I can note that te getbytestotal, returns me negative values like (-1) while the picture is loading.

this causes that I can't make works preloaders movies for this external movies.

I have this problem locally and remotely

Any idea ??

Preloading External Images
http://rui-camilo.de/main.html
go to this site and enter the portfolio section to see what i'm talking about.

this is the kind of effect i want to have for my site, but i don't know how they do it. i'm not sure if they're using external images or not, but i want mine to be external.

anyways, they are preloaded one by one and the little squares show the progress and you click them to load that image.

any ideas of where i should start? i have no idea.

thanks

Preloading External Images
how do i do a graphical preloader while external jpgs load?
i have a script that loads the image before placing them on the stage but need to display something while that is happening.

my script is to reposition the container on the stage after the image is loaded and the height and width are determined. after the height and width are determined it repositions the container and draws a border around the image again based on the height and width. but i am not displaying anything while that is being executed.

can someone add to this script? something like... createTextField?
i am going to paste my current function here. my container call the below function like so:

onClipEvent (data) {
_root.loadedImage();
}

below is my function:

function loadedImage() {

_root.container2.getBytesLoaded() === _root.container2.getBytesTotal()
CenterPointX = 452;
CenterPointY = 270;
container2._visible = false;
// get image size
ImgWidth = container2._width;
ImgHeight = container2._height;
// set new X and Y pos of container2 to center image to new centerpoint
container2._x = CenterPointX-(ImgWidth/2);
container2._y = CenterPointY-(ImgHeight/2);
// my first time drawing in flash. border based on image size
with (_root.container2) {
lineStyle(1, 0x666666, 100);
moveTo(-5, -5);
lineTo(-5, ImgHeight+5);
lineTo(ImgWidth+5, ImgHeight+5);
lineTo(ImgWidth+5, -5);
lineTo(-5, -5);
}
with (_root.container2) {
lineStyle(2, 0x39532D, 100);
moveTo(-8, -8);
lineTo(-8, ImgHeight+8);
lineTo(ImgWidth+8, ImgHeight+8);
lineTo(ImgWidth+8, -8);
lineTo(-8, -8);
}
container2._visible = true;
container2._alpha = 0;
container2.onEnterFrame = function() {
if (container2._alpha<100) {
container2._alpha = container2._alpha += 20;
}
}
}


i only need it for the dial up people.
my images are not larger than 40k


the site is www.chriscleveland.com

Preloading For External Images
Hi
Can you help me? How can I do a preloader for external image or movie? Is there any tutorial or something? Could you give me the adress please?
Thanks in advance

Preloading External Images...
Is there a way to preload external jpeg's (for example), so that when needed, I can display them instantly in the Flash video without waiting for them to load?

Preloading External Images
Hi peeps,
I'm trying to preload external images from a folder and they don't seem to be preloading. When I run a trace, the vars 'total' and 'loaded' come up as 4, even though the image i'm dynamically loading is larger than that. Can anyone help, or see what i'm doing wrong? I'm still kinda new to actionscript. thanks!

Also, just to make things clear, my images are loading, but they aren't being preloaded. Thanks!

Here is my code:

Code:
siteName=_root.myString;
myLabels1=new LoadVars();
//grab image filename and description
myLabels1.load("http://www.mysite.com/websites.php?do=showSite&siteName="+siteName);
myLabels1.onLoad=function(){
img=myLabels1["img"];
desc=myLabels1["desc"];
siteImg.loadMovie("http://www.mysite.com/"+img);
siteImg.onEnterFrame = function() {
loaded = siteImg.getBytesLoaded();
total = siteImg.getBytesTotal();
var percentage = Math.round(loaded / total * 100);
trace(loaded);
if (percentage>=100) {
delete this.onEnterFrame;
trace(total);
}
}
_root.contentmov.siteTitle.text=siteName;
_root.contentmov.siteDesc.text=desc;
}

Preloading External Images
I have successfully done a tutorial at Kirupa about preloaders and transitions.
http://www.kirupa.com/developer/mx/p...transition.htm

My problem is that I have a swf file that loads external jpegs and I cannot get the tutorial to work correctly with this swf. It only preloads the the swf and not the external content that this swf is calling.

Here is the code that I have on the main timeline of the home.swf


PHP Code:



var imgList:Array = new Array();
imgList[0] = "images/image00.jpg";
imgList[1] = "images/image01.jpg";
imgList[2] = "images/image02.jpg";
imgList[3] = "images/image03.jpg";
imgList[4] = "images/image04.jpg";
function chooseTheString() {
    randomPic = random(imgList.length-0);
    pics.loadMovie(imgList[randomPic]);
}
chooseTheString();
_quality = "best";
stop();




The rest of my swf files preload correctly but I just can't get it to preload this one correctly at all. I would appreciate any help that you can give.

Preloading My External Images At Once?
Hey everyone

I have an image gallery, which feeds from an XML-file. in the xml-file the target to the image is placed, and flash just loads all the pictures into the gallery that is in the XML-file.

My problem is, that I want to be able to preaload all my external images in one preloader. How can I do that??

- RUne

Preloading External Images
Hi peeps,
I'm trying to preload external images from a folder and they don't seem to be preloading. When I run a trace, the vars 'total' and 'loaded' come up as 4, even though the image i'm dynamically loading is larger than that. Can anyone help, or see what i'm doing wrong? I'm still kinda new to actionscript. thanks!

Also, just to make things clear, my images are loading, but they aren't being preloaded. Thanks!

Here is my code:

Code:
siteName=_root.myString;
myLabels1=new LoadVars();
//grab image filename and description
myLabels1.load("http://www.mysite.com/websites.php?do=showSite&siteName="+siteName);
myLabels1.onLoad=function(){
img=myLabels1["img"];
desc=myLabels1["desc"];
siteImg.loadMovie("http://www.mysite.com/"+img);
siteImg.onEnterFrame = function() {
loaded = siteImg.getBytesLoaded();
total = siteImg.getBytesTotal();
var percentage = Math.round(loaded / total * 100);
trace(loaded);
if (percentage>=100) {
delete this.onEnterFrame;
trace(total);
}
}
_root.contentmov.siteTitle.text=siteName;
_root.contentmov.siteDesc.text=desc;
}

Preloading External Images
Does anyone have any code to preload an external image

I am making a small movie with a larger image as the background

I wanted the image to be loaded externally so i could change it periodicly without having to mess about editting the flash movie

I've included a preloader for the movie but i can't get it to preload the image!

Please help!

Cheers

Sam

Preloading Many External Images
Hi there!

I'm trying to preload a gallery-type movie that has UIloaders that load several external images. I want to preload all of them before displaying them.

Right now I'm using a wrapper swf preloader because that was suggested... It loads the movie successfully but it doesn't preload it at all. Grr.

Any suggestions?

This is the wrapper. I don't THINK there are any problems with it but... Just in case

PHP Code:



import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;

function startLoad() {
    var mLoader:Loader = new Loader();
    var mRequest:URLRequest = new URLRequest("buy2.swf");
    mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
    mLoader.load(mRequest);
}

function onCompleteHandler(loadEvent:Event) {
    addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent) {
    var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
    trace(percent);
    percentbar.scaleX=percent/100
}
startLoad(); 

Preloading External Images
I've looked at many tutorials on preloading external images and followed them to set up a basic scene with just a preloader and 9 external swf files. The problem I have is that the movies start playing before the preloader has got to 100%. ie its not waiting for the preloader to finish before starting the movie.

So from what I can work out the preloader is working and the link to the external files and movie clip is working but for some reason they are not communicating with each other.

Any ideas. Im not sure if its the script on the 2nd frame of the main scene

if (this.getBytesTotal()>=this.getBytesTotal()) {
gotoAndStop(3);
} else {
gotoAndPlay(1);
}

Preloading External Images
I want to preload two .jpgs before they are placed into a movie (with loadMovie I suppose).

Is this somehow possible ?

Preloading External Images
I have successfully done a tutorial here at Kirupa about preloaders and transitions.
http://www.kirupa.com/developer/mx/p...transition.htm

My problem is that I have a swf file that loads external jpegs and I cannot get the tutorial to work correctly with this swf. It only preloads the the swf and not the external content that this swf is calling.

Here is the code that I have on the main timeline of the home.swf


PHP Code:



var imgList:Array = new Array();
imgList[0] = "images/image00.jpg";
imgList[1] = "images/image01.jpg";
imgList[2] = "images/image02.jpg";
imgList[3] = "images/image03.jpg";
imgList[4] = "images/image04.jpg";
function chooseTheString() {
    randomPic = random(imgList.length-0);
    pics.loadMovie(imgList[randomPic]);
}
chooseTheString();
_quality = "best";
stop(); 




The rest of my swf files preload correctly but I just can't get it to preload this one correctly at all. I would appreciate any help that you can give.

Preloading All External Images At Once.
Hi,

Im using a mix between xml and loadClip to dynamically load the content of a photogallery into my swf. Everything is working fine except the preloader. I know how to make a preloader for each individual image using this function:

HTML Code:
myListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number){
//blah blah
}
However for this particular project it does not matter when each individual image is loaded, but rather I need to know when the whole lot is done. Does anyone know how I can do this..... it could be that Im using the wrong approach and maybe I can solve this with some kind of a onLoad(success) type function on the xml part of the code.

Im stuck. Please help, deadlines tomorrow!

Thanks in advance,

J

Preloading External Images
I want to preload two .jpgs before they are placed into a movie (with loadMovie I suppose).

Is this somehow possible ?

Preloading External Images
Hi,
I'm creating an image gallery that zooms in and out. Basically, it loads in high res images when the user is zoomed in. I'm trying to use a preloader to let the users know the images are loading. My problem is i cannot get the preloader to work for more than 1 image. The code i have so far seems to work for just 1 image,


Code for loading images:

Code:
function startPreload (url, path) {
preloader_mc.url = url;
preloader_mc.target = path;
preloader_mc.gotoAndPlay (2);
}


function hitTestCheck () {
{
if (_root.zoomImg.z1.z1.hitTest (_root.block)) {
startPreload ("z1/1.jpg",z1.holder);
}
if (_root.zoomImg.z1.z2.hitTest (_root.block)) {
startPreload ("z1/2.jpg",z2.holder);
}
if (_root.zoomImg.z1.z3.hitTest (_root.block)) {
startPreload ("z1/3.jpg",z3.holder);
}
// there are more images, this has just been cut back for example purposes.
}
Preloader code


Code:

onEnterFrame = function(){
var bytes_loaded = this.target.getBytesLoaded();
var bytes_total = this.target.getBytesTotal();

if (bytes_total > 0){
var percent_loaded = bytes_loaded/bytes_total;
preloader_mc.value = percent_loaded;

if (percent_loaded == 1){

// running preloader
delete onEnterFrame;
play();
}
}
}
Any ideas/suggestions?

Preloading External Images From XML
Hi,

So, as the title suggest I'm having a problem preloading external images from an XML file in AS3. It's a scrolling image gallery and everything loads fine, but I can't figure out how to preload the images (all I've been able to do is preload the actual .xml file, which is useless to preload a 10k file). The thumbs skip, the big pics pause, etc.

I'm moderate in AS2 and decided to do this project in AS3(doh), and it's been painful; any help on this last part would be awesome, thanks!

Here's my code:

Code:

import flash.display.*;
import flash.events.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.filters.*;
import flash.net.*;


var container:MovieClip = new MovieClip();
var container2:MovieClip = new MovieClip();
var fullContainer:MovieClip = new MovieClip();
var copyMoved:Boolean = false;
var fadeTween:Tween;

var imageText:TextField = new TextField();

var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();

var myoverPic:MovieClip = new overPic;
var myunderPic:MovieClip = new underPic;
var backgroundCover:MovieClip = new BGMC;


xmlLoader.load(new URLRequest("images.xml"));

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

fullContainer.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

function enterFrameHandler(event:Event):void {
   
   if(!copyMoved && fullContainer.width > 0){
      container2.x += container.width+5;      
      copyMoved = true;
   }
   
   event.target.x -= 2;
   if(fullContainer.x <= -(container.width+5)){
      fullContainer.x = 0;
   }
}

function xmlLoaded(event:Event):void
{
   xml = XML(event.target.data);
   xmlList = xml.children();
      
   for(var i:int = 0; i < xmlList.length(); i++)
   {
      imageLoader = new Loader();
      imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
      imageLoader.x = i * 205;
      imageLoader.y = 0;
      imageLoader.name = xmlList[i].attribute("source");
      var _loader:DisplayObject = container.addChild(imageLoader);
      container.buttonMode = true;
      container.useHandCursor = true;
      imageLoader.addEventListener(MouseEvent.CLICK, showPicture);
   }
      
   for(i = 0; i < xmlList.length(); i++)
   {
      imageLoader = new Loader();
      imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
      imageLoader.x = i * 205;
      imageLoader.y = 0;
      imageLoader.name = xmlList[i].attribute("source");
      var _loader2:DisplayObject = container2.addChild(imageLoader);
      container2.buttonMode = true;
      container2.useHandCursor = true;
      imageLoader.addEventListener(MouseEvent.CLICK, showPicture);
   }
   
   addChild(fullContainer);
   fullContainer.addChild(container);
   fullContainer.addChild(container2);
   
   setChildIndex(myoverPic,numChildren-1);
   
}


function showPicture(event:MouseEvent):void
{
   imageLoader = new Loader();
   imageLoader.load(new URLRequest(event.target.name));
   imageLoader.x = 0;
   imageLoader.y = 0;
   addChild(imageLoader);
   addChild(myunderPic);
   imageLoader.addEventListener(MouseEvent.CLICK, removePicture);
   myunderPic.addEventListener(MouseEvent.CLICK, removePicture);
   
   
    imageText.x = 350;
   imageText.y = 195;
   for(var j:int = 0; j < xmlList.length(); j++)
   {
      if(xmlList[j].attribute("source") == event.target.name)
      {
         imageText.htmlText = xmlList[j];
         setChildIndex(imageText,numChildren-1);
      }
   }
   fadeTween = new Tween(imageLoader, "alpha", None.easeNone, 0,1,.75,true);
   
}

imageText.autoSize = TextFieldAutoSize.LEFT;
addChild(imageText);


var _over:MovieClip = MovieClip(addChild(myoverPic));
_over.mouseChildren = false;
_over.mouseEnabled = false;

addChild(backgroundCover);

function removePicture(event:MouseEvent):void
{
   addChild(backgroundCover);
   addChild(myoverPic);
   
   xmlLoader.load(new URLRequest("images.xml"));
   xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
   fullContainer.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}


{
   
   setChildIndex(imageText, numChildren-4);
   setChildIndex(backgroundCover,numChildren-3);
}

Preloading External Images
Ok, so the carousel works beautifully in my scene as a movieclip, I've sorted out all the problems - except for 1 major one.

Basically, when I run it with cntrl+enter from flash, it's perfect - but when I "simulate download" at anything other then a ridiculously fast speed (like 1000kb/s), the carousel takes AGES to show up. The 8 icons I'm using total around 1Mb in size (together, not seperately) - the .swf file is only 1.5Mb (with a 1 min soundtrack), and the loading time is roughly proportional. The issue is that I really want to load all that stuff with the preloader, rather than have people with non-super connections waiting for something to happen - and thinking that the site is just not finished and leaving before it comes up.

If there's no way to preload the images with the movie, can I somehow add a separate preloader for the movieclip containing the carousel?

If you need the .fla source file I'll post it, but they're pretty big since I haven't cleaned out unused stuff (about 19Mb at this point). Either way, my implementation of the carousel is pretty similar to the turoial one, with the images loading through an xml (which i'm guessing I need to use for preloading - but I'm really not sure how). I tried adding the images into the movie, and loading them at the start, but they load again every time I enter the carousel (even if I've already entered it once).

Thankyou very much, and I really appreciate how much you guys have done for the flash community.

Preloading External Images ?
Sup, I'm trying to preload my external images from a folder.
This is what I have:

In the main movie
I'm using a function and everytime I call it it ads a # to my
loadMovie("poze/image"+mypic+".jpg", "square");

mypic = the # that my function calls

function processClick(picId) {
loadMovie("preloader.swf", "preld");
_root.picId = picId;
}

In the preloader: (I'm using an external preloader)
so after the preloader does its thing this is supposed to happen:

stop();
mypic =_root.picId;
loadMovie("poze/image"+mypic+".jpg", "_root.square");


On the button:

on (release) {
_root.processClick(4);
} // calling the function

To see the work in progress go to www.espritstudio.com/test.html

Is there a cleaner and better way of doing this?
Your help is very much appriciated

<< Problem: Preloading External Images >>
Ok, you can dynamically load images using LoadMovie(), but you can't seem to access any of its properties, including _width, _height, or GetTotalBytes() until AFTER the file has been completely loaded.

This is my impression of how it works. Am I wrong? Is there a way to GetBytesLoaded() for dynamically loaded images?

Nick

Preloading External Images And Text
Hi,

I want to create a dynamic flash movie where all the content such as text and images is stored externally from the flash file.

What would be the best way to load all of this in the preloader. I would simply have a text file full of variables which had the content and URL's to any images used.

All I really need to know is a good way to load it all into the movie and any example code or .fla files would be appreciated. I need all the content to be ready beofre it actually is needed - so there would be no loading situations for individual images. There would be approximately 10 images but this could vary based on what is entered into the text file.

Thanks!
(I am on flash MX)

Preloading Random External Images
Here's the code I'm currently using:


Code:
maxVal = 10;

myVar=Math.round(Math.random()*maxVal);

function load_jpg_or_swf(targetMC, jpgURL) {
_root.mc_container.mtClip.loadMovie(jpgURL);
attachMovie("mc_container", "loadMC", 1000);
loadMC.loadtarget = _root.mc_container.mtClip;
loadMC.onEnterFrame = is_loaded_results;
loadMC._x = 465;
loadMC._y = 348;
}
function is_loaded_results() {
this.proportionloaded = this.loadtarget.getBytesLoaded()/this.loadtarget.getBytesTotal();
this.percentage = this.proportionloaded*100;
this.displaypercentage = Math.floor(this.percentage)+" %";
_root.loadMc.bar._xscale = Math.floor(this.percentage);
if (this.proportionloaded == 1) {
this.removeMovieClip();
}
}

_root.mc_container.onEnterFrame = function() {
yourJPGurl = "fotos/foto"+mvVar+".jpg"; //works with jpg or swf!!!
load_jpg_or_swf(mtClip, yourJPGurl);
};
The idea is for myVar to be a number from 0 to 10, and load whatever pic that is.

Then I need a little bit more code to make it wait a few seconds and then change the picture.
But after the first one, I need the preloader to vanish.

Preloading Multiple External Images
I'm creating an XML driven application (image slideshow) and I would like to preload all of the images before the slideshow begins. It'd be great if it could be done with some sort of progress bar. I have done quite a bit of research and can't seem to find any resource to show the best way of doing this.

Thank you!

Preloading External Data And Images
Hey all,

I'm a new user but read up on this board often. I did my best to search the forums and other flash sites but was unable to find a good solution to pre-loading external images.

I am not an expert by any means but I managed to build a nice home page features box for my web site. I modeled it exactly after http://entertainment.msn.com. It works perfectly on my local machine. When uploading ot a server it takes time to download each image and does not give the user a smooth experience.

I would like to pre-load ALL external text and images before the movie startings playing. Is there any way to do this?

Right now I am using all hard coded references to files. The files are located in the root directory where the flash file is. I will be switching hit an external page with variables once I get the preloading to work.

I have attached my source files. If you need any further info please let me know!

Any help would be GREATLY appreciated!


Thank you!

-Joe

Preloading External Images For Display.
Hi, I'm creating a small flash application that displays 5 images in a constantly rotating order. Ie: each fades in & out into the next one. But in order for the fade to work, they all need to be loaded at runtime, otherwise the image is still loading while the fade is taking place.

Does anyone know a way of pre-loading a group of images so that they can be displayed when called without having to load them individually?

Preloading A Folder Of External Images
I have a really annoying slide show that shows pairs of before and after pictures. What I need is to be able to preload a folder of images and then load those images into movieClip holders. I have no idea how to get the images to preload.

To be honest the whole thing is a mess. What I really wanted is a slide show that has pairs of images that fade from before to after. With buttons along the bottom that take you to the next pair of images. AND have all the images loaded in from an XML document. Bonus to anyone who can give me a hint on that one.

Really i would settle how to preload the images while the preloader is going. And then loading the first pair of slides.

Here is the in-progress version. http://www.mediamaxphotography.com/m...com/aerial.php
Attached is the fla.

Preloading Multiple External Images
Hey'a, I just need a little help with this code.
Basically I want to preload images referenced from an array into the same container_mc.

This means that when I need to show the image in the same container_mc I can just use the preloader again to display it.. As the image is already preloaded it will instantly show.

Heres the code.. Can you please help?


ActionScript Code:
stop();//Preload Arrayvar preload_array:Array = new Array();preload_array[0] = "pixeldragon.jpg";preload_array[1] = "pixeldragon2.jpg";//bar_mc Width for Bar Percentagevar bar_mc_width:Number = bar_mc._width;//Preloadermc_loader = new MovieClipLoader();preload = new Object();mc_loader.addListener(preload);preload.onLoadStart = function(targetMC) {    trace("Started Loading "+targetMC);};preload.onLoadProgress = function(targetMC, lBytes, tBytes) {    bar_mc._width = (lBytes/tBytes)*bar_mc_width;    pText.text = Math.round((lBytes/tBytes)*100)+"%";};preload.onLoadComplete = function(targetMC) {    trace("Finished Loading "+targetMC);};//Loop to preload each image one at a time.for (var i = 0; i < preload_array.length; i++) {    mc_loader.loadClip(preload_array[i], container_mc);};play();

Preloading External Images From LoadVars
Hello,

I am loading external text with the loadVars command. Within my external text, I am referencing images located in an images folder.

Currently when the page loads, there is a very noticable delay until the image loads. The text loads pretty quickly but the delay is on the images.

I need to figure out how to use the getBytesLoaded command with my loadVars command so that my external images display some sort of progress bar.

Any ideas???

Preloading Batch Of External Images
Hi. I'm relatively new to Flash/AS3 and have no idea how I'd preload a set of photos (about 20) all at once as my photography website is downloaded, or as I link from my home page to my Gallery page. I'd like them to be preloaded so that mousing over thumbnails instantly loads the main image into the loader.

I know how to load external photos via a simple URLRequest, and how to build a preloader that responds to each image individually. But how to batch preload...beyond my understanding. If possible, I'd like to do it without XML since that steepens the learning curve.

Thanks a lot!

Preloading External Images Question
hello,

what would be the best way to preload external images upfront to be used later in the movie? i would like to be able to use several instances of the image later in the movie without waiting for it to load. but i also do not want to import all the images into the library.

any advice is appreciated.

thanks!

Preloading External Images From An Array
I am trying to preload external images that I am loading into the swf file. Here is the code that I have on the main timeline.

Code:

var imgList:Array = new Array();
imgList[0] = "images/image00.jpg";
imgList[1] = "images/image01.jpg";
imgList[2] = "images/image02.jpg";
imgList[3] = "images/image03.jpg";
imgList[4] = "images/image04.jpg";
function chooseTheString() {
   randomPic = random(imgList.length-0);
   pics.loadMovie(imgList[randomPic]);
}
chooseTheString();
_quality = "best";
stop();


I would appreciate any help. :?

Preloading The Dynamic Images.
I m loading the images dynamically using flash mx. Is there any way that i can preload those images.

Also want to know how can I preload multiple swfs.

cheers
Rits

Preloading Dynamic Images
im doing my best to keep the site im working on dynamic. i have sections of content that have thumbnails that are loading dynamically based on the rollover code. they aren't that big in terms of file size but there is a little delay while they load. given that these images are 8 or 12 k each, could i just preload them somewhere and if that is a smart thing to do how would i do it?

Preloading Dynamic Images.. Serious Need Of Help Here
I got a mass amount of images that need to be preloaded dynamically.

Lets say I have 20 pictures that are all on a server.. the SWF creates a new movieClip for each one depending on how many are in the XML file..



It organizes them horizontally just fine, but some of them don't space evenly because the thumbnails haven't all downloaded, so it can't read their width and it makes them overlap..

However when I reload it, since all the thumbnails are downloaded from teh previous load, they space just fine.


So i need to find a way to preload all of these thumbnails before hand.



I tried loading them all individually into one clip then creating the line of clips after.. but they load all randomly.. it'll load like 1, 1, 1, 3, 6, 3, 8, 9, 31, 1, 3, 5, 3, 8, 9, 6, 4, .. it repeats a lot of them..

So I'm not sure where to go from here!





Code:

function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;



for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;

//thumbnails_fn(i); // this WOULD load them all in a line. but its not necessary yet because they aren't preloaded!!

thumbnail_mc.loadMovie(thumbnails[i]); //load each clip based on I statement

thumbnail_mc.onEnterFrame = function() {
var totalv = thumbnail_mc.getBytesTotal();
var loaded = thumbnail_mc.getBytesLoaded();

percent = Math.round((loaded/totalv*100)/image.length);
if (loaded == totalv && totalv > 4) {
trace(loaded);

delete this.onEnterFrame;
}

};





thumbnail_mc._alpha=0;
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images2.xml");

p = 0;
this.onEnterFrame = function() {
if (thumbnail_mc._alpha <100){
thumbnail_mc._alpha +=2;}

};

If you need it, here is the script to get them line up right!




Code:
function thumbnails_fn(k) {
b = k;
thumbnail_mc.createEmptyMovieClip("t"+k,k);
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
//target_mc._x = hit_left._x+(eval("thumbnail_mc.t"+k)._width) * k;
if ((eval("thumbnail_mc.t"+k))._width > 10){
trace(eval("thumbnail_mc.t"+k)._width);
if (k == 0)
{

target_mc._x = hit_left._x; //Offset from the border of hit_left
}
else
{
target_mc._x = hit_left._x; //Offset from the border of hit_left
for (i = 0; i < k; i++)
{

target_mc._x = target_mc._x + eval("thumbnail_mc.t"+i)._width + 5;
// trace("i = " + i + " Distance = " + target_mc._x); //Debugging information

}
}}

//
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[b], eval("thumbnail_mc.t"+b));

}


This has been driving me nuts for the past 2 days! I really need some help!!

Thanks!

Preloading Dynamic Images
Currently my movie loads dynamic images from another website whose location is retrieved from a (dynamic) XML file. Right now the images are not preloaded, and are loaded only when a user specifically clicks a button to generate them.

The button initiates a for loop that continues until it attaches a separate movieclip of all the images that were included in the XML file. The moveclip instance loads the movie in the first frame of its timeline is simply a placeholder for the image. There can be up to 60 images loaded at one time.

Now it would only make sense to preload these images, but I wasn't sure what would be the most efficient way of doing it and what would be the least demanding on a users system resources - if it even makes a difference.

My first hunch was to just run the for loop at the beginning of the movie and just hide each separate image until they are called in. But I wondered if it would be more efficient to attach and preload just 1 movie clip that includes all 60 of the images and just hide that.

In summary: Is it more efficient to attach and load a movieclip instance onto the main stage for each separate image or to attach and load 1 big moveclip instance that contains all 60 images.... or does it even make a difference? (Mainly in terms of system resources)

Or maybe there’s an even better way to do it?

Preloading Dynamic Images
Hello,
I am building an application and I am using xml to dynamically load in images. Is it possible to preload each image as it is called? I am a bit of newbie to flash so any help or advice is much appreciated

Cheers

Preloading Dynamic Images
I have a sweet little problem. In my animation, i am dynamically loading images, one per frame into a blank movie with instance name loadimage.
The problem is that each of these images is around 90-100k and it takes hell of a time to load.
I was wondering if there is a way to preload all the images before the movie is starts? Or better still preload lets say first 5 images and then continue preloading the rest of the images while the movie runs?

Preloading Dynamic Images
Morning Lads,

Having a bit of an issue here. I'm building a webcam script / component for flash but I can't get my preloader to recognize a dunamic image. I've got the timer script working and the images load on the first run. But each consecctive recycle displays the same image, it does not refresh. As well as the preloader for the images does not register an image referanced by a URL as a number of bytes to be loaded.

URL
http://www.plexusstudio.net/temp/webcam2.swf

nned some help

Preloading Dynamic Images?
Hi there, does anyone know how to preload images into Flash that are external from the SWF file. I am using non progressive jpegs and they are loading in OK, but I need them preloaded! The usual preload commands that preload frames in the SWF file do not work, as it only preloads the SWF file and not the external jpeg file.

Can this be done?

Preloading Dynamic Images
Hi guys,

I'm trying to preload some images through xml but I can't seem to get it right.

this is my function which I then use in a loop


Code:

function startLoading (whichImage, holder) {
loadMovie (whichImage,holder);
_root.onEnterFrame = function () {
infoLoaded = holder.getBytesLoaded ();
infoTotal = holder.getBytesTotal ();
trace(infoTotal);
percentage = Math.floor (infoLoaded / infoTotal * 100);
if (percentage >= 100) {
delete this.onEnterFrame;
trace("done");
}
};
}



Usage would be smt like startLoading (image[i], imgHoldr[i]);

For some reason I can't get the actual filesize of the image. It always gives me 4kb as image size. IE.. if I trace getBytesTotal it outputs = 4.

Why is this?

Thx

Preloading External Swfs & Images - Redux
I've been having trouble finding an answer to this question, and think maybe I'm not asking it right.

Basically, I want to use external swfs and external images in my movies... for example, through XML.

Yet I need a way to preload the entire movie, including those external swfs and external images. That way, there's no delay when I click on a link that calls the swf (unless it needs its own preloader).

So what is the common procedure here? If you have a series of external swfs... should each swf have its own preloader? What about larger external images... ?

Is there a way to get both the swf and image to talk to the main preloader and have it test that all of content has been loaded before entering the movie?

It was mentioned before to look at Bulk Loader, but admittedly, I find it a bit complicated for my current level. I'll continue to chip at it until I know what's going on...

Any help is appreciated.

Problem With Preloading External Images(.jpegs)
Hi guys,

One of my first posts, so point out any shortcomings in my demeanor.

I have created a flash website with a number of portfolio sections (eg.web, 3d, print etc.) The main site/timeline is a .swf, and each portfolio section is an external .swf that id loaded into an empty movie clip with the aid of a preloader. This all works fine and there are no issues.

However, within each of those portfolio .swfs is a number of links to relevant imagery of our design work. I have a preloader that runs when you load these .jpegs and it works apart form one obvious issue.

When you click on the button for the desired piece of work, the preloader (percentage and bar) pops up and, instead of starting at 0%, it reads 2147483628% for a second then drops to 0% and begins the loading process.

Now it all loads fine and my images appear after the preloader has finished, but that annoying number is really unnerving for me. It has to be fixed before I can let this site go live.

I have no idea why it is doing this as it is the same preloader that I have used for loading all the .swfs and they load fine.

I reckon its got something to do with loading .jpegs as opposed to .swfs.
I have also created and viewed this on a Mac so I don't know if this has anything to do with it.

Here is the link to the site:

http://www.momentumpacific.co.nz/test/

If you want to check out the issue, go through to anyone of the portfolio sections (video and dvd excluded as they load .swfs) and click on a button to bring up an image.

Here is the code I have on the preloader:

onClipEvent (enterFrame) {
loading = _parent.shell.getBytesLoaded();
total = _parent.shell.getBytesTotal();
percent = (loading/total)*100;
per = int(percent);
percentage = per+"%";
loadbar._width = per*1.65;
if (percent>99.5) {
_parent.preloader2._alpha = 0;
loading = 0;
}
}

And the code on the button/s:

on (release) {
loadMovie("presentations_1.jpg", shell);
}
on (release) {
loadVariables("presentations_1.txt", this);
}
on (release) {
gotoAndStop(104);
}
on (release) {
preloader2._alpha = 100;

Where "shell" is the empty movieclip for loading external .jpegs and .swfs into, and "presentations_1.txt" is some dynamic descriptor text.

Anyway I appreciate any feedback and help.

Cheers,

Enforcer73

Preloading Dynamic Images For Rollovers Please Help
ok im using dynamic images in my flash movie, i want to know if anyone can tell me how to preload my images.

thanks
atf

Preloading Dynamic Images As A Group
All the dynamic image preloader scripts I've found just pause the movie clip until the loading is complete and then play it, which is fine if you want to have a preloading pause every time you click next image, but I'd rather have everything preload at once in the beginning. I want to load a series of images for a gallery in a preloader so that I can display them seemlessly at some later point in the movie (probably in a different scene).

I know how to load external images into movie clips and check the progress of the individual clips loading so I know how to do the preloading part, but my problem is being able to reference those clips later in the movie. Since actionscript created an instance of a movieclip on the stage to put the image in like:

this.createEmptyMovieClip('holder', 1);
holder.loadMovie("myimage.jpg");

Ok, great so now I have a movie clip called 'holder' on the stage, but say I move to a new scene. How do I get that back?

createEmptyMovieClip returns a MovieClip object. Maybe I could make an array of MovieClip objects so that the objects themselves and the image inside of them persist across scenes? But then how do I place these objects back onto a blank scene?

Preloading For Dynamic Text And Images
Hi people

My flash MC has a lot of elements which are dynamically loaded using the loadMovie command. The problem is that the preloader(which shows you a percentage increasing until the movie is ready to be played) doesn't seem to take these images into account and as a result loads pretty quickly. But the images are only load up later so they kinda pop up the way HTML pages do. Anyone know a way to address this?

Fanx

Syllogism

Preloading Dynamic Images With LoadBitmapSmoothed
Hi all.

I have been working on my online portfolio lately and ran into a problem which I initially thought I had solved.
I had been loading dynamic images from an XML file into an empty MC using the 'loadMovie' function. No problems. I even had them preloading nicely using a preloader and a bit of script.
However, I wanted to be able to rotate these images, and when I did, they lost their quality. I found this was actually an issue with Flash and that it does not by default smooth externally loaded images.
To solve this, I found the below workaround script online:

Code:
import flash.display.*;

function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our
// unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(
"bmc",
target.getNextHighestDepth());

// Create a listener which will notify us when
// the bitmap loaded successfully
var listener:Object = new Object();

// Track the target
listener.tmc = target;

// If the bitmap loaded successfully we redraw the
// movie into a BitmapData object and then attach
// that BitmapData to the target movie clip with
// the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
mc._visible = false;

var bitmap:BitmapData = new BitmapData(
mc._width,
mc._height,
true);

this.tmc.attachBitmap(
bitmap,
this.tmc.getNextHighestDepth(),
"auto",
true);

bitmap.draw(mc);
};

// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}
This code works well, when used in place of the 'loadMovie()' function. I can rotate my dynamically loaded images and they retain their quality/smoothness.
However, the issue I have run into now is that my preloader no longer works with this new code.
Here's the AS for my preloader, where 'imageLoader_mc' is my MC and
'preloader_mc' is my preloader:

Code:
this.onEnterFrame = function() {
filesize = Math.floor(imageLoader_mc.getBytesTotal());
loaded = Math.floor(imageLoader_mc.getBytesLoaded());
if (loaded != filesize) {
preloader_mc._alpha = 100;
preloader_mc._rotation += 10;
imageLoader_mc._alpha = 0;
} else {
preloader_mc._alpha = 0;
if (imageLoader_mc._alpha<=100) {
imageLoader_mc._alpha += 20;
}
}
};
I think the issue is that the 'getBytesTotal()' and 'getBytesLoaded()' functions do not work with the 'loadBitmapSmoothed()' function.
Problem is, I don't know how to edit the code to allow the preloader to work.
I was wondering if anyone may be able to help me out with this?
Thanks so much,

Enforcer73

Stuck With Preloading External Images And A Prototype Loadmeter?
Hi there,

First, happy NY everyone.

Secondly, i am stuck with preloading external images. My movie is structered as follows:

1 Two scenes, preload and Scene1
2 The last frame in Scene1 has the name "end"
3 In the preload scene i have

PHP Code:



total_bytes = this.getBytesTotal();
loaded_bytes = this.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
ifFrameLoaded ("Scene 1", "end") {
    gotoAndPlay ("Scene 1", 1);





4 This is where everything goes wrong; in the first frame of Scene1 i have:

PHP Code:



//un - comment for testing purpose
dir = "test";
//dir defines the photo dir comes our param var
//path to photos
//we can make this dynamic by +dir
_global.pathToPics = "test/";
////load the photos in an array
_global.pArray = ["ph_big1.jpg", "ph_big2.jpg", "ph_big3.jpg", "ph_big4.jpg"];
//testing set loaded file equal 0
_global.loadedFile = 0;
MovieClip.prototype.loadPhoto = function () {
    // specify the movieclip to load images into
    //see array length
    for (i = 0; i < 4; i++) {
        pIndex = i;
        trace ("pIndex = " + pIndex);
        bgTest = "bg_ph" + pIndex;
        bigMov.bg["bg_ph" + pIndex].loadMovie (pathToPics + pArray[pIndex]);
        trace ("PHOTO BEING LOADED: "+pathToPics  + pArray[pIndex]);
        trace ("BGCLIP CONTAINER:  " + bgTest);
        trace ("help me " + bigMov.bg.bgTest);
        bigMov.bg["bg_ph" + pIndex].onEnterFrame = loadMeter ();
    }
};
MovieClip.prototype.loadMeter = function () {
    var l, t;
    l = this.getBytesLoaded ();
    trace ("LOADED BYTES: " + l);
    t = this.getBytesTotal ();
    trace ("TOTAL BYTES: " + t);
    trace ("this : " + this._width);
    if (t > 0 && l == t) {
        this._visible = 1;
        trace ("loaded");
        delete this.onEnterFrame;
        if (this._width > 1) {
            _global.loadedFile++;
        if (_global.loadedFile == _global.pArray.length)
        {
            trace(" Loaded all files...");
            root.gotoAndPlay("goHere");
        }
        }
    }
};
loadPhoto ();
stop(); 




Now when i look at the trace messages the ones that don't work correctly are the loaded bytes and total bytes. I know for sure that my 4 jpg's have different byte sizes, but somehow it traces "LOADED BYTES: 12789" and none of my jpg's has such a bytesize. In fact their bytesizes are: 41, 35, 37, 24 kb.

But the trace PHOTO BEING LOADED does what i thought it would do

PHP Code:



PHOTO BEING LOADED: test/ph_big1.jpg
BGCLIP CONTAINER:  bg_ph0
......
.....
PHOTO BEING LOADED: test/ph_big2.jpg
BGCLIP CONTAINER:  bg_ph1
......
etc 




So where in MovieClip.prototype.loadMeter does it go wrong??????

Grtz,

Stuck With Preloading External Images And A Prototype Loadmeter?
Hi there,

First, happy NY everyone.

Secondly, i am stuck with preloading external images. My movie is structered as follows:

1 Two scenes, preload and Scene1
2 The last frame in Scene1 has the name "end"
3 In the preload scene i have

PHP Code:



total_bytes = this.getBytesTotal();
loaded_bytes = this.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
ifFrameLoaded ("Scene 1", "end") {
    gotoAndPlay ("Scene 1", 1);





4 This is where everything goes wrong; in the first frame of Scene1 i have:

PHP Code:



//un - comment for testing purpose
dir = "test";
//dir defines the photo dir comes our param var
//path to photos
//we can make this dynamic by +dir
_global.pathToPics = "test/";
////load the photos in an array
_global.pArray = ["ph_big1.jpg", "ph_big2.jpg", "ph_big3.jpg", "ph_big4.jpg"];
//testing set loaded file equal 0
_global.loadedFile = 0;
MovieClip.prototype.loadPhoto = function () {
    // specify the movieclip to load images into
    //see array length
    for (i = 0; i < 4; i++) {
        pIndex = i;
        trace ("pIndex = " + pIndex);
        bgTest = "bg_ph" + pIndex;
        bigMov.bg["bg_ph" + pIndex].loadMovie (pathToPics + pArray[pIndex]);
        trace ("PHOTO BEING LOADED: "+pathToPics  + pArray[pIndex]);
        trace ("BGCLIP CONTAINER:  " + bgTest);
        trace ("help me " + bigMov.bg.bgTest);
        bigMov.bg["bg_ph" + pIndex].onEnterFrame = loadMeter ();
    }
};
MovieClip.prototype.loadMeter = function () {
    var l, t;
    l = this.getBytesLoaded ();
    trace ("LOADED BYTES: " + l);
    t = this.getBytesTotal ();
    trace ("TOTAL BYTES: " + t);
    trace ("this : " + this._width);
    if (t > 0 && l == t) {
        this._visible = 1;
        trace ("loaded");
        delete this.onEnterFrame;
        if (this._width > 1) {
            _global.loadedFile++;
        if (_global.loadedFile == _global.pArray.length)
        {
            trace(" Loaded all files...");
            root.gotoAndPlay("goHere");
        }
        }
    }
};
loadPhoto ();
stop(); 




Now when i look at the trace messages the ones that don't work correctly are the loaded bytes and total bytes. I know for sure that my 4 jpg's have different byte sizes, but somehow it traces "LOADED BYTES: 12789" and none of my jpg's has such a bytesize. In fact their bytesizes are: 41, 35, 37, 24 kb.

But the trace PHOTO BEING LOADED does what i thought it would do

PHP Code:



PHOTO BEING LOADED: test/ph_big1.jpg
BGCLIP CONTAINER:  bg_ph0
......
.....
PHOTO BEING LOADED: test/ph_big2.jpg
BGCLIP CONTAINER:  bg_ph1
......
etc 




So where in MovieClip.prototype.loadMeter does it go wrong??????

Grtz,

Copyright © 2005-08 www.BigResource.com, All rights reserved