Next previous button in gallery


hi guys, been while, hope well.  having problem implementing next/previous button on image once has been enlarged in gallery.  have done in pure as3 tutorials seem use timeline.  post code underneath can see too.  next/previous button should think added modelclicked function.

 

from understand, next/previous button , turn them button object.  delete them stage , instantiate them within class below.  add them modelclicked function events tied them.  should in these events make fit in code below?

 

any advise appreciated,

 

cheers

 

nick

 

 

package classes.models {      import flash.display.bitmap;     import flash.display.loader;     import flash.display.movieclip;     import flash.display.sprite;     import flash.geom.rectangle;      import flash.events.mouseevent;     import flash.events.event;      import flash.net.urlrequest;      import eu.flashlabs.ui.basicbutton;      import classes.ui.stateclip;     import classes.ui.placeholder;      import classes.utils.urlutil;      import classes.vo.modelsstates;      import fl.containers.scrollpane;     import fl.controls.progressbar;      import com.greensock.tweenlite;       public class individualmodel extends stateclip     {          //--------------------------------------------------------------------------         // constants         //--------------------------------------------------------------------------          private static const padding_top:number= 28;         private static const padding_left:number= 50;         private static const cols:int= 4;         private static const rows:int= 8;         private static const gap_horizontal:number= 5;         private static const gap_vertical:number= 5;          //--------------------------------------------------------------------------         // member variables         //--------------------------------------------------------------------------          private var _data:xml;         public function data():xml         {             return _data;         }         public function set data(value:xml):void         {             setdata(value);         }          private var items:array;          private var backbtn:basicbutton;          private var itemsholder:movieclip;          private var loadindex:int;          private var sp:scrollpane;          private var clonedbitmap:bitmap;         private var originalbitmap:bitmap;         private var rect:rectangle;          private var screen:sprite = new sprite();          public function individualmodel()         {             super();             items = [];                          addeventlistener(event.added_to_stage, addedtostagehandler);         }                  private function addedtostagehandler(event:event):void         {             initchildren();         }          private function initchildren():void         {             itemsholder = new movieclip();             addchild(itemsholder);              sp = getchildbyname("mc_pane") scrollpane;              backbtn = getchildbyname("btn_back") basicbutton;             backbtn.addeventlistener(mouseevent.click, backbtn_clickhandler);              screen.graphics.beginfill(0x111111, .75);             screen.graphics.drawrect(0, 0, stage.stagewidth, stage.stageheight);             screen.graphics.endfill();         }          public function destroy():void         {             clearitems();         }          //--------------------------------------------------------------------------         // public interface         //--------------------------------------------------------------------------          //--------------------------------------------------------------------------         // layout         //--------------------------------------------------------------------------          private function clearitems():void         {             while (items.length > 0)             {                 var item:modelsitem = items.pop() modelsitem;                 itemsholder.removechild(item);                 item.destroy();             }         }          private function populateitems():void         {             (var i:int = 0; < math.min(cols * rows, data.picture.length()); i++)             {                 var item:modelsitem = new modelsitem();                 item.data = data.picture[i];                 item.x = padding_left + (i % cols) * (modelsitem.item_width + gap_horizontal);                 item.y = padding_top + math.floor(i / cols) * (modelsitem.item_height + gap_vertical);                 /*item.addeventlistener(mouseevent.click, modelclicked);*/                 itemsholder.addchild(item);                 /*item.mouseenabled = false;*/                 sp.source = itemsholder;                 items.push(item);             }             sp.verticalscrollpolicy = "on";             sp.horizontalscrollpolicy = "off";             sp.update();         }          //--------------------------------------------------------------------------         // picture loading         //--------------------------------------------------------------------------          private function loadnextpicture():void         {             if (loadindex < items.length)             {                 var loader:loader = new loader();                 loader.contentloaderinfo.addeventlistener(event.complete, loadnextpicture_completehandler);                 var item:modelsitem = items[loadindex] modelsitem;                 loader.load(new urlrequest(urlutil.geturl(item.data.@url.tostring())));                 /*item.mouseenabled = true;*/             }         }          private function loadnextpicture_completehandler(event:event):void         {             event.target.removeeventlistener(event.complete, loadnextpicture_completehandler);              modelsitem(items[loadindex]).bitmap = event.target.content bitmap;             modelsitem(items[loadindex]).addeventlistener(mouseevent.click, modelclicked);                          loadindex++;             loadnextpicture();         }          //--------------------------------------------------------------------------         // event handlers         //--------------------------------------------------------------------------          private function backbtn_clickhandler(event:mouseevent):void         {             state = modelsstates.hidden;         }          private function modelclicked(e:mouseevent):void         {             stage.addchild(screen);             var item:modelsitem = e.currenttarget modelsitem;             originalbitmap = item.bitmap;             clonedbitmap = new bitmap(originalbitmap.bitmapdata.clone());              stage.addchild(clonedbitmap);              rect = originalbitmap.getbounds(stage);             clonedbitmap.x = rect.x;             clonedbitmap.y = rect.y;             clonedbitmap.width = rect.width;             clonedbitmap.height = rect.height;             clonedbitmap.smoothing = true;              tweenlite.to(clonedbitmap, 1, { x: (stage.stagewidth - originalbitmap.width) / 4, y: (stage.stageheight - originalbitmap.height) / 6, oncomplete:zoominfinished, scalex: 1, scaley: 1 });          }          private function zoominfinished():void         {             trace("zoom in finished");             stage.addeventlistener(mouseevent.click, mouseclicked);         }          private function mouseclicked(e:mouseevent):void         {             tweenlite.to(clonedbitmap, 1, { x: rect.x, y: rect.y, oncomplete:zoomoutfinished, width: rect.width, height: rect.height});             stage.removeeventlistener(mouseevent.click, mouseclicked);         }                  private function zoomoutfinished():void         {             trace("mouse clicked");             stage.removechild(screen);             stage.removechild(clonedbitmap);         }                  //--------------------------------------------------------------------------         // getters & setters         //--------------------------------------------------------------------------          private function setdata(value:xml):void         {             _data = value;              clearitems();             populateitems();              loadindex = 0;             loadnextpicture();              state = modelsstates.shown;         }          //--------------------------------------------------------------------------         // utils         //--------------------------------------------------------------------------          override protected function animateincomplete():void         {             super.animateincomplete();              switch (state)             {                 case modelsstates.shown :                     break;                 case modelsstates.hidden :                     break;             }         }      } } 

no offense, lost interest halfway through code. it's code ask go through , try guess problem is.

 

a few questions, maybe they'll me 0 in on issue:

 

  1. what in code working , isn't?
  2. in part isn't working, trace statements or debugger telling you?
  3. why want delete instances off stage , move them created entirely in as? feel stage "dirty"? or not know how reference stage objects , use them are? or else?
  4. why aren't instantiating straight library if stage bothers much?
  5. your items appear serving data sources in load next image function, you're adding them stage. what's that? models or views?


More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support