• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

scrollpane dynamic content mx 04

Hi
What i want to do is pull images from a database and place them in a scroll bar..

Currently i have been able to get the image names.. but havnt been able to load them in properly..
images as variable s are like so.. image1, image2 etc..
eg
i currently have something like so

for(i=1;i<noproducts;i++){
_root.createEmptyMovieClip("imageHolder"+i,i);
set("imghold",eval("imageHolder"+i));
imghold._x=4*i;
imghold._width=10;
imghold._height=50;
set("img",eval("image" add i));
loadMovie(img,imghold);
}

It basically doesnt want to load... at the moment its not linked to a scroll bar but im hoping to get this going so i can..


Any help would be great
0
chizzy12
Asked:
chizzy12
  • 7
  • 5
1 Solution
 
d2kagwCommented:
Hey there,

this usually works for me

for (i=1; i<noproducts;i++)
{
      this.attachMovie("mc_Dropper","tmpImage_"+i, 1000+i )
      this['tmpImage_'+i].Dropper.loadMovie("_images/"+img[noproducts])
      this['tmpImage_'+i]._height = 60
      this['tmpImage_'+i]._width  = 60
      this['tmpImage_'+i]._x = 25 * i
}

basically, I just took out the set("img", eval ("Image" + i)) and replaced it with this["image"+i] which is much more reliable.

hope this helps !!
0
 
chizzy12Author Commented:
I get Syntax error...
Doining that way can i dynamically get the images and place them in the scrollbar.. its sounds so easy yet ive spend a day on it...
0
 
d2kagwCommented:
lol - its always the easiest stuff that takes all day...

ok, so you have a scrollbar, is it MX or MX 04?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
chizzy12Author Commented:
MX 04
0
 
ssdesignCommented:
hi, i have created a image gallery based on same kind of principle. Its pulling data from MySql database using PHP.

You can look at it here:

http://www.ssdesigninteractive.com/image_gallery/image_gallery.html

I used SCROLLPANE, its always easier to use UI components if size is not a big issue.

You can create an empty movieclip and set it as Content Path for the Scrollpane. Then you can attach your images to this empty movieclip.

Let me know if this kind of code works for you.
0
 
chizzy12Author Commented:
thats what i have been trying .. i create a movieclip that can be placed in a scroll pane with via a button. then using a loop create empty movie clips within that movie instance name and loadthem with images from db .. but hen i click the button it just loads the original flash with no movie clips attached..

would you have some code that could help me..

THanks
0
 
d2kagwCommented:
Hi There,

I haven't tested this, but it should work:

//
// Draw Icon Table
// ---------------------------------------------------------------
//
//            @ditArray = the array where all the image locations are stored
//            @ditObject = the object where mc's are to be attached
//            @ditAttach = the name of the library object to be attached
//            @ditPadding = the number of pixels to padd with [minimum pixels]
//

function drawIconTable(ditArray:Array, ditObject:Object, ditAttach:String, ditPadding:Number):Void
{
      //
      trace("DRAW ICON TABLE")
      //
      i = new Array()
      i[0] = 0
      i[1] = 0
      i["firstRun"] = true
      //
      ditAWidth  = 0
      ditAHeight = 0
      ditColumns = 0
      //
      while (ditArray[i[0]]['URL'] != null)
      {
            //
            ditObject.attachMovie(ditAttach,"icon_"+i[0] ,i[0])
            ditObject['icon_'+i[0]].loadMovie( ditArray[i[0]]['URL'])
            //
            with(eval("ditObject.icon_"+i[0]))
            {
                  //
                  _x = (i[1] * (ditAWidth+ditPadding)) + ditPadding
                  _y = Math.floor(i[0]/ditColumns) * (ditAHeight + ditPadding)
                  //
            }
            //
            if (i["firstRun"])
            {
                  //
                  i["firstRun"] = false
                  //
                  ditAWidth  = getProperty(eval("ditObject.icon_"+i[0]), _width)
                  ditAHeight = getProperty(eval("ditObject.icon_"+i[0]), _height)
                  //
                  ditColumns = Math.floor(ditObject._width / (ditAWidth + ditPadding))
                  //
            }
            //
            i[0] ++
            i[1] ++
            //
            if (i[1] > (ditColumns-1))
            {
                  i[1] = 0
            }
            //
      }
      //
}
//
0
 
