Jump to content
GreenSock

souzadavi

Members
  • Posts

    7
  • Joined

  • Last visited

souzadavi's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Do you think that way i´m going is the best way? or do I should do this from other way?? thanks DS
  2. i did this to load the files one by one... this function call _pageLoad()..... private function _pageCurrent(page:int):void { this._pageUnload(page); var i:int = -1; /// KEEP 3 PAGES LOADED. for (i; i < 3; i++) { var paginaLoad:int = page + i; if (_container.getChildByName(String(paginaLoad)) == null) { //trace("NOT LOADED"); if (page == 0) { this._pageLoad(0); this._pageLoad(1); this._pageLoad(2); } if (page != 0) { this._pageLoad(paginaLoad); } }else { //trace("ALREADY LOADED"); } } }
  3. private function _pageLoad(pageId:int):void { LoaderMax.activate([imageLoader, SWFLoader, XMLLoader]); queue = LoaderMax.parse("assets/" + chapters.page[pageId].@file, { name:+pageId, x:pageId * _pageBounds.width, width:_pageBounds.width, height:_pageBounds.height, container:_container, autoDispose:true}); queue.load(); var loaded:Array = queue.getChildrenByStatus(LoaderStatus.COMPLETED); trace(loaded.length + " loaders have completed"); }
  4. not working.. ERROR: 1061: Call to a possibly undefined method getChildrenByStatus through a reference with static type com.greensock.loading.core:LoaderCore. thanks DS
  5. HI, there is anybody knows how could i get the number of loader i already got loaded? Like i want to make sure that i´m unload all things that i used to... I just need hold only 3 external files. i´m loading the files: LoaderMax.activate([imageLoader, SWFLoader, XMLLoader]); loader = LoaderMax.parse("assets/" + chapters.page[pageId].@file, { name:+pageId, x:pageId * _pageBounds.width, width:_pageBounds.width, height:_pageBounds.height, container:_container } ); loader.load(); I want to know how many child is in loader... Something like: trace(loader.numChildren); Or other way to check if loader is unload already.... thanks... DS
  6. Thanks... I´´m working around and soon i will post the news back here again.. thanks for the direction....
  7. Hi, i´ve been trying to search a free open source application for android magazine, and i couldn´t find nothing, so this project will be to build a open source code for magazine to use in google play for android apk with adobe air. the project is at github https://github.com/souzadavi/dsmagazine I want to use LoaderMax for this project. I would like to load at same time only 3 pages, so will be the current page, last page and next page. When an user swipe the page to left or right the magazine pre load the page, this should work by this way because this magazine will run on tablet, so we don´t have too much memory avalaible. Any other ideia will be appreciate also. I`m using this http://www.greensock.com/as/zip/PanelScrollExample.zip but i´m loading all pages and added in stage, this is taking a lot of memory. I would like to load 3 by 3.... Any help will be very appreciate. MY XML IS: <?xml version="1.0" encoding="utf-8"?> <data> <configs load="false"> <screen height="1232" width="800" aspectioRatio="portrait" /> <book name="Demo" /> <chapters quantity="1" /> </configs> <book> <chapter name="Demo Parte 1" load="true"> <page file="1/page_1.jpg" type="image" /> <page file="1/page_2.jpg" type="image" /> <page file="1/page_3.jpg" type="image" /> <page file="1/page_4.jpg" type="image" /> </chapter> <chapter name="Demo Parte 2" load="false"> <page file="1/page_1.jpg" type="image" /> <page file="1/page_2.jpg" type="image" /> <page file="1/page_3.jpg" type="image" /> <page file="1/page_4.jpg" type="image" /> </chapter> </book> </data> AS3 CODE: package com.core{ import com.greensock.events.LoaderEvent; import com.greensock.loading.*; import flash.display.Sprite; import flash.events.MouseEvent; import flash.net.URLLoader; import flash.net.URLRequest; import flash.utils.getTimer; import flash.events.Event; import flash.geom.Rectangle; import com.greensock.TweenLite; import com.greensock.easing.Strong; public class Magazine extends Sprite { private var _pageBounds:Rectangle; private var _container:Sprite; private var _currentPageIndex:int = 0; private var _pageCount:int; private var _x1:Number; private var _x2:Number; private var _t1:uint; private var _t2:uint; public function Magazine(){ this.init(); } private function init():void { var xmlLoader:XMLLoader = new XMLLoader("configs/book.xml", {onComplete:_xmlCompleteHandler}); xmlLoader.load(); } private function _xmlCompleteHandler(event:LoaderEvent):void { var configs:XMLList = event.target.content.configs; var chapters:XMLList = event.target.content.book.chapter; _pageBounds = new Rectangle(0, 0, Number(configs.screen.@width), Number(configs.screen.@height)); _container = new Sprite(); _container.x = _pageBounds.x; _container.y = _pageBounds.y; addChildAt(_container, 0); _container.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDownHandler, false, 0, true); _pageCount = chapters.page.length(); var queue:LoaderMax = new LoaderMax(); for (var i:int = 0; i < _pageCount; i++) { //trace("PAGINAS CONTADAS:"+ chapters.page[i].@type); switch (String(chapters.page[i].@type)){ case "image" : queue.append( new ImageLoader("assets/" + chapters.page[i].@file, {x:i * _pageBounds.width, width:_pageBounds.width, height:_pageBounds.height, container:_container}) ); break; case "swf" : queue.append( new SWFLoader("assets/" + chapters.page[i].@file, {x:i * _pageBounds.width, width:_pageBounds.width, height:_pageBounds.height, container:_container}) ); break; } } //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(_pageBounds.x - 9999, _pageBounds.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 (_currentPageIndex > 0 && (xVelocity > 20 || _container.x > (_currentPageIndex - 0.5) * -_pageBounds.width + _pageBounds.x)) { _currentPageIndex--; } else if (_currentPageIndex < _pageCount - 1 && (xVelocity < -20 || _container.x < (_currentPageIndex + 0.5) * -_pageBounds.width + _pageBounds.x)) { _currentPageIndex++; } TweenLite.to(_container, 0.7, {x:_currentPageIndex * -_pageBounds.width + _pageBounds.x, ease:Strong.easeOut}); } } } thanks DS
×