BloggerLoop Actionscript

Table of contents | Previous document | Download BloggerLoop.as | SWF!T Homepage

RCSfile: BloggerLoop.as,v  Revision: 1.3  Date: 2003/01/29 16:40:19  

Copyright 2003 Orgdot AS. All Rights Reserved. http://dev.swfit.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


The BloggerLoop does the actual loading of the basic blogger, implementing a delayed setting of variables, so that the maxscroll property can be read. See BloggerInit.as for parameter names and further details.
author      Olaf Havnes
version     Revision: 1.3  Date: 2003/01/29 16:40:19  
since       SWFIT1.0


Means we got a previous one

if (adjust_clip)
{

Report to the scrollbar the total height BEFORE this clip is added

   set ("../:tot_height_" add num_clip, tot_height);

Load data for a single post

   username      = eval (PUB_USERNAME      add num_clip);
   usermail      = eval (PUB_USERMAIL      add num_clip);
   userbio       = eval (PUB_USERBIO       add num_clip);

   urlval        = eval (PUB_URL_VAL       add num_clip);
   urltxt        = eval (PUB_URL_TXT       add num_clip);

   title         = eval (PUB_TITLE         add num_clip);
   post          = eval (PUB_POST          add num_clip);

   image_path    = eval (PUB_IMAGE_PATH    add num_clip);
   image_title   = eval (PUB_IMAGE_TITLE   add num_clip);
   image_credits = eval (PUB_IMAGE_CREDITS add num_clip);

   cdate_short   = eval (PUB_CDATE_SHORT   add num_clip);
   cdate_long    = eval (PUB_CDATE_LONG    add num_clip);
   mdate_short   = eval (PUB_MDATE_SHORT   add num_clip);
   mdate_long    = eval (PUB_MDATE_LONG    add num_clip);

Adjust for image directory and image size

   if (image_path ne "") image_path = image_prepend add image_path add image_append;

Stick all the data into the current clip

   nclip = "clip_" add num_clip;

   set ( nclip add ":" add NME_USERNAME,      username      );
   set ( nclip add ":" add NME_USERMAIL,      usermail      );
   set ( nclip add ":" add NME_USERBIO,       userbio       );

   set ( nclip add ":" add NME_URL_VAL,       urlval        );
   set ( nclip add ":" add NME_URL_TXT,       urltxt        );

   set ( nclip add ":" add NME_TITLE,         title         );
   set ( nclip add ":" add NME_POST,          post          );

   set ( nclip add ":" add NME_IMAGE_PATH,    image_path    );
   set ( nclip add ":" add NME_IMAGE_TITLE,   image_title   );
   set ( nclip add ":" add NME_IMAGE_CREDITS, image_credits );

   set ( nclip add ":" add NME_CDATE_SHORT,   cdate_short   );
   set ( nclip add ":" add NME_CDATE_LONG,    cdate_long    );
   set ( nclip add ":" add NME_MDATE_SHORT,   mdate_short   );
   set ( nclip add ":" add NME_MDATE_LONG,    mdate_long    );


Measure the size of the texfield and delete the text to ease rendering.

   scrollval = eval (nclip add ":txt_scroll.maxscroll");
   set ( nclip add ":txt_scroll", ""  );

Measure the different components

   top_height = getProperty (nclip add "/top_back", _height);
   mid_height = lheight * (1 + scrollval);
   bot_height = getProperty (nclip add "/bot_back", _height);

Stack the different components

1) Leave the top where it is

2) Scale the background

   setProperty (nclip add "/mid_back", _yscale, mid_height);

3) Move the bottom clips down

   setProperty (nclip add "/bot_back",      _y, mid_height);
   setProperty (nclip add "/link_but",       _y, mid_height);

4) Should we hide the usermail button ?

   if (usermail eq "")
   {
       setProperty (nclip add "/user_but", _visible, false);
   }

5) Should we hide the url button ?

   if (urlval eq "")
   {
       setProperty (nclip add "/link_but", _visible, false);
   }

6) Measure the full size of this clip

   this_height = top_height + mid_height + bot_height;

7) Should we load an image ?

   if (image_path eq "")
   {
       setProperty (nclip add "/placeholder", _visible, false);
   }
   else
   {
       loadMovie (image_path, nclip add "/placeholder");
       if (this_height < imheight)
       this_height = imheight;
   }

Report the total height and the size of this clip to the scrollbar

   tot_height += this_height + cspacing;
   _parent.scroll_height = tot_height;
   _parent.no_scroll_size = this_height;
   

Iterate to the next clip

   adjust_clip = false;
   num_clip++;

Report the number of clips to the scrollbar

   _parent.num_clip = num_clip;
}

if (num_clip < num_user)
{

Duplicate the basic clip

   nclip = "clip_" add num_clip ;
   duplicateMovieClip ("clip", nclip, num_clip);

Set the workaround textfield so that we can measure the text size the next time

   post = eval (PUB_POST add num_clip);
   set (nclip add ":txt_scroll", post);

Move the clip to the correct position

   setProperty (nclip, _y, tot_height);
   adjust_clip = true;
}