Jump to content
Search Community

Drunk-Kong

Members
  • Posts

    4
  • Joined

  • Last visited

Drunk-Kong's Achievements

0

Reputation

  1. just chage to up and down. /** * Very simple demo of panel flick-scrolling. It loads in an XML file * containing the file names for 5 panel jpg files and then arranges them * side-by-side in a Sprite (_container) and makes it scrollable horizontally. * Feel free to add more panels in the XML, change the _panelBounds position/size, * add a preloader, error handling, etc. the goal was to keep this simple. * * Get more code at http://www.greensock.com **/ package { import com.greensock.events.LoaderEvent; import com.greensock.loading.*; import flash.display.Sprite; import flash.events.MouseEvent; import flash.utils.getTimer; import flash.events.Event; import flash.geom.Rectangle; import com.greensock.TweenLite; import com.greensock.easing.Strong; /** * ... * @author Fernando Cabello */ public class PanelScrollExample extends Sprite { private var _panelBounds:Rectangle = new Rectangle(0, 0, 400, 225); private var _container:Sprite; private var _currentPanelIndex:int = 0; private var _panelCount:int; private var _x1:Number; private var _x2:Number; private var _t1:uint; private var _t2:uint; public function PanelScrollExample() { _container = new Sprite(); _container.x = _panelBounds.x; _container.y = _panelBounds.y; addChildAt(_container, 0); _container.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDownHandler, false, 0, true); var xmlLoader:XMLLoader = new XMLLoader('assets/panels.xml', {onComplete:_xmlCompleteHandler}); xmlLoader.load(); } private function _xmlCompleteHandler(event:LoaderEvent):void { var panels:XMLList = event.target.content.panel; _panelCount = panels.length(); var queue:LoaderMax = new LoaderMax(); for (var i:int = 0; i < _panelCount; i++) { queue.append( new ImageLoader('assets/' + panels[i].@file, {y:i * _panelBounds.height, height:_panelBounds.height, width:_panelBounds.width, container:_container}) ); } //feel free to add a PROGRESS event listener to the LoaderMax instance to show a loading progress bar. queue.load(); } private function _mouseDownHandler(event:MouseEvent):void { TweenLite.killTweensOf(_container); _x1 = _x2 = this.mouseY; _t1 = _t2 = getTimer(); //_container.startDrag(false, new Rectangle(_panelBounds.y - 9999, _panelBounds.x, 9999999, 0)); _container.startDrag(false, new Rectangle(_panelBounds.x, _panelBounds.y -9999, 0, 999999)); this.stage.addEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler, false, 0, true); this.addEventListener(Event.ENTER_FRAME, _enterFrameHandler, false, 0, true); } private function _enterFrameHandler(event:Event):void { _x2 = _x1; _t2 = _t1; _x1 = this.mouseY; _t1 = getTimer(); } private function _mouseUpHandler(event:MouseEvent):void { _container.stopDrag(); this.removeEventListener(Event.ENTER_FRAME, _enterFrameHandler); this.stage.removeEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler); var elapsedTime:Number = (getTimer() - _t2) / 1000; var xVelocity:Number = (this.mouseY - _x2) / elapsedTime; //we make sure that the velocity is at least 20 pixels per second in either direction in order to advance. Otherwise, look at the position of the _container and if it's more than halfway into the next/previous panel, tween there. if (_currentPanelIndex > 0 && (xVelocity > 20 || _container.y > (_currentPanelIndex - 0.5) * -_panelBounds.width + _panelBounds.y)) { _currentPanelIndex--; } else if (_currentPanelIndex < _panelCount - 1 && (xVelocity < -20 || _container.y < (_currentPanelIndex + 0.5) * -_panelBounds.width + _panelBounds.y)) { _currentPanelIndex++; } TweenLite.to(_container, 0.7, {y:_currentPanelIndex * -_panelBounds.width + _panelBounds.y, ease:Strong.easeOut}); } } } thansk very much
  2. That's look perfect, let me give a try..... and post code
  3. ok almost done, just simple question. How to tween for drag. I mean if i drag some object i want it to do it with tween effect. thanks.. I'll psot my code as soon i finished it.
  4. Hi to all devs an designers.. I'm just new here...amazing this library.. well i'v been drive me crazy for the last couples of days trying to achive a mobile scroll behavoiur like for my app. I've got a few attemps but i could not achieve it 100%.. Any clue, tutorial are more than welcome... I think that with a noce tutorial on how to do a simple scrollbar i could extract i tan dcreate what i want.. I must say that i work with FlashDevelop so please no timeLines tutorials.. Please help.. i'm stuck into here!! Thanks in advance
×
×
  • Create New...