Solved

scrollpane dynamic content mx 04

Posted on 2004-09-16
13
278 Views
Last Modified: 2011-09-20
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
Comment
Question by:chizzy12
  • 7
  • 5
13 Comments
 
LVL 3

Expert Comment

by:d2kagw
ID: 12081839
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
 

Author Comment

by:chizzy12
ID: 12081877
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
 
LVL 3

Expert Comment

by:d2kagw
ID: 12081952
lol - its always the easiest stuff that takes all day...

ok, so you have a scrollbar, is it MX or MX 04?
0
 

Author Comment

by:chizzy12
ID: 12081962
MX 04
0
 
LVL 7

Expert Comment

by:ssdesign
ID: 12084510
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
 

Author Comment

by:chizzy12
ID: 12097972
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 3

Expert Comment

by:d2kagw
ID: 12098006
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
 

Author Comment

by:chizzy12
ID: 12098103
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
 
LVL 3

Expert Comment

by:d2kagw
ID: 12098161
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
 

Author Comment

by:chizzy12
ID: 12098353
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
 
LVL 3

Accepted Solution

by:
d2kagw earned 460 total points
ID: 12098594
Hey, I do have files, whats your email address and I'll shoot it across.
0
 

Author Comment

by:chizzy12
ID: 12098872
mrsigma@yahoo.com

Cheers
0
 

Author Comment

by:chizzy12
ID: 12099012
Thanks.. Now i have a better understanding of it..


Thanks again...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

707 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now