Problem with scrolling (along with everyone else it seems!)

  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

I'm working on a blog for a site that loads entries via a PHP script from a database into a dynamic textfield with a scrollbar MC.

I've got everything working (so far) except I can't get the textbox to scroll. The original version of this blog is a guestbook that used a Flash textfield component, which worked except it didn't conform stylistically to the site, so I decided to use my own. I've used my textfield before and in fact have it on several other pages in the site to load text files and it works fine.

The original AS was meant to load text files, but something is wrong with the path to the textbox variables. The problem seems to be that the scrollbar is not attaching itself to the textfield, meaning I'm using the wrong variable name or path to identify the textfield to the scrollbar. Before, when using a textfile source, I would reference the var name of the dynamic text in the scrollbar's AS. That doesn't seem to work here and I've tried every permutation of target path I can think of. And even some I couldn't think of. I can drag the scrollbar so I've got that much right. I know it's something really stupid. Lostinbeta, where are you when I need a dose of humility?

You can find the files here: http://duke-music.com/new/. The blog is 'blogpage_only.htm' and '.fla'. If you view the HTML page in a browser, you'll see that the database connection is working. You can see the entire site, with scrolling textfields, at http://duke-music.com/.

Thanks for your help!
Lance

If you need the PHP script, here it is:

Code: [ Select ]
<?php
/*
-----
Application: Flash-dB GuestBook Version 2.0
Details:   mySQL and PHP powered GuestBook
Author:   Mohsin Sumar
Website:   http://www.flash-db.com
Support:   http://www.flash-db.com/Board
Notes:    Coments are marked by using comment entries symbols. Eg: // Comment
-----
*/

// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
  $DBhost = "localhost";  // Database Server
  $DBuser = "*******";    // Database User
  $DBpass = "*******";      // Database Pass
  $DBName = "*******";    // Database Name
  $table = "guestbook";  // Database Table
  $numComments = 10;    // Number of Comments per page
 
  // Connect to mySQL Server
  $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());

  // Select mySQL Database
  mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// Part Two - Choose what action to perform
  $action = $_GET['action'];
 
  switch($action) {
   case 'read' :
         // Fetch all comments from database table
         $sql = 'SELECT * FROM `' . $table . '`';
         $allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
         $numallComments = mysql_num_rows($allComments);
         // Fetch page-wise comments from database table
         $sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
         $fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
         $numfewComments = mysql_num_rows($fewComments);
         // Generate Output for Flash to Read
         print '&totalEntries=' . $numallComments . '&';
         print "<br>&entries=";    
        
         if($numallComments == 0) {
          print "No entries in the guestbook, as yet..";
         } else {
          while ($array = mysql_fetch_array($fewComments)) {
              $name = mysql_result($fewComments, $i, 'name');
              $email = mysql_result($fewComments, $i, 'email');
              $comments = mysql_result($fewComments, $i, 'comments');
              $time = mysql_result($fewComments, $i, 'time');
             
              print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<br><b>Comments: </b>' . $comments . '<br><i>Date: ' . $time . '</i><br><br>';
              $i++;
          }
        }
        // Print this only when there aren't any more entries..
        if($_GET['NumLow'] > $numallComments) {
          print 'No More Entries!&';
        }
        break;
        
     case 'write' :
       // Recieve Variables From Flash
         $name = ereg_replace("&", "%26", $_POST['yourname']);
         $email = ereg_replace("&", "%26", $_POST['youremail']);
         $comments = ereg_replace("&", "%26", $_POST['yourcomments']);
         $submit = $_POST['submit'];
             
         // Current system date in yyyy-mm-dd format
         $submitted_on = date ("Y-m-d H:i:s",time());
                 
         // Check if its submitted from Flash
         if($submit == 'Yes'){
         // Insert the data into the mysql table
         $sql = 'INSERT INTO ' . $table .
        ' (`ID`,
                  `name`,
                  `email`,
                  `comments`,
                  `time`
                 )
                 VALUES
                 (\'\','
                  . '\'' . $name . '\','
                  . '\'' . $email . '\','
                  . '\'' . $comments . '\','
                  . '\'' . $submitted_on . '\'
                  )';
         $insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
        
         // If you want your script to send email to both you and the guest, uncomment the following lines of code
         // Email Script Begin
        
         /* <-- Remove this line
         $MyName = "Mohsin Sumar";
         $MyEmail = "mohsinsumar@hotmail.com";
         $Subject = "$name has just signed your guestbook.";
         $EmailBody = "Hello Mohsin,\n$name has just signed your guestbook available at http://www.mohsinsumar.com. THe following were the details submitted into your guestbook:\n\nName: $name\nEmail: $email\nComment:\n$comments\n";
        
         $EmailFooter = "~~~~~~~~~~~~~~~\nThe guestbook was signed by $name and thus this email got activated by $name from $REMOTE_ADDR from http://www.mohsinsumar.com\n~~~~~~~~~~~~~~~\nThanking you,\nMohsin Sumar";
        
         $Message = $EmailBody.$EmailFooter;
        
         mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
         --> Remove this line */
        
         // Email Script End
        
         print "&gb_status=Thank you for signing my guestbook.&done=yes&";
         return;
         }
         print "&_root.write.gb_status=Error!&";
         break;
  }
