Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-24-2004, 01:44 PM   #1
designlevel2
Registered User
 
Join Date: Mar 2004
Posts: 19
Default Help Remoting Array

Ok I have a remoting project that needs to load about 50 images per swf. I have the whole thing working, but now im running into preloading issues.

That being said I am readdressing how to achieve this. I think what I need to do is bring all of the file names into a local array, then use setInterval to load them. I have this working fine statically but when I populate the array with remoting it screws up and doesnt work. My question is how do I populate an array locally. Here's my static code that does work:

ActionScript Code:
k=0; myDummyArray = ['images/naveen.jpg', 'images/cn4.jpg', 'images/mu_med.jpg', 'images/rb_med.jpg']; i = 0; //ArrayAll = (myDummyArray[0]+", "+myDummyArray[1]+", "+myDummyArray[2]); ArrayAll = (myDummyArray[0]+", "+myDummyArray[1]+", "+myDummyArray[2]+", "+myDummyArray[3]+", "+myDummyArray[4]); totaljpgs = 4; for(i=0;i<=totaljpgs;i++){ rclip=_root.createEmptyMovieClip("MyClip"+i,i); rclip.loadMovie(myDummyArray[i]); rclip._x = (100*i); rclip._y = 300; //rclip.loadMovie("images/cn1.jpg"); } function loadtotalfunction(){ for(i=1;i<=totaljpgs;i++){ total=_root["MyClip"+i].getBytesTotal(); //} //clearInterval(loadtotalinterval); preloadinterval=setInterval(preloadfunction,10); } } function preloadfunction(){ for(i=1;i<=totaljpgs;i++){ loaded=_root["MyClip"+i].getBytesLoaded(); } fractionloaded=(loaded/total); //percentloaded=loaded; if (fractionloaded>0){ percentloaded=math.floor(100*fractionloaded)+" %"; } if(fractionloaded>=1){ clearInterval(preloadinterval); } } loadtotalinterval=setInterval(loadtotalfunction,10);


Thanks in advance.
designlevel2 is offline   Reply With Quote
Old 04-13-2004, 06:28 PM   #2
petefs
Fried Onions
 
petefs's Avatar
 
Join Date: Apr 2004
Location: Chicago, IL
Posts: 1,328
Send a message via AIM to petefs Send a message via MSN to petefs Send a message via Yahoo to petefs
Default

I would use the mc loader class available in either flash 7 or the flash 6 version located at this url:
Colin Moock's loading class

assuming you have your flash service set up to just:
return mysql_query("select image_url from images");

flash 6 example:

Code:
#include "NetDebug.as"
#include "NetServices.as"
#include "DataGlue.as"
#include "com.qlod.LoaderClass.as"

imgLoader = new com.qlod.LoaderClass();
imgLoadProgress = new Object();

responder = new Object();
gatewayurl = "http://yourdomain/flashservices/gateway.php";
NetServices.setDefaultGatewayUrl(gatewayurl);
connection = NetServices.createGatewayConnection();
MyService = connection.getService("MyService", responder);
MyService.getImages();

responder.getImages_Result = function(data)
{
  totalImages = data.getLength();
  loadedImages = 0;
  for(var i=0;i<data.getLength();i++){
    var _mc = createEmptyMovieClip("img"+i, 100+i);
    imgLoader.load(_mc, data.items[i].img_url, imgLoadProgress);
  }
}

imgLoadProgress.onLoadProgress = function (loaderObj)
{
  trace(loaderObj.getPercent());    
}
that should load each returned url sequentially, you can handle how you place them however you want. if you want each movieclip to have it's own preloader going, the documentation at the URL for the loader above will illustrate how to do that rather easily. I think that's the simplest way to do it, personally. the loader class takes care of all the little weird things that can happen that are a pain in the ay ess ess to debug sometimes ^_^ If you have any other questions lemme know, I can put together a sample webservice and .FLA if that doesn't do it for you.

pete
petefs is offline   Reply With Quote
Old 04-14-2004, 08:28 AM   #3
designlevel2
Registered User
 
Join Date: Mar 2004
Posts: 19
Default

Thing is I have 11 images in each row of the database. Makes .length kind of a mute point. But I see what you're saying. Ill give it a try later this week.
designlevel2 is offline   Reply With Quote
Old 04-14-2004, 12:26 PM   #4
petefs
Fried Onions
 
petefs's Avatar
 
Join Date: Apr 2004
Location: Chicago, IL
Posts: 1,328
Send a message via AIM to petefs Send a message via MSN to petefs Send a message via Yahoo to petefs
Default

If you get a chance, could you post either some real data or some test data from your database as INSERT statements (assuming it's mysql)? or just give me a good idea of how it's laid out. I would build the array in whatever language you're using to parse AMF data and then pass it to flash -- flash's array manipulation, math, etc...is rather slow comparitavely, it's best to do all the work and pass the data all pretty-like to flash ^_^

something in your webservice like (amfphp):
Code:
$image_array = array();
$image_query = mysql_query("select * from images");
while($image=mysql_fetch_array($image_query)){
  $image_array[] = $image['row1'];
  $image_array[] = $image['row2'];
  ...
}
return array("image_array" => $image_array);
and then on the flash side:

Code:
for(var i=0;i<data.image_array.length;i++){
}
should do it. if things don't work out right post up some test data from the database, otherwise good luck!
petefs 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 07:40 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.