Jump to content
Search Community

Amnesicat

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Amnesicat

  1. Hi, mvaneijgen and Carl, These are two fantastic solutions, thank you so much for your quick responses. Carl, thanks for the other technique too, I'll definitely check that out as well as your videos. Regards, Alan
  2. Hi, I'm trying to emulate something like this - I tried doing a forEach to dynamically capture all item elements, create fromTo tweens into separate child timelines and then add them to a main timeline to enable expand all items etc. (see codepen), but it's not working as intended. The item animations work fine on there own but when I add them to the main timeline they mess everything up. Can you control nested GSAP timelines individually like this, or is there a better way to do it? Any guidance or examples on how to do this properly would be greatly appreciated. Thanks a lot, Alan
  3. Thanks Carl, that did the trick. The effect is like a mexican wave type motion through a straight row of movieclips, so the offset is intentional to achieve this. You probably have to see it setup in flash to know what I mean. By the way, I really like your tutorials. Keep up the great work. Thanks again, Alan
  4. Hi Just wondering if someone might know a solution to my problem (see code below). The whole tween works fine on the first run, but when it repeats the movieclips seem to act strange and jump to the 120 y position straight away. Now I know it's because of the 0.3 offset, I just thought someone might know a way to get around or do this differently. Any help would be greatly appreciated. Thanks, Alan import com.greensock.*; import com.greensock.easing.*; var mcArray:Array = [mc01,mc02,mc03,mc04,mc05,mc06,mc07,mc08,mc09]; var tl:TimelineMax = new TimelineMax({delay:2, repeat:-1, repeatDelay:2}); tl.insertMultiple(TweenMax.allTo(mcArray, 1, {y:120, ease:Bounce.easeOut}, 0.2)); tl.insertMultiple(TweenMax.allTo(mcArray, 1, {y:242, ease:Bounce.easeOut}, 0.2), 0.3);
  5. Yep, that seems to have nailed it. Tested it on my mates version of the Flash Builder Prolifer and it stayed at a happy yoyo with the gc. I did not know you could do that with for loops. Thank you so much for showing me the way, greatly appreciated. Cheers.
  6. Hello Mr Greensock Firstly, I know you probably get compliments on your classes all the time, but I just have to say that they are an extremely intuitive and superbly crafted set of classes. I used them in my last project when I only just started learning actionscript, and as a beginner I found them really easy to implement and right away started accurately tweening to my heart's content. I didn't realise that this coding stuff could be so fun (I am merely a graphic designer trying to cut corners by doing my own AS coding). So, a big thank you for that. Well, I tried adding mc.mcTween.kill(); to the dispose method, and as you said it didn't make any difference. There's definitely memory building up as you click each page button, and it just keeps building the more you click and not fully releasing even after leaving it run for at least 20 mins. I have attached some simple example FLAs if you wanted to have a look. The code is exactly what I'm using in my final project except obviously it includes bitmap images instead of the vectors. I think I have narrowed the problem down to the use of the TimeLineMax instance within the for loop. If I just use the loop to capture all the objects and only add a simple tween in a separate function it seems to work fine without any memory build up. Should I not be instantiating a TimeLineMax in a loop like that? Should I use some other method to tween and reverse tween multiple objects? On another note, I have been using Mrdoob's Hi-Res Stats profiler for testing memory. Have you used this at all?, and if so, is it a reliably consistent profiler?. I ony ask because I've been getting varying results depending on which Flash Player version I use. For instance, with other memory tests I've performed (not the particular problem I'm experiencing now, interestingly) using Flash Player version 10.1 and above the profiler would show memory being captured and not released after the child swfs are loaded and unloaded repeatedly. But, using Flash Player 10 and below it would show the memory build and release as the garbage collection passed over, as it should. So, I'm definitely no expert in the matter and by no means trying to bag Mrdoob's profiler, I'm just wondering if there may be a chance it could be a miss reading or bug in this particular profiler or something. Is there a reliable memory profiler that you would recommend using? Is the Flash (Flex) Builder version any good? Any help would be terrific, because I'm really baffled by this one. Thanks. Example.zip
  7. Hello I'm pretty sure you have to use the load() and unload() calls as well as the add/remove content lines. Someone correct me if I'm wrong but I think your code should look like this: var currentPage:SWFLoader; if (currentPage != null) { swf_holder_mc.removeChild(currentPage.content); currentPage.unload(); } currentPage = LoaderMax.getLoader('swf1'); currentPage.load(true); swf_holder_mc.addChild(currentPage.content); Anyway, it's something for you to try if you haven't done so already.
  8. Hi all I'm loading and unloading child SWFs from a main SWF using the Main SWF Code below that was suggested in another thread on this forum. Then as suggested in the SWFLoader API documentation I added a dispose method to the Child SWFs to cleanup eventlisteners for garbage collection when unload is called within the Main SWF (See Child SWF Code below). The trouble is that when I test the memory management of the Main SWF there seems to be a memory leak, as the memory isn't being released and is building up over time. I am pretty new to actionscript and not really sure what else I have to do to avoid memory leaks when loading and unloading with SWFLoader. Is there something else I need to add in the dispose method of the Child SWF? I'd appreciate any help. Thank you Main SWF Code: import flash.display.*; import flash.events.*; import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; var page1:SWFLoader = new SWFLoader("page1.swf",{centerRegistration:true,x:512,y:350}); var page2:SWFLoader = new SWFLoader("page2.swf",{centerRegistration:true,x:512,y:350}); var page3:SWFLoader = new SWFLoader("page3.swf",{centerRegistration:true,x:512,y:350}); var currentPage:SWFLoader; nav_mc.button1.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler); nav_mc.button2.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler); nav_mc.button3.addEventListener(MouseEvent.MOUSE_DOWN, clickHandler); nav_mc.button1.mouseChildren = false; nav_mc.button2.mouseChildren = false; nav_mc.button3.mouseChildren = false; nav_mc.buttonMode = true; function clickHandler(e:MouseEvent):void { var next:SWFLoader; if (e.currentTarget == nav_mc.button1) { next = page1; } else if (e.currentTarget == nav_mc.button2) { next = page2; } else { next = page3; } if (next == currentPage) { return; } if (currentPage != null) { removeChild(currentPage.content); currentPage.unload(); } currentPage = next; currentPage.load(true); addChild(currentPage.content); } Child SWF Code: import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; import flash.events.MouseEvent; import flash.display.*; TweenPlugin.activate([scalePlugin]); var mcArray:Array = [pic1,pic2,pic3,pic4,pic5,pic6,pic7,pic8,pic9,pic10,pic11,pic12]; var mcTween:TimelineMax; TweenMax.to(mcBackDrop, 0, {autoAlpha:0}); var len:int = mcArray.length; var mc:MovieClip; for (var i:int = 0; i < len; i++) { mc = mcArray[i]; var stageX = stage.stageWidth / 2; var stageY = 330; mc.mouseChildren = false; mc.addEventListener(MouseEvent.CLICK, clickHandler, false, 0, true); mc.mcTween = new TimelineMax({paused:true,reversed:true,onReverseComplete:addBackDrop}); mc.mcTween.insert(TweenMax.to(mcBackDrop,0.8,{autoAlpha:0.7,ease:Sine.easeInOut})); mc.mcTween.insert(TweenMax.to(mc,1,{x:stageX,y:stageY,scale:1,ease:Back.easeInOut})); } function clickHandler(e:MouseEvent):void { e.target.mcTween.reversed = ! e.target.mcTween.reversed; e.target.mcTween.resume(); addChild(e.target as DisplayObject); } function addBackDrop() { addChild(mcBackDrop); } var curParent:DisplayObjectContainer = this.parent; while (curParent) { if (curParent.hasOwnProperty("loader") && curParent.hasOwnProperty("rawContent")) { Object(curParent).loader.addEventListener("unload", dispose, false, 0, true); } curParent = curParent.parent; } function dispose(event:Event):void { mc.removeEventListener(MouseEvent.CLICK, clickHandler); }
  9. Thanks Carl, Well, I tried to implement the globalToLocal method but couldn't really get it to center the image as I'd hoped. Though this is most likely due to my lack of actionscript knowledge. I'm not sure but I think I need to somehow use the ENTER_FRAME function in the throwprops code to updated the x/y coordinates to reflect the new center position for the tween. How to do this is well beyond my knowledge for now. Thanks for your suggestion. I probably should try a more generic as3 forum as this is bordering more on just as3 rather than greensock. Thanks again, Alan
  10. I thought I'd attach a simple FLA example to help explain what I mean. Thanks, Alan Example.zip
  11. Hi everyone, Just wondering if someone could please help me out. I have a throwprops movieclip setup to scroll vertically with a mouse drag similar to ipad devices and the like. Inside the movieclip there is a couple of thumbnail image movieclips that when clicked enlarge to the fullsized image in the center of the stage. The problem is that the thumbnail images are positioned below the stage frame, so when you sroll down to the thumbnail and click it the enlarged image tweens up and is positioned out of view. Now I know this is happening because I have x/y positions set to fit in the center of the stage using (stage.stageWidth / 2;), I just thought someone may know a way to dynamically update the center position to reflect the currently viewed area of the throwprops movieclip. Anyway, I've attached the code below. Any help would be greatly appreciated. Thanks, Alan import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; import com.greensock.loading.*; import flash.geom.Rectangle; import flash.utils.getTimer; import flash.events.MouseEvent; import flash.text.*; import flash.display.*; TweenPlugin.activate([ThrowPropsPlugin, ScalePlugin]); var bounds:Rectangle = new Rectangle(0,0,1024,768); var blitMask:BlitMask = new BlitMask(mc,bounds.x,bounds.y,bounds.width,bounds.height,true,true,0,false); var t1:uint,t2:uint,y1:Number,y2:Number; blitMask.update(); blitMask.disableBitmapMode(); blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler, false, 0, true); function mouseDownHandler(e:MouseEvent):void { TweenLite.killTweensOf(mc); y1 = y2 = mc.y; t1 = t2 = getTimer(); mc.startDrag(false, new Rectangle(bounds.x, bounds.y - 9999, 0, 9999999)); mc.addEventListener(Event.ENTER_FRAME, enterFrameHandler, false, 0, true); mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 0, true); } function enterFrameHandler(e:Event):void { y2 = y1; t2 = t1; y1 = mc.y; t1 = getTimer(); blitMask.update(); } function mouseUpHandler(e:MouseEvent):void { mc.stopDrag(); mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); mc.removeEventListener(Event.ENTER_FRAME, enterFrameHandler); var time:Number = (getTimer() - t2) / 1000; var yVelocity:Number = (mc.y - y2) / time; ThrowPropsPlugin.to(mc, {throwProps:{ y:{velocity:yVelocity, max:bounds.top, min:bounds.top - 632, resistance:600} }, onStart:blitMask.disableBitmapMode, onUpdate:blitMask.update, ease:Quad.easeOut}, 10, 0.3, 1); } ///////////////////////smallPics////////////////////////////////////////////////////////////////////////////// var picArray:Array = [mc.pic1,mc.pic2,mc.pic3,mc.pic4]; var mcAddChild:MovieClip; var mcTween:TimelineMax; var mc:MovieClip; TweenMax.to(mc.mcCover, 0, {autoAlpha:0}); for (var i:int = 0; i < picArray.length; i++) { var stageX = stage.stageWidth / 2; var stageY = stage.stageHeight / 2; picArray[i].mouseChildren = false; picArray[i].addEventListener(MouseEvent.CLICK, clickHandler, false, 0, true); picArray[i].mcTween = new TimelineMax({paused:true,reversed:true,onStart:addMovieClip,onReverseComplete:addCover}); picArray[i].mcTween.insert(TweenMax.to(mc.mcCover,0.8,{autoAlpha:0.7,ease:Sine.easeInOut})); picArray[i].mcTween.insert(TweenMax.to(picArray[i],1,{x:stageX,y:stageY,scale:1,ease:Back.easeInOut})); } function clickHandler(e:MouseEvent):void { e.target.mcTween.reversed = ! e.target.mcTween.reversed; e.target.mcTween.resume(); mcAddChild = MovieClip(e.currentTarget); } function addMovieClip() { mc.addChild(mcAddChild); } function addCover() { mc.addChild(mc.mcCover); }
×
×
  • Create New...