?>
  1. <?php
  2. /*
  3. -----
  4. Application: Flash-dB GuestBook Version 2.0
  5. Details:   mySQL and PHP powered GuestBook
  6. Author:   Mohsin Sumar
  7. Website:   http://www.flash-db.com
  8. Support:   http://www.flash-db.com/Board
  9. Notes:    Coments are marked by using comment entries symbols. Eg: // Comment
  10. -----
  11. */
  12. // Part One - Initiate a mySQL Database Connection
  13. // Database Connectivity Variables and other Variables
  14.   $DBhost = "localhost";  // Database Server
  15.   $DBuser = "*******";    // Database User
  16.   $DBpass = "*******";      // Database Pass
  17.   $DBName = "*******";    // Database Name
  18.   $table = "guestbook";  // Database Table
  19.   $numComments = 10;    // Number of Comments per page
  20.  
  21.   // Connect to mySQL Server
  22.   $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
  23.   // Select mySQL Database
  24.   mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
  25. // Part Two - Choose what action to perform
  26.   $action = $_GET['action'];
  27.  
  28.   switch($action) {
  29.    case 'read' :
  30.          // Fetch all comments from database table
  31.          $sql = 'SELECT * FROM `' . $table . '`';
  32.          $allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
  33.          $numallComments = mysql_num_rows($allComments);
  34.          // Fetch page-wise comments from database table
  35.          $sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
  36.          $fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
  37.          $numfewComments = mysql_num_rows($fewComments);
  38.          // Generate Output for Flash to Read
  39.          print '&totalEntries=' . $numallComments . '&';
  40.          print "<br>&entries=";    
  41.         
  42.          if($numallComments == 0) {
  43.           print "No entries in the guestbook, as yet..";
  44.          } else {
  45.           while ($array = mysql_fetch_array($fewComments)) {
  46.               $name = mysql_result($fewComments, $i, 'name');
  47.               $email = mysql_result($fewComments, $i, 'email');
  48.               $comments = mysql_result($fewComments, $i, 'comments');
  49.               $time = mysql_result($fewComments, $i, 'time');
  50.              
  51.               print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<br><b>Comments: </b>' . $comments . '<br><i>Date: ' . $time . '</i><br><br>';
  52.               $i++;
  53.           }
  54.         }
  55.         // Print this only when there aren't any more entries..
  56.         if($_GET['NumLow'] > $numallComments) {
  57.           print 'No More Entries!&';
  58.         }
  59.         break;
  60.         
  61.      case 'write' :
  62.        // Recieve Variables From Flash
  63.          $name = ereg_replace("&", "%26", $_POST['yourname']);
  64.          $email = ereg_replace("&", "%26", $_POST['youremail']);
  65.          $comments = ereg_replace("&", "%26", $_POST['yourcomments']);
  66.          $submit = $_POST['submit'];
  67.              
  68.          // Current system date in yyyy-mm-dd format
  69.          $submitted_on = date ("Y-m-d H:i:s",time());
  70.                  
  71.          // Check if its submitted from Flash
  72.          if($submit == 'Yes'){
  73.          // Insert the data into the mysql table
  74.          $sql = 'INSERT INTO ' . $table .
  75.         ' (`ID`,
  76.                   `name`,
  77.                   `email`,
  78.                   `comments`,
  79.                   `time`
  80.                  )
  81.                  VALUES
  82.                  (\'\','
  83.                   . '\'' . $name . '\','
  84.                   . '\'' . $email . '\','
  85.                   . '\'' . $comments . '\','
  86.                   . '\'' . $submitted_on . '\'
  87.                   )';
  88.          $insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
  89.         
  90.          // If you want your script to send email to both you and the guest, uncomment the following lines of code
  91.          // Email Script Begin
  92.         
  93.          /* <-- Remove this line
  94.          $MyName = "Mohsin Sumar";
  95.          $MyEmail = "mohsinsumar@hotmail.com";
  96.          $Subject = "$name has just signed your guestbook.";
  97.          $EmailBody = "Hello Mohsin,\n$name has just signed your guestbook available at http://www.mohsinsumar.com. THe following were the details submitted into your guestbook:\n\nName: $name\nEmail: $email\nComment:\n$comments\n";
  98.         
  99.          $EmailFooter = "~~~~~~~~~~~~~~~\nThe guestbook was signed by $name and thus this email got activated by $name from $REMOTE_ADDR from http://www.mohsinsumar.com\n~~~~~~~~~~~~~~~\nThanking you,\nMohsin Sumar";
  100.         
  101.          $Message = $EmailBody.$EmailFooter;
  102.         
  103.          mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
  104.          --> Remove this line */
  105.         
  106.          // Email Script End
  107.         
  108.          print "&gb_status=Thank you for signing my guestbook.&done=yes&";
  109.          return;
  110.          }
  111.          print "&_root.write.gb_status=Error!&";
  112.          break;
  113.   }
  114. ?>
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Your .fla file is corrupt, I can't open it.
  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

