the flex canvas container limited 10,000x10,000 pixels. yet, i've seen flex apps scrolling way more 10,000 pixels. idea how can done?
the content want scroll in pieces already, need add pieces can scroll vertically more 10,000 pixels.
depending on want display may able split content tiles. how google maps works, every time map moved program determines tiles visible on screen , loads them in. markers or overlays on map notified map has moved , determine new location is. if location off screen can removed canvas. example, width of tiles @ zoom level 20 on google maps (256 pixels * 2^20) equals 268,435,456 total pixels.
essentially need create special sprite keeps track of actual x,y location supposed positioned at. time container moves iterate through of child objects , determine put them.
function oncanvasscroll() { //determine top left coordinates of canvas //you figure out how depending on how scrolling window //is implemented var canvas_scroll_x; var canvas_scroll_y; //create bounding box canvas var view_bounds = new rectangle(canvas_scroll_x, canvas_scroll_y, canvas.width, canvas.height); (child in canvas) { var x = child.actual_x - view_bounds.x; var y = child.actual_y - view_bounds.y; var childbounds = new rectangle(x, y, child.width, child.height); //determine if component visible on screen if (view_bounds.intersects(child_bounds)) { child.visible = true; child.x = x; child.y = y; } else { child.visible = false; } } }
so if have canvas positioned @ (100, 20000), sprite positioned @ (300, 20100), , window (640,408), place @ (200, 100) , visible on screen.
instead of setting visible true or false better approach remove items canvas entirely when not within bounds of view.
Comments
Post a Comment