Jump to content
GreenSock

PapaDeBeau

Members
  • Posts

    33
  • Joined

  • Last visited

Recent Profile Visitors

3,354 profile views

PapaDeBeau's Achievements

  1. Hi, Sorry for my simplicity in this question. I have been a paying member for YEARS now and I very rarely ask questions. Anyway thanks for your patience. Here is my goal. I want to load a list of hundreds of Names from a Database, maybe even over 1K or 2K. Then I load them into jQuery Array. I want to have like maybe 10 or 20 names float from the bottom to the top. In short this is like a Memorial Wall of people who have passed away. We want to honor their life with music etc... I have code working but when its coded very poorly. When I get many names it CHUGS and STUTTERS because it's creating huge amounts of DIVS and animating them all. This is bad I know. I would like to, maybe, animate only 10 to 20 and then once off screen I would UNLOAD OR HIDE the div to free up resources. I would also like to maybe add a candle the is animated by the name as well. This would also take up huge resources if it was many names loaded. What is the best way to loop though hundreds maybe even thousands of names and not have to load them in all in one go. Also, I would like the names to float up at various speeds as an option and would like them to be in random x positions as they go up. ANOTHER issue with my code is that sometimes the names are so long they go off the right side of the screen. They are not contained. I am guessing this is fairly simple, but gosh I just don't know how to do it. I Thank you in advance for helping me overcome this. I put my example on CodePen with reloaded STATES as the names, but eventually those NAMES will be real names loaded from a Database. var W = $(window).width(); var H = $(window).height(); for (i = 0; i < Names.length; i++) { $(".P").append('<div class="C" >' + Names[i] + "</div>"); var tl = gsap.timeline({ delay: 1 }); var Mary = $(".C").width(); gsap.fromTo( ".C", { y: H + 100, x: "random(0, " + W / 2 + ")", opacity: 0 }, { y: -333, opacity: 1, duration: 14, stagger: 0.8 } ); } I didn't put the NAMES vars in this code above but I did in the working example in CodePen. Thanks for your help. The code is here: https://codepen.io/PapaDeBeau/pen/LYBEjdb
  2. Link is broken. I could use this. Thanks
  3. How do I get my mc to be active after I animate my blitmask? I am missing just one line of code somewhere i believe. My Content:MC I am bringing in works and has active buttons. They only stopped working when I added the Blitmask for faster scrolling. But how do I get it back after the update? Thanks package com { import flash.display.MovieClip; import flash.events.*; import flash.utils.getTimer; import flash.geom.Rectangle; import flash.display.Shape; // Greensock Annimation import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; import com.greensock.plugins.TransformAroundCenterPlugin; TweenPlugin.activate([TransformAroundCenterPlugin]); TweenPlugin.activate([TransformAroundPointPlugin]); import com.greensock.plugins.CacheAsBitmapPlugin; TweenPlugin.activate([CacheAsBitmapPlugin]); TweenPlugin.activate([ThrowPropsPlugin]); public class scrollContent extends MovieClip { public var mc: MovieClip; public var bounds: Rectangle; public var MainStage: MovieClip; public var blitMask: BlitMask; public var t1: uint, t2: uint, y1: Number, y2: Number, yOverlap: Number, yOffset: Number; public function scrollContent(Content: MovieClip) { // constructor code addEventListener(Event.ADDED_TO_STAGE, init); mc = Content; } public function init(e: Event) { MainStage = this.parent as MovieClip; trace("scroll Stage: " + MainStage); bounds = new Rectangle(0, MainStage.MenuBar.height, Main_Activate._screenX, Main_Activate._screenY - MainStage.MenuBar.height); addChild(mc); blitMask = new BlitMask(mc, bounds.x, bounds.y, bounds.width, bounds.height, false); blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); } public function mouseDownHandler(event: MouseEvent): void { TweenLite.killTweensOf(mc); y1 = y2 = mc.y; yOffset = this.mouseY - mc.y; yOverlap = Math.max(0, mc.height - bounds.height); t1 = t2 = getTimer(); mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } public function mouseMoveHandler(event: MouseEvent): void { var y: Number = this.mouseY - yOffset; //if mc's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior) if (y > bounds.top) { mc.y = (y + bounds.top) * 0.5; } else if (y < bounds.top - yOverlap) { mc.y = (y + bounds.top - yOverlap) * 0.5; } else { mc.y = y; } blitMask.update(); var t: uint = getTimer(); //if the frame rate is too high, we won't be able to track the velocity as well, so only update the values 20 times per second if (t - t2 > 50) { y2 = y1; t2 = t1; y1 = mc.y; t1 = t; } event.updateAfterEvent(); } public function mouseUpHandler(event: MouseEvent): void { mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); 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 - yOverlap, resistance: 300 } }, onUpdate: blitMask.update, ease: Strong.easeOut }, 10, 0.3, 1); } } }
  4. Hi, Not sure how many questions get asked about flash these days but I have one. I have having issues on scrolling using the code below. It works but but its slow. I am thinking a "blitmask" would work great here but I don't know where I would put it. Can you give me some tips? Thanks -Ed /// SCROLL BAR /////////////////////// public function throwIt(clipContent:MovieClip) { // old code //var bounds:Rectangle = new Rectangle(_screenX - clipContent.width,0,_screenX,_screenY); // custom var var bounds:Rectangle = new Rectangle(0,0,_screenX,_screenY); //var mc:Sprite = meow.getChildByName("content") as MovieClip; var mc:Sprite = clipContent as MovieClip; addChild(mc); //some variables for tracking the velocity of mc var t1:uint,t2:uint,y1:Number,y2:Number; mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); function mouseDownHandler(event:MouseEvent):void { TweenLite.killTweensOf(mc); y1 = y2 = mc.y; t1 = t2 = getTimer(); mc.startDrag(false, new Rectangle(bounds.x, -99999, 0, 99999999)); mc.addEventListener(Event.ENTER_FRAME, enterFrameHandler); mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } function enterFrameHandler(event:Event):void { //track velocity using the last 2 frames for more accuracy y2 = y1; t2 = t1; y1 = mc.y; t1 = getTimer(); } function mouseUpHandler(event: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; var yOverlap:Number = Math.max(0,mc.height - bounds.height); ThrowPropsPlugin.to(mc, {ease:Strong.easeOut, throwProps:{y:{velocity:yVelocity, max:bounds.top , min:bounds.top - yOverlap - (littleLogo.height + littleLogo.height/3) , resistance:777}}}, 33, 0.25, .3); } } ////////////////// /// end SCROLL/////////////
  5. SOLVED: - I think So here is what I did. I made a new boolean: var flagsClickNow:Boolean = true; Then instead of using a MouseEvent.CLICK - I used a MouseEvent.MOUSE_DOWN Then I did an event listener using a MOUSE_MOVE event. If it is moving I made the boolean false so when the finger came off the button it would not triger the button. When on a mouse_up event I set the boolean back to true. So now when they click on a button while it's not moving it will go to the MC I intended. Does this make sense? Do you see any potential pitfalls? I still think you guys should do a tutorial based off of this logic Thanks Amigos!
  6. Hi guys, Thanks for the great tips. Let me try to explain what exactly I need. First I will say I did something that "kind of" helped by making the button press on the bittMask a touch event, a "tap" or a "press" mobile event. That helped a little but its still a little sketchy and I want to ensure it's the best for the users. In short my "Flag Buttons" load two by two all the way down off the screen. Each flag when "pressed" is supposed to do an action. But I want the whole bittMask to be "flickable" like the iPhone screens that have more content below... like a scroll to see the new content. I am hoping you know what I mean. Anyway, the "flick" always works but sometimes when you start the flick from a button it "flicks" but when I let go it calls the function from the button and loads that screen. I hope this makes sense. Please let me know what works best with this. I have a testFlightApp account so I can send you a demo if you need. Please email me at ed.vizenor@gmail.com and I can add your iPhone to my testing account to show you. Thanks for all your support and this great product. P.S. I think that that one of you suggested is the issue but I look at the book to read on that page and it has so many HUGE code bits and even new people posting their code for help that its hard to find out what the answer is. Perhaps JACK or you guys could do a tutorial on this subject because my guess is 90 percent of users who use throwprops on devices will want to achieve this effect on smart phones. Or maybe you could upload another thowprop example with code on it
  7. I am sure this might be a common issue but I have buttons in my mc that is being moved by throws prop with the iPhone effect. I am using eventListerners. How do I fix this issue? It is creating buttons dynamically in this function and adding dynamic event listners to each button and then finally putting them all in on MC and making it "flickable" with throwProps. Here is my code/// DECLARES flagMC var flagMC:MovieClip = new MovieClip(); var bounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight); var blitMask:BlitMask; function displayFlags(evt:Event = null) { trace("DISPLAY FLAGS---------------"); if(!Lang) { trace("No Lang!"); return; } var p:uint = 0; for (var i:uint = 0; i < Lang.length; i++) { flag = new Loader(); flag.load(new URLRequest(File.applicationStorageDirectory.url + "Languages/" + Lang + "/roundFlag.png")); flag.name = Lang; flagButton = new roundFlag(); flagButton.btext.text = Lang; addChild(flagButton); flagButton.removeChildAt(1); flagButton.addChildAt(flag,1); flag.addEventListener(MouseEvent.CLICK, loadLang(Lang,flagMC)); var fh = flagButton.getBounds(flagButton); if (i % 2){ flagButton.x = flagButton.width + flagButton.width/20; flagButton.y = fh.y * i;} else {flagButton.x = 0; trace("I is " +i); flagButton.y = fh.y * i; } // flagButton.y = fh.y * i; trace(fh.height); trace("Flag Button Height " + flag.height); flagMC.addChild(flagButton); } //addChild(flagMC); flagsIn(); flagMC.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); } //B1.addEventListener(MouseEvent.CLICK, getLang); //B2.addEventListener(MouseEvent.CLICK, displayFlags); import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; import flash.geom.Rectangle; import flash.utils.getTimer; import flash.events.MouseEvent; import flash.text.*; import flash.display.*; TweenPlugin.activate([ThrowPropsPlugin]); var t1:uint, t2:uint, y1:Number, y2:Number, yOverlap:Number, yOffset:Number; function mouseDownHandler(event:MouseEvent):void { trace("Mouse Down"); TweenLite.killTweensOf(flagMC); y1 = y2 = flagMC.y; yOffset = this.mouseY - flagMC.y; yOverlap = Math.max(0, flagMC.height - bounds.height); t1 = t2 = getTimer(); flagMC.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); flagMC.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } function mouseMoveHandler(event:MouseEvent):void { var y:Number = this.mouseY - yOffset; //if flagMC's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior) if (y > bounds.top) { flagMC.y = (y + bounds.top) * 0.5; } else if (y < bounds.top - yOverlap) { flagMC.y = (y + bounds.top - yOverlap) * 0.5; } else { flagMC.y = y; } //blitMask.update(); var t:uint = getTimer(); //if the frame rate is too high, we won't be able to track the velocity as well, so only update the values 20 times per second if (t - t2 > 50) { y2 = y1; t2 = t1; y1 = flagMC.y; t1 = t; } event.updateAfterEvent(); } function mouseUpHandler(event:MouseEvent):void { trace("Mouse Up"); flagMC.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); flagMC.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); var time:Number = (getTimer() - t2) / 1000; var yVelocity:Number = (flagMC.y - y2) / time; ThrowPropsPlugin.to(flagMC, {throwProps: { y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:300}}, //onUpdate:blitMask.update, ease:Strong.easeOut }, 10, 0.3, 1); } that causes the issue:
  8. oh wow. I just did research on blitMask. I would love to get this code working on this app. It's for a phone. I sent the fla. Can you take a look at it. I also included the code pasted but you need the files to see how it's not working. Now I want to Mast blitMask. It seems to be so fast! Thanks again.
  9. OK I GOT IT TO WORK.. . But I am worried because I just deteted and added and got WAY LUCKY!!! I am afraid this may break later and I don't know why. I would like to understand what it could hurt that I removed 2 blitMask updates. This scares me that I got luck. also the addEventlistner would NOT work as a blitMask. I had to change it to the var mc. the small changes to make it work. I had to REMOVE 2 blitMask updates and add the mc after the dot in the blitMask section. blitMask = new BlitMask(mc.flagButton, bounds.x, bounds.y, bounds.width, bounds.height, false); THE FULL CODE BEOW import flash.filesystem.File; B1.btext.text = "Press me 1st"; B2.btext.text = "Press me 2nd"; var folderLanguages:File = File.applicationDirectory.resolvePath("Languages"); var availLang:Array = folderLanguages.getDirectoryListing(); var Lang:Array; var LangPath:Array; var flagButton:MovieClip; function getLang(evt:Event) { Lang = new Array(); LangPath = new Array(); for (var i:uint = 0; i < availLang.length; i++) { if(availLang[i].isDirectory) { //trace(availLang[i].name);// gets the name Lang.push(availLang[i].name); LangPath.push(availLang[i].nativePath); trace(availLang[i].nativePath);// gets the name } } evt.target.visible = false; } var Language:MovieClip; var LangButton:MovieClip; var flag:Loader; var fh:Object; /// DECLARES MC var mc:MovieClip = new MovieClip(); var bounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight); var blitMask:BlitMask; function displayFlags(evt:Event = null) { if(!Lang) { return; } flagButton = new MovieClip(); for (var i:uint = 0; i < Lang.length; i++) { //Language = new MovieClip(); //Language.name = Lang[i]; LangButton = new button01(); LangButton.name = Lang[i]; LangButton.btext.text = Lang[i]; LangButton.y = LangButton.height * i; LangButton.btext.x = 125; addChild(LangButton); flag = new Loader(); flag.load(new URLRequest(LangPath[i]+"/flag.png")); flag.name = Lang[i]; flag.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedFlag); function loadedFlag(evt:Event) { var fh = flag.getBounds(flag); trace("FLAG HEIGHT = " + fh); trace("flag Name: "+ flag.name); trace(flag); var myFlagInfo:LoaderInfo = evt.currentTarget as LoaderInfo; var myFlag:Loader = myFlagInfo.loader; myFlag.y = (LangButton.height/2) - (flag.height/2); } LangButton.addChild(flag); flagButton.addChild(LangButton); } evt.target.visible = false; addChild(flagButton); addChild(mc); mc.addChild(flagButton); blitMask = new BlitMask(mc.flagButton, bounds.x, bounds.y, bounds.width, bounds.height, false); mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); } B1.addEventListener(MouseEvent.CLICK, getLang); B2.addEventListener(MouseEvent.CLICK, displayFlags); import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; import flash.geom.Rectangle; import flash.utils.getTimer; import flash.events.MouseEvent; import flash.text.*; import flash.display.*; TweenPlugin.activate([ThrowPropsPlugin]); var t1:uint, t2:uint, y1:Number, y2:Number, yOverlap:Number, yOffset:Number; function mouseDownHandler(event:MouseEvent):void { trace("Mouse Down"); TweenLite.killTweensOf(mc); y1 = y2 = mc.y; yOffset = this.mouseY - mc.y; yOverlap = Math.max(0, mc.height - bounds.height); t1 = t2 = getTimer(); mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } function mouseMoveHandler(event:MouseEvent):void { var y:Number = this.mouseY - yOffset; //if mc's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior) if (y > bounds.top) { mc.y = (y + bounds.top) * 0.5; } else if (y < bounds.top - yOverlap) { mc.y = (y + bounds.top - yOverlap) * 0.5; } else { mc.y = y; } //blitMask.update(); var t:uint = getTimer(); //if the frame rate is too high, we won't be able to track the velocity as well, so only update the values 20 times per second if (t - t2 > 50) { y2 = y1; t2 = t1; y1 = mc.y; t1 = t; } event.updateAfterEvent(); } function mouseUpHandler(event:MouseEvent):void { mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); 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 - yOverlap, resistance:300}}, //onUpdate:blitMask.update, ease:Strong.easeOut }, 10, 0.3, 1); }
  10. Hummm ok Let's try this. Can you help me? This is all I am trying to do. I need to figure out a way to get MC's "like this" in the future into your awesome plugin and working. In this case I need to have the MC called "flagButton" controlled by greensock. I am including a link to the zipped folder you you can test it. http://www.massmediamail.com/testing/GreensockRocks.zip Here is my code alone: import flash.filesystem.File; B1.btext.text = "Press me 1st"; B2.btext.text = "Press me 2nd"; var folderLanguages:File = File.applicationDirectory.resolvePath("Languages"); var availLang:Array = folderLanguages.getDirectoryListing(); var Lang:Array; var LangPath:Array; var flagButton:MovieClip; function getLang(evt:Event) { Lang = new Array(); LangPath = new Array(); for (var i:uint = 0; i < availLang.length; i++) { if(availLang[i].isDirectory) { //trace(availLang[i].name);// gets the name Lang.push(availLang[i].name); LangPath.push(availLang[i].nativePath); trace(availLang[i].nativePath);// gets the name } } evt.target.visible = false; } var Language:MovieClip; var LangButton:MovieClip; var flag:Loader; var fh:Object; function displayFlags(evt:Event = null) { if(!Lang) { return; } flagButton = new MovieClip(); for (var i:uint = 0; i < Lang.length; i++) { //Language = new MovieClip(); //Language.name = Lang[i]; LangButton = new button01(); LangButton.name = Lang[i]; LangButton.btext.text = Lang[i]; LangButton.y = LangButton.height * i; LangButton.btext.x = 125; addChild(LangButton); flag = new Loader(); flag.load(new URLRequest(LangPath[i]+"/flag.png")); flag.name = Lang[i]; flag.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedFlag); function loadedFlag(evt:Event) { var fh = flag.getBounds(flag); trace("FLAG HEIGHT = " + fh); trace("flag Name: "+ flag.name); trace(flag); var myFlagInfo:LoaderInfo = evt.currentTarget as LoaderInfo; var myFlag:Loader = myFlagInfo.loader; myFlag.y = (LangButton.height/2) - (flag.height/2); } LangButton.addChild(flag); flagButton.addChild(LangButton); } evt.target.visible = false; addChild(flagButton); } B1.addEventListener(MouseEvent.CLICK, getLang); B2.addEventListener(MouseEvent.CLICK, displayFlags); I need to master this concept and I was trying to use your example and change things based off of what I thought might work. Thus it got really messy. Thanks for your help and the great plugin.
  11. Thanks for the update. I got excited, sadly I am getting this error after adding that code right after the addchild TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.greensock::BlitMask/update()[C:\User\yadaya\com\greensock\BlitMask.as:295] For Example: mc = new MovieClip; addChild(mc); blitMask.update(null,true); mc.addChild(flagButton); mc.alpha = .3; is not working... the alpha works when I don't add a my.addChildren(flagbutton);
  12. I am really bummed its not easy to find an example of how to use throwProps with a movie clip. Is there an example or several to see or use? When where we can have a menu button like the iphone... or the MovieClip flicks as if it was text but its a movieclip Thanks
  13. Ok I figured some of it. I got my mc to move via throwprops, HOWEVER, now my flags are gone. I am loading a dynamicly loaded mc and dynamically loaded flags. I know I am doing it right. This must be an error in greensock script perhaps? Its not showing children of children? import flash.filesystem.File; var folderLanguages:File = File.applicationDirectory.resolvePath("Languages"); var availLang:Array = folderLanguages.getDirectoryListing(); var Lang:Array; var LangPath:Array; var flagButton:MovieClip; function getLang(evt:Event) { Lang = new Array(); LangPath = new Array(); for (var i:uint = 0; i < availLang.length; i++) { if(availLang[i].isDirectory) { //trace(availLang[i].name);// gets the name Lang.push(availLang[i].name); LangPath.push(availLang[i].nativePath); trace(availLang[i].nativePath);// gets the name } } evt.target.visible = false; } var Language:MovieClip; var LangButton:MovieClip; var flag:Loader; var fh:Object; var mc:Sprite; var bounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight); //setupTextField(mc, bounds); var blitMask:BlitMask = new BlitMask(mc, bounds.x, bounds.y, bounds.width, bounds.height, false); var t1:uint, t2:uint, y1:Number, y2:Number, yOverlap:Number, yOffset:Number; function displayFlags(evt:Event = null) { if(!Lang) { return; } flagButton = new MovieClip(); addChild(flagButton); mc = new MovieClip(); addChild(mc); for (var i:uint = 0; i < Lang.length; i++) { //Language = new MovieClip(); //Language.name = Lang[i]; LangButton = new button01(); LangButton.name = Lang[i]; LangButton.btext.text = Lang[i]; LangButton.y = LangButton.height * i; LangButton.btext.x = 125; addChild(LangButton); flag = new Loader(); flag.load(new URLRequest(LangPath[i]+"/flag.png")); flag.name = Lang[i]; flag.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedFlag); function loadedFlag(evt:Event) { var fh = flag.getBounds(flag); trace("FLAG HEIGHT = " + fh); trace("flag Name: "+ flag.name); trace(flag); var myFlagInfo:LoaderInfo = evt.currentTarget as LoaderInfo; var myFlag:Loader = myFlagInfo.loader; myFlag.y = (LangButton.height/2) - (flag.height/2); } LangButton.addChild(flag); flagButton.addChild(LangButton); flagButton.alpha = .3; mc.addChild(flagButton); } evt.target.visible = false; bounds = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight); //setupTextField(mc, bounds); blitMask = new BlitMask(mc, bounds.x, bounds.y, bounds.width, bounds.height, false); //t1:uint, t2:uint, y1:Number, y2:Number, yOverlap:Number, yOffset:Number; blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); } import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; import flash.geom.Rectangle; import flash.utils.getTimer; import flash.events.MouseEvent; import flash.text.*; import flash.display.*; TweenPlugin.activate([ThrowPropsPlugin]); function mouseDownHandler(event:MouseEvent):void { TweenLite.killTweensOf(mc); y1 = y2 = mc.y; yOffset = this.mouseY - mc.y; yOverlap = Math.max(0, mc.height - bounds.height); t1 = t2 = getTimer(); mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } function mouseMoveHandler(event:MouseEvent):void { var y:Number = this.mouseY - yOffset; //if mc's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior) if (y > bounds.top) { mc.y = (y + bounds.top) * 0.5; } else if (y < bounds.top - yOverlap) { mc.y = (y + bounds.top - yOverlap) * 0.5; } else { mc.y = y; } blitMask.update(); var t:uint = getTimer(); //if the frame rate is too high, we won't be able to track the velocity as well, so only update the values 20 times per second if (t - t2 > 50) { y2 = y1; t2 = t1; y1 = mc.y; t1 = t; } event.updateAfterEvent(); } function mouseUpHandler(event:MouseEvent):void { mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); 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 - yOverlap, resistance:300} }, onUpdate:blitMask.update, ease:Strong.easeOut }, 10, 0.3, 1); } B1.addEventListener(MouseEvent.CLICK, getLang); B2.addEventListener(MouseEvent.CLICK, displayFlags);
  14. thanks for the awesome tip. I was sooo sleepy when I posted this. I could not even think to hit enter. Anyway, that seemed to do it but for some reason throwprops is not picking it up. Its not moving. The alpha for flagButton works but its not being moved by throwProps. Not sure why. I have Maybe there is something blocking it? Humm I know the script is connected properly because I tested it with the movieClip B1 and it work. .
×