Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

crooksy88

Members
  • Posts

    24
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Sheffield UK

crooksy88's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. Ok so after a little fiddling it seems that the issue was that the blitmask was being applied before the bitmaps had been loaded. var queue:LoaderMax = new LoaderMax({onComplete:loadCompleteHandler}); private function loadCompleteHandler(event:LoaderEvent):void { if (!_blitMask) { _blitMask = new BlitMask(_container, 0, 0, 400, 100, true, true, 0xFF0000, true); _blitMask.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDownHandler, false, 0, true); } } Seems to be visible now. Thanks again for the great reply.
  2. Thanks Carl. That is a great reply. Very thorough. The confusion is that I am using the example at the bottom of the page (panel scrolling) which I now realise doesn't use ThrowProps! This still doesn't seem to like having a BlitMask applied to it though. The example uses the 400px stage to do it's masking but what I'm after is creating a 400px wide scroll area sat on a 1024px stage. Perhaps I'm missing something. I've downloaded the files, run them to test everything is working. Then added a blitmask like this: 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}) ); } queue.load(); var _blitMaskB:BlitMask = new BlitMask(_container, 0, 0, 400, 100, true, true, 0xFF0000, true); } But I just get a black screen when testing?
  3. Thanks Carl. I did already have this reference but when I've tried to add it to a blitmask I don't get anything appearing in screen. The post seemed to suggest there was a working example of ThrowProps and Blitmask together but I'm assuming that was incorrect?
  4. Could someone point me to where this ThrowProps with BlitMask example (mentioned in the initial post) is please? Thanks
  5. Thanks Jack, I don't know if you're interested in investigating this further but this issue does seem to be linked with using GSAP. I've altered my code to use a regular URLStream and according to Scout, the ByteArrays are not held onto and the Network buffer is now being purged by Garbage Collection. I've included my code in case it's of interest to anyone as well as a Scout screenshot showing the network buffer purge. This was running on Air 3.7 for Android (on a HTC One). var _downloadItemIndex:int = 0; private function downloadAFile():void { _downloadItemName = _filesToDownload[_downloadItemIndex]; _urlString = ANDROID_DOWNLOADS_URL + _downloadItemName; _urlReq = new URLRequest(_urlString); _urlStream = new URLStream(); _urlStream.addEventListener(flash.events.Event.COMPLETE, saveFileToDisc, false, 0, true); _urlStream.load(_urlReq); } private function saveFileToDisc(event:flash.events.Event):void { _dataD = new ByteArray(); _urlStream.readBytes(_dataD, 0, _urlStream.bytesAvailable); _dFile = File.documentsDirectory.resolvePath("Includes/"+ _downloadItemName); _fileStream = new FileStream(); _fileStream.addEventListener(flash.events.Event.CLOSE, fileSaved, false, 0, true); _fileStream.openAsync(_dFile, FileMode.UPDATE); _fileStream.writeBytes(_dataD, 0, _dataD.length); _fileStream.close(); _dataD.length = 0; _dataD = null; } private function fileSaved(closeEvent:flash.events.Event):void { _downloadItemIndex++; if (_downloadItemIndex < _numFiles) { downloadAFile(); } else { _fileStream.removeEventListener(flash.events.Event.CLOSE, fileSaved); _urlString = null; _urlReq = null; _urlStream = null; _dFile = null; _filesToDownload = []; _filesToDownload = null; _dataD = null; _fileStream = null; trace("finished"); } }
  6. I'm using LoaderMax to load several .flv files. _queue = new LoaderMax({name:"mainQueue", onComplete:finishedDownload, maxconnections:2}); for (i = 0; i < _numFiles; i++) { _queue.append( new DataLoader(_filesToDownload[i][0], {name:_filesToDownload[i][0], format:"binary", estimatedBytes:_filesToDownload[i][1]}) ); } _queue.load(); When the queue has completed it calls: private function finishedDownload(event:LoaderEvent):void { _queue.dispose(true); _queue.unload(); _queue = null; } I then repeat the loading sequence again with a new set of flv urls. As I watch this in Scout though, despite calling dispose and unload on the queue, I see a gradual increase in ByteArrays and Network Buffers until the app crashes, presumably running out of memory. I've attached a screenshot of the Scout display. I have no other ByteArray allocations going on so this seems to be linked to LoaderMax. Would anyone have an idea on how I can clear these ByteArrays and Network Buffers? Thanks, Mark
  7. Thanks Carl, That seems to be working although I have a slight issue. I think that my app is running out of memory as I try to load the LoaderMax queue (290MB of assets). As each file is downloaded and stored to disc I was hoping to remove that DataLoader from the queue but doing so seems to reset the overall progress of the queue. private function startAndroidVideosDownload():void { _dFile = File.documentsDirectory.resolvePath("includes"); if (!_dFile.exists) { _dFile.createDirectory(); } _numFilesLoaded = 0; _filesToDownload = []; for(var i:int = 0; i < DataStore._appData.androidIncludes.item.length(); i++) { _filesToDownload.push([DataStore._appData.androidIncludes.item[i], DataStore._appData.androidIncludes.item[i].@bytes]); } _numFiles = _filesToDownload.length; log("_numFiles "+_numFiles); _queue = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler, onChildComplete:saveFile, maxconnections:2}); for (i = 0; i < _numFiles; i++) { _queue.append( new DataLoader(_filesToDownload[i][0], {name:_filesToDownload[i][0], format:"binary", estimatedBytes:_filesToDownload[i][1]}) ); } _queue.prependURLs("http://www.domain.com/mobileSupport/androidIncludes/"); _queue.load(); } private function saveFile(event:LoaderEvent):void { _dataD = LoaderMax.getContent(event.target.name); _fileStream = new FileStream(); _dFile = File.documentsDirectory.resolvePath("includes/"+event.target.name); _fileStream.openAsync(_dFile, FileMode.WRITE); _fileStream.writeBytes(_dataD, 0, _dataD.length); _fileStream.close(); //now dispose the loader var currentLoader:DataLoader = LoaderMax.getLoader(event.target.name); currentLoader.dispose(true); currentLoader = null; } Would you have any suggestions on the most efficient way to download 90 files (totalling 290MB)? Being able to show the total progress is a big plus. Thanks, Mark
  8. HI, I need to download several files (.flv, .xml and .mp3) and store them to disc (not display or play them) but am having trouble doing this. As the queue loads and each child is loaded I am calling the 'saveFile' function in which I need to get the loaders' content as a ByteArray so I can save it with FileStream. Any advice would be very much appreciated. Here's where I am at the moment: private var _queue:LoaderMax; private var _dataD:ByteArray; private function startAndroidDownload():void { LoaderMax.activate([XMLLoader, BinaryDataLoader, VideoLoader, MP3Loader]); _filesToDownload = ["squats.flv","Workout1.xml","Workout2.xml","Workout3.xml","Workout4.xml","Workout5.xml","Workout6.xml","Workout7.xml","Workout8.xml","Workout9.xml"]; _numFiles = _filesToDownload.length; _queue = LoaderMax.parse(_filesToDownload,{maxconnections:1, onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler, onChildComplete:saveFile}); _queue.prependURLs("http://www.mydomain.com/androidIncludes/"); _queue.load(); } private function progressHandler(event:LoaderEvent):void { //show progress } private function completeHandler(event:LoaderEvent):void { //queue complete } private function errorHandler(event:LoaderEvent):void { //handle error } private function saveFile(event:LoaderEvent):void { // I'm wanting to get the loader data as a ByteArray so I can save it to disc with FileStream _dataD = _queue.getContent(event.target.name) as ByteArray; }
  9. Perfecto . Certainly helps when you know what you're doing. bd.draw(queue.getLoader(_imageName).content); Thanks Jack.
  10. Hi, I'm currently loading an image using the proportionalOutside and crop parameters: queue.append( new ImageLoader(_loadedImageURL, {name:_imageName, estimatedBytes:2800, container:this, alpha:1, width:100, height:50, scaleMode:"proportionalOutside", crop:true}) ); If we imagine the full sized image that is loaded to be 200px wide by 50px high the image will crop off the left and right 50px. That is all good but if I get the width of the image I get 200px, not 100. queue.getLoader(_imageName).rawContent.width); // 200 What I'm wanting to do is create a bitmap of the cropped area only, i.e. 100x50px Would anyone know how I can access just this part of the image? Thanks, Mark
  11. Hi, If I load lots of ImageLoaders via a LoaderMax queue. var queue = new LoaderMax({name:"mainQueue",onProgress:progressHandler,onComplete:completeHandler}); for(...) { var _loader = new ImageLoader(_media_url+".jpg", {name:_media_url, container:this, width:100, height:100, scaleMode:"stretch", onComplete:completeHandler}); } queue.append( _loader ); Is my code more efficient/optimised if I remove all listeners from all ImageLoaders or does it not make any difference if I just leave them there? I had an idea of creating a new bitmap of the loaded content and then using dispose(true) for all the ImageLoaders. Would that be more efficient than just keeping the ImageLoaders as they are? Thanks, Mark
  12. Thanks Carl, Just out of curiosity, is using the allTo and allFrom methods more efficient than using a for loop, or is it just more convenient?
  13. Hi, I have an array of instances of a class. Each instance contains a public variable, ypos:int. Can I access this variable within an allTo command so each instance would be tweened to it's own ypos value? e.g. TweenMax.allTo(statsArr, 1, {y:"ypos", ease:Strong.easeOut},.1); Thanks, Mark
  14. You were on the right lines. I guess you just missed a few things that needed changing/swapping. I've changed the names of the vars as well to signify x instead of y although that isn't really necessary. // Blitmasking for Section 1 import com.greensock.layout.*; import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; TweenPlugin.activate([ThrowPropsPlugin]); var blitMask:BlitMask = new BlitMask(coretechtimeline_mc, coretechtimeline_mc.x, coretechtimeline_mc.y, coretechtimeline_mc.width, coretechtimeline_mc.height, true); blitMask.bitmapMode = false; var t1:uint, t2:uint, x1:Number, x2:Number; blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); function mouseDownHandler(event:MouseEvent):void { trace("bitmapMode is now FALSE"); blitMask.bitmapMode = false; TweenLite.killTweensOf(coretechtimeline_mc); x1 = x2 = coretechtimeline_mc.x; t1 = t2 = getTimer(); coretechtimeline_mc.startDrag(false, new Rectangle(-99999,0 ,99999999, 0)); coretechtimeline_mc.addEventListener(Event.ENTER_FRAME, enterFrameHandler); coretechtimeline_mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } function enterFrameHandler(event:Event):void { x2 = x1; t2 = t1; x1 = coretechtimeline_mc.x; t1 = getTimer(); //blitMask.scrollX = 0; blitMask.update(); } function enableBitMapMode():void{ trace("bitmapMode is now TRUE"); blitMask.bitmapMode = true; } function mouseUpHandler(event:MouseEvent):void { coretechtimeline_mc.stopDrag(); coretechtimeline_mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); coretechtimeline_mc.removeEventListener(Event.ENTER_FRAME, enterFrameHandler); var time:Number = (getTimer() - t2) / 1000; var xVelocity:Number = (coretechtimeline_mc.x - x2) / time; var xOverlap:Number = Math.max(0, coretechtimeline_mc.width - coretechtimeline_mc.width); ThrowPropsPlugin.to(coretechtimeline_mc, {throwProps:{ x:{velocity:xVelocity, max:0, min:0, resistance:100} }, onUpdate:blitMask.update, ease:Strong.easeOut, onComplete:enableBitMapMode }, 0.3, 0.3, 0.2); }
×