Solved

Loading external images to Flash at run-time

Posted on 2004-10-06
3
151 Views
Last Modified: 2010-04-03
I have a map (created in Flash MX) which consist of many location node's represented by the 'square' icon (image in JPEG format, 3KB in size). It will take nearly 50 seconds to load all the icons (more than 90 icons) and display it on the map. I'm using actionscript to fetch the icons from server.
Few questions to ask here :- Hope you expert guys out there can hands the help. :)
1. What's is the best way to load all the icons in terms of  design, coding and technology wise.
2. How to make faster loading time of icons?
3. Is there any possibilities to load and save the icons(images) to local PC (using cache) for future local-loading?

Icon Table
ID      status      url      blink
1      11      yellow.jpg      1
2      12      red.jpg      1


ASP coding
---
            strSQL = "select * from map_ico"
            Set rs = objConn.Execute(strSQL)

            i = 0
                  
            While Not rs.EOF
                     Response.Write "&ico_status" & i & "=" & rs("status")& "&<br>"
                     Response.Write "&url" & i & "=" & rs("url")& "&<br>"
                     Response.Write "&blink" & i & "=" & rs("blink")& "&<br>"'add for         
                      i = i+1
                      rs.MoveNext
            Wend
      
            Response.Write "&icoNum=" & i & "&<br>"
---


Actionscript coding
----
      _root.icoUrls.splice(0);
      _root.icosNum = lvData.icoNum;
            
      for (i=0; i<lvData.icoNum; i++) {
            _root.icoUrls[i] = new icoUrlClass(lvData["ico_status" add i],lvData["url" add i],lvData["blink" add i]);
            
      }

some codes here
            for(j = 0; j<_root.icosNum; j++){
                  if(_root.icoUrls[j].status == lvData["ico" add i]){
                  
                        eval("_root.summary" add i).ico.url = _root.icoUrls[j].url;
                        eval("_root.summary" add i).ico.gotoAndStop(2);
                        
                        break;
                  }
            }

----



0
Comment
Question by:showbix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Expert Comment

by:nishasrilankan
ID: 12245554
Hi...

I think you can put all the icons in one larger Image (Lets think that icon is 10x10px in size...for 90 icons you can use larger image which contains 30cols and 30rows...and using a mask which is 10x10px..you can set the x and y of the larger image to display the relevent icon.) this will help to reduce the loading time..and  reduce the file size by 90%....if you are using just a plain square as an Icon you can use the color object to change the color of the Icon instead of the separate icons...
0
 

Author Comment

by:showbix
ID: 12245714
Hi nishasrilankan.
I'm still new to Flash and the Actionscript. Maybe you can elaborate more of your comments and if possible with examples.
0
 

Accepted Solution

by:
subhailc earned 100 total points
ID: 12455145
showbix:

unless you're times are in reference to dialup dl's, there's something wrong.  if you have only 90 images at 3kb each, it certainly shouldnt take that long to load.  i always dynamically load jpgs, and often have well in excess of a 100, which are rarely as small as you've mentioned filesize-wise.  i commonly use 380x380 as a standard size for product 'fullsize' shots, which usually run about 20-25kb.  are you sure everything's at 72dpi and that the bit depth is at 8?  i don't think thats the problem since it would be obvious (i.e., the filesize wouldn't be 3kb).

perhaps its the db import - as's xml class is plenty for what you're doing - actually LoadVars would be even better considering time since we then wouldnt incur the overhead of an xml parser - can you get the image list into a text file?  delimit them any way you want (tab, comma, space, carriage return) and put this in frame 1

m = new LoadVars();
m.load("yourtextfile.txt");
m.onData = function(r) {
      var n = [];
      n = r.split("\r\n");
      for (i=0; i<n.length; i++) {
            x=createEmptyMovieClip(n[i], i);
            x.createEmptyMovieClip("jpg",0);
            x.jpg.loadMovie(n[i]);
      }
};

course, change "yourtextfile.txt" to the appropriate filename, and i used \r and \n as delimiters; carriage returns and line stops.  if you use something else, just change what's between the quotes in that line to whatever you're using (so if you separated them with commas, you'd use n=r.split(",");)

hth, gl
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question