Jump to content


  • Posts

  • Joined

  • Last visited

tonybot3's Achievements


Newbie (1/14)



  1. It works perfectly now. Thank you so much... Clearly, i have a lot to educate myself about Loaders and AS3, though i know the tool is functioning as i need to.
  2. Thank you much, and for clarifying for my misunderstanding. I will give this a go.
  3. Yes, ultimately, i think this was intended as an image loader, but i noticed i could get it to work with AS2 swf, as well. This is the one i'm trying to use: http://www.greensock.com/as/swf/PanelScrollExample.swf'>http://www.greensock.com/as/swf/PanelScrollExample.swf It simuates swiping, like on a phone. It invokes an external ActionScript file, which directs to an XML that in turn points to a directory full of jpegs (or in this case, standalone swf's). I would use an swf loader if i could find one that did the same thing. /** * 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; public class PanelScrollExample extends Sprite { private var _panelBounds:Rectangle = new Rectangle(0, 0, 800, 480); 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, {x:i * _panelBounds.width, width:_panelBounds.width, height:_panelBounds.height, 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.mouseX; _t1 = _t2 = getTimer(); _container.startDrag(false, new Rectangle(_panelBounds.x - 9999, _panelBounds.y, 9999999, 0)); 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.mouseX; _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.mouseX - _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.x > (_currentPanelIndex - 0.5) * -_panelBounds.width + _panelBounds.x)) { _currentPanelIndex--; } else if (_currentPanelIndex < _panelCount - 1 && (xVelocity < -20 || _container.x < (_currentPanelIndex + 0.5) * -_panelBounds.width + _panelBounds.x)) { _currentPanelIndex++; } TweenLite.to(_container, 0.7, {x:_currentPanelIndex * -_panelBounds.width + _panelBounds.x, ease:Strong.easeOut}); } } }
  4. Hi there, i've gotten PanelScrollExample to work with swf's (rather than images), the only caveat being that the swf's must be output as AS2 swf's. When i instead try with AS3 swf's, i get the following message: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@33c47041 to flash.display.Bitmap. at com.greensock.loading::ImageLoader/_initHandler() What does this error mean? Why does it work with AS2 swf's but not AS3 swf's? Is there anyway to make this work with AS3 swf's instead? I'm trying publish into a mobile app using Air, but that process will not retain any of the AS2 coding, so i'm back to square one.