Back to Top
The nuts and bolts for
Creative web development

Displaying Multiple Access Records with Flash and ASP

Most Flash & ASP tutorials only deal with returning one row of information at a time from the database to the Flash movie. I was interested in displaying multiple records and fields simultaneously. One resource (FlashCFM.com) pointed the way and I used this start to arrive at a nice solution which is explained here.

The Flash side of things
Now, we have our output formatted so Flash can read it. Set up a Flash movie as so:

  1. Frame 1 Layer 1 - add a keyframe and the following action : loadVariablesNum ("list2.asp", 0);
    list2.asp is our ASP page that we have formatted to work with Flash
  2. Frame 1 add the text Loading ... on Layer 2. This will display until all the records are looped through by the ASP page and
    the variable 'counter' is set to 1.
  3. On Frame 2 add the following action :
       if (_root.Counter == 1) {
         gotoAndStop (3);
       } else {
         gotoAndPlay (1);
       }

    'Counter' is a variable we set up on the ASP page to signal the Flash movie that all of the table data has been read
  4. Create a new movie clip that looks like an up arrow - copy it, rotate it 180 degrees and place both of these button into another movie clip - name it arrow. You will use these later to scroll your results.
  5. Frame 2 add the following code to the frame :
        if (_root.Counter == 1) {
              gotoAndStop (3);
        } else {
          gotoAndPlay (1);
        }

    This insures that Loading will be displayed as the results are being returned.
  6. Frame 3 - this is where flash reads the array created by ASP, splits the array at the "," and duplicates the dynamic
    text fields. A lot of work but just follow the screen shot.


  7. Now double click on the movie clip containing the buttons and select one of the arrows. To the arrow button attach the following code:
       on (release, keyPress "<Up>") {
         for (eachBox in _root) {
           _root[eachBox]._y -= 10;
           setProperty (_root.arrow, _y, ypos);
         }
       }

    This uses the 'for...in' method to find each movie clip on the _root and move it down after each button press or each press of the down arrow key. Problem, this also moves your navigation buttons as they too reside in a movie clip on the _root. Fix this by adding a second layer to the inner movie clip and attaching the following code to the first layer
    on that frame:
       var ypos= _root.arrow._y;
    Now if you look back to the code in step 7 you see that after you change the _y position of all the clips on the _root, you change the arrow movie clip back to its original _y

That's it! Download Fla


Written by Chris Bizzel
The Pinnacle Consulting Group

This tutorial was the result of cobbling together information from several different resources and I want to thank David Freerksen particularly for sharing his code on the duplication of movie clips.
If you have questions about this tutorial contact me at webmaster@pincongrp.com.

Share this Article

Comments

Good Info, but didn't work for me

I followed the tutorial and I created my connection to SQL rather than Access. When I run the ASP I get the data as it said it would appear in the browser. I downloaded the Flash application and made sure the right ASP page was being called. However, no data ever appeared. It just sat there loading. I don't understand if thre is a problem in the code or if I have done something wrong. I wish it worked fro me ebcause I would really like to see the output.

just a hint

wouldb't it be easyer if you used xml?

i mean, you could return the records like <record name="John" email="j@you.us" />.

i'm saying this only because the performance of splitting strings and using arrays ends up loosing against the performance of the xml object in flash mx. this counts only if you have a lot of records, of course. if you work with a few records only, you can forget all that i said, because time diferences aren't so noticed.

keep up with the good work...

::Well appreciated tutorial::

helped me obtain ideas about connecting datagrid Flash UI Component to a database... specially the string splitting... pretty cool, but i need another assistance regarding commanding Flash to display a picture directly out of a database... thanks for the tutorial... g'day...

RE: Tutorial Update

gdkghkghkghk
See all 8 Comments