Try it now. It was in MX2004. Now in MX.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

While that does help me that it was now MX, the original file was corrupt altogether, not just format. When it's the version I get 'Unexpect File Format', but I was getting 'Unable to Open File' which means it got corrupted.

As for your problem....

this.blogtext

should be...

blogtext_txt

You can't use 'this' in a function, only a prototype (because a prototype is object specific), and your instance name for the textfield was blogtext_txt, not just blogtext.
  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

Sounds reasonable though I thought I'd tried that. I'll give it another shot when I get home tonight.

Thanks again. This forum rocks with you on it. You've helped me more times than I can ENUM.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

ROFL! Spoken like a true geek.

Code: [ Select ]
for (var i = 0; i<INFINITY; i++){
  DartHead.hug();
}
  1. for (var i = 0; i<INFINITY; i++){
  2.   DartHead.hug();
  3. }



I tried it out with my own text. I just disabled the loading, added in my own custom text, set loaded to true and changed the targetting... worked orgasmically.
  • DartHead
  • Beginner
  • Beginner
  • User avatar
  • Posts: 56
  • Loc: NYC

Post 3+ Months Ago

Whoa!

Super!! It works like a charm. I knew it was stupid. Wait, maybe it's me. Coulda swore I tried that. I think it was setting loaded to 'true' that did the trick. I just took loaded out altogether. It was being pretentious anyway.

Thanks again!

