Solved

scrollpane dynamic content mx 04

Posted on 2004-09-16
13
281 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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
 
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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
3D rotation for a product 3 339
SWF won't scale? 4 524
Firefox video player - embedded native versus VLC player 3 1,076
Adobe Flash Player - PPAPI plugin 6 648
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
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…
The goal of the tutorial is to teach the user how to how to record live broadcast.

773 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