Skip navigation
Jazzkokehead
Currently Being Moderated

XML gallery and other questions

Aug 9, 2012 4:28 PM

Tags: #flash #as3 #xml #as3.0 #actionscript3

Hello everyone,

 

I am a beginner when it comes to Flash, ActionScript, and so forth. I started reading up on the subjects several months ago, when I decided my website needed a serious upgrade, and thought Flash would be the best way to achieve what I wanted. I've looked at a number of websites,  and have done my best to figure things out on my own, but I've reached a point where I'm simply not sure how to proceed and would appreciate the help and guidance of someone who knows what they're doing.

 

Keeping my inexperience in mind, I'll do my best to accurately describe the problems I'm having.

 

1. I have a gallery based on the code from the tutorial on this site, but I would like to expand it in several ways - the first being, I would like to divide my gallery into multiple pages, but pull the thumbnails from a single XML file. Right now I have 8 thumbnails per page, with each page being a separate XML - this doesn't seem very efficient for when I want to update my gallery. What would be the best way to tell Flash to load the first 8 images from the XML, then the next 8 when a button is clicked, and so forth?

 

2. I would also like to allow the user to cycle through full sized images - that is, when the user is viewing a full image, they can click a button to go forward or backward to the next full-sized image without having to exit and go back to the gallery.

 

3. Lastly, I want the full sized images to be resized and repositioned based on the size of the browser window. Right now, the images appear to be scaled and positioned properly when I first click on them, but if I resize the window while the large image is up, it doesn't update it's size or position. I copied the initial code I was using to determine size/position so that I essentially am calling a function within a function. Needless to say, this seems a bad way of doing things, but I'm not sure else how to get it to work the way I want it.

 

Thanks in advance for your help!

 
Replies
  • Currently Being Moderated
    Aug 9, 2012 10:07 PM   in reply to Jazzkokehead

    To display 8 images per page, you can consider two variables...one for index and another for display 8 in page as follows:

     

    var index:int = 0;

    var imagesToDisplay:int = 8;

    var imagesCount:int = 8;

     

    function arrangeImages()

    {

         for(var i:int = index;i < imagesCount;i++)

         {

              //code for loading and displaying images here...

         }

    }

     

    next_btn.addEventListener(MouseEvent.CLICK,gotoNextPage);   //next_btn is a button to go next page and display next 8 images...

    prev_btn.addEventListener(MouseEvent.CLICK,gotoPrevPage);   //prev_btn is a button to go last page and display previous 8 images....

     

    function gotoNextPage(e:MouseEvent):void

    {

         if(index <= length of images - imagesToDisplay)

         {

              index += imagesToDisplay;

              imagesCount += imagesToDisplay;

              arrangeImages();

         }

    }

     

    function gotoPrevPage(e:MouseEvent):void

    {

         if(index >= imagesToDisplay)

         {

              index -= imagesToDisplay;

              imagesCount -= imagesToDisplay;

              arrangeImages();

         }

    }

     

     

    For viewing the full size images of the gallery one by one, you need to take another next and previous buttons. At that time you have to get the images of the current page by checking xml as well. Use the code like above but the only difference is you need to consider index of those 8 images and thier length that is nothing but 8. For prev button

     

    if(index > 0)

    index--;

    call the function which loads images...

     

     

    For next button

     

    if(index < 7)

    index++;

    call the function which loads images...

     

     

     

    For placing the images constantly, you can take one movieclip to have all these images. Place that movieclip according to the stage.

     

    mc.x = stage.stageWidth/ 2;

     

    like that....

     

     

     

     

    Note: I just want to provide you a basic idea. But this may not be the exact code. As per your requirements, you can change...and go on...

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points