Solved

scrollpane dynamic content mx 04

Posted on 2004-09-16
13
282 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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…

837 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