chizzy12Author Commented:
thanks .. im not too familar with the format of functions.. how would i pass
these values..

ive got this code in a function
drawIconTable("28.jpg,29.jpg","circle","contentHolder", "15");
just to test...

      @ditArray = the array where all the image locations are stored
//          @ditObject = the object where mc's are to be attached
//          @ditAttach = the name of the library object to be attached
//          @ditPadding = the number of pixels to padd with [minimum pixels]

-- circle is a MC that i can load into a scrollpane because it has an identifier..
--contentHolder is the name of an empty Mc in the Library

trying that ive got

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 19: Syntax error.
              i = new Array();

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 20: Syntax error.
          i[0] = 0;

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 5: Type mismatch.
     drawIconTable("28.jpg,29.jpg","circle","contentHolder", "15");
What am i doing wrong


Thanks again
0
 
d2kagwCommented:
Ok,

Firstly, i'd suggest removing the :Array, :Object, :String, :Number and :Void from this function,
as you may/may not be aware, this is the new Strict Data Typing implemented in MX04, which is super for developers that create more complex applications as it greatly assists in the debuging stage, however, if you use Strict Data Typing on one area of your application, it needs to be everywhere, otherwise you get loads of errors, like your i=new Array();

so the function decliration should look like:

        function drawIconTable(ditArray, ditObject, ditAttach, ditPadding)

That should eradicate the first two errors.
then for the last one, you need to put the the urls into an array.

imageArray = new Array()
imageArray[0]['URL'] = '28.jpg'
imageArray[1]['URL'] = '29.jpg'

then feed the function imageArray instead of the string.

Also, ensure that your jpegs are not saved as pogressive load, cause flash can't load them dynamically, images either have to be Gifs or Baseline Jpegs.

Hope that helped
0
 
chizzy12Author Commented:
It doesnt seem to .

Ok ive got a button that calls loadScrollableContent()
This is following code.. You wouldnt to happen to have a sample file i could look at.. its the only way i can learn...

You will recieve the points regardless..

Thanks,,

function loadScrollableContent(){
imageArray = new Array()
imageArray[0]['URL'] = '28.jpg'
imageArray[1]['URL'] = '29.jpg'
drawIconTable(imageArray,"circle","contentHolder",10)
      }
      
function drawIconTable(ditArray, ditObject, ditAttach, ditPadding)
{
        i = new Array();
     i[0] = 0;
     i[1] = 0;
     i["firstRun"] = true;
 
     ditAWidth  = 0;
     ditAHeight = 0;
     ditColumns = 0;
     
     while (ditArray[i[0]]['URL'] != null)
     {
          
          ditObject.attachMovie(ditAttach,"icon_"+i[0] ,i[0]);
          ditObject['icon_'+i[0]].loadMovie( ditArray[i[0]]['URL']);
          
          with(eval("ditObject.icon_"+i[0]));
          {
               
               _x = (i[1] * (ditAWidth+ditPadding)) + ditPadding;
               _y = Math.floor(i[0]/ditColumns) * (ditAHeight + ditPadding);
               
          }
          
          if (i["firstRun"])
          {
               
               i["firstRun"] = false;
               
               ditAWidth  = getProperty(eval("ditObject.icon_"+i[0]), _width);
               ditAHeight = getProperty(eval("ditObject.icon_"+i[0]), _height);
              
               ditColumns = Math.floor(ditObject._width / (ditAWidth + ditPadding));
              
          }
        
          i[0] ++;
          i[1] ++;
          
          if (i[1] > (ditColumns-1))
          {
               i[1] = 0;
          }
     
     }
    
}
      
.
0
 
d2kagwCommented:
Hey, I do have files, whats your email address and I'll shoot it across.
0
 
chizzy12Author Commented:
mrsigma@yahoo.com

Cheers
0
 
chizzy12Author Commented:
Thanks.. Now i have a better understanding of it..


Thanks again...
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now