Code: [ Select ]
onClipEvent (load) {
    scrolling = 0;
    frameCounter = 1;
    speedFactor = 2;
    numLines = 7;
    resetOnNewFile = true;
    origHeight = scrollbar._height;
    origX = scrollbar._x;
    refreshRate = 12;
    refreshCounter = 0;
    refreshlastMaxscroll = 0;
    function refreshScrollBar()
    {
        blogtext_txt.scroll = resetOnNewFile ? 1 : Math.min(blogtext_txt.maxscroll, blogtext_txt.scroll);
        var totalLines = numLines + blogtext_txt.maxscroll - 1;
        scrollbar._yscale = 100 * (numLines) / totalLines;
        deltaHeight = origHeight - scrollbar._height;
        lineHeight = deltaHeight / (blogtext_txt.maxscroll - 1);
        updateScrollBarPos();
    }
    function updateScrollBarPos()
    {
        scrollbar._y = lineHeight * (blogtext_txt.scroll - 1);
    }
}
onClipEvent (enterFrame) {
    if (refreshCounter % refreshRate == 0 && blogtext_txt.maxscroll != refreshLastMaxScroll) {
        refreshScrollBar();
        refreshLastMaxScroll = blogtext_txt.maxscroll;
        refreshCounter = 0;
    }
    refreshCounter++;
    if (frameCounter % speedFactor == 0) {
        if (scrolling == "up" && blogtext_txt.scroll > 1) {
            blogtext_txt.scroll--;
            updateScrollBarPos();
        } else if (scrolling == "down" && blogtext_txt.scroll < blogtext_txt.maxscroll) {
            blogtext_txt.scroll++;
            updateScrollBarPos();
        }
        frameCounter = 0;
    }
    frameCounter++;
}
onClipEvent (mouseDown) {
    if (up.hitTest(_root._xmouse, _root._ymouse)) {
        scrolling = "up";
        frameCounter = speedFactor;
    }
    if (down.hitTest(_root._xmouse, _root._ymouse)) {
        scrolling = "down";
        frameCounter = speedFactor;
    }
    if (scrollbar.hitTest(_root._xmouse, _root._ymouse)) {
        scrollbar.startDrag(0, origX, deltaHeight, origX);
        scrolling = "scrollbar";
    }
    updateAfterEvent();
}
onClipEvent (mouseUp) {
    scrolling = 0;
    stopDrag();
    updateAfterEvent();
}
onClipEvent (mouseMove) {
    if (scrolling == "scrollbar") {
        blogtext_txt.scroll = Math.round((scrollbar._y) / lineHeight + 1);
    }
    updateAfterEvent();
}
  1. onClipEvent (load) {
  2.     scrolling = 0;
  3.     frameCounter = 1;
  4.     speedFactor = 2;
  5.     numLines = 7;
  6.     resetOnNewFile = true;
  7.     origHeight = scrollbar._height;
  8.     origX = scrollbar._x;
  9.     refreshRate = 12;
  10.     refreshCounter = 0;
  11.     refreshlastMaxscroll = 0;
  12.     function refreshScrollBar()
  13.     {
  14.         blogtext_txt.scroll = resetOnNewFile ? 1 : Math.min(blogtext_txt.maxscroll, blogtext_txt.scroll);
  15.         var totalLines = numLines + blogtext_txt.maxscroll - 1;
  16.         scrollbar._yscale = 100 * (numLines) / totalLines;
  17.         deltaHeight = origHeight - scrollbar._height;
  18.         lineHeight = deltaHeight / (blogtext_txt.maxscroll - 1);
  19.         updateScrollBarPos();
  20.     }
  21.     function updateScrollBarPos()
  22.     {
  23.         scrollbar._y = lineHeight * (blogtext_txt.scroll - 1);
  24.     }
  25. }
  26. onClipEvent (enterFrame) {
  27.     if (refreshCounter % refreshRate == 0 && blogtext_txt.maxscroll != refreshLastMaxScroll) {
  28.         refreshScrollBar();
  29.         refreshLastMaxScroll = blogtext_txt.maxscroll;
  30.         refreshCounter = 0;
  31.     }
  32.     refreshCounter++;
  33.     if (frameCounter % speedFactor == 0) {
  34.         if (scrolling == "up" && blogtext_txt.scroll > 1) {
  35.             blogtext_txt.scroll--;
  36.             updateScrollBarPos();
  37.         } else if (scrolling == "down" && blogtext_txt.scroll < blogtext_txt.maxscroll) {
  38.             blogtext_txt.scroll++;
  39.             updateScrollBarPos();
  40.         }
  41.         frameCounter = 0;
  42.     }
  43.     frameCounter++;
  44. }
  45. onClipEvent (mouseDown) {
  46.     if (up.hitTest(_root._xmouse, _root._ymouse)) {
  47.         scrolling = "up";
  48.         frameCounter = speedFactor;
  49.     }
  50.     if (down.hitTest(_root._xmouse, _root._ymouse)) {
  51.         scrolling = "down";
  52.         frameCounter = speedFactor;
  53.     }
  54.     if (scrollbar.hitTest(_root._xmouse, _root._ymouse)) {
  55.         scrollbar.startDrag(0, origX, deltaHeight, origX);
  56.         scrolling = "scrollbar";
  57.     }
  58.     updateAfterEvent();
  59. }
  60. onClipEvent (mouseUp) {
  61.     scrolling = 0;
  62.     stopDrag();
  63.     updateAfterEvent();
  64. }
  65. onClipEvent (mouseMove) {
  66.     if (scrolling == "scrollbar") {
  67.         blogtext_txt.scroll = Math.round((scrollbar._y) / lineHeight + 1);
  68.     }
  69.     updateAfterEvent();
  70. }
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Glad you got it working!

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 11 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.