Jump to content
Search Community

Benjamin Waller

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by Benjamin Waller

  1. Hi there, Very nice Rotation effect. I am playing around with this example because I'm trying to get the dial to slowly rotate around when the mouse isn't down on the object. However, I'm getting the following error ArgumentError: Error #1063: Argument count mismatch on starters_App_fla::MainTimeline/startAgain(). Expected 1, got 0. Here's greensock's code with a few additions: import com.greensock.*; import com.greensock.plugins.*; import com.greensock.easing.*; import flash.events.MouseEvent; import flash.geom.Rectangle; import flash.utils.getTimer; import flash.display.*; import flash.events.Event; TweenPlugin.activate([ThrowPropsPlugin]); dial.buttonMode = true; var RAD2DEG:Number = 180 / Math.PI; var t1:uint, t2:uint, r1:Number, r2:Number, offset:Number; dial.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); dial.addEventListener(Event.ENTER_FRAME, noMouseDownHandler); ////to rotate the object when move is up////// function noMouseDownHandler(event:Event):void { TweenMax.to(dial, 35, {rotation:"350", timeScale:0.01, useFrames:true, repeat:-1, ease:Linear.easeNone}); } function mouseDownHandler(event:MouseEvent):void { dial.removeEventListener(Event.ENTER_FRAME, noMouseDownHandler); TweenLite.killTweensOf(dial); offset = Math.atan2(dial.y - this.mouseY, this.mouseX - dial.x); r1 = r2 = dial.rotation; t1 = t2 = getTimer(); dial.addEventListener(Event.ENTER_FRAME, enterFrameHandler); dial.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); } function enterFrameHandler(event:Event):void { r2 = r1; t2 = t1; var newOffset:Number = Math.atan2(dial.y - this.mouseY, this.mouseX - dial.x); dial.rotation += (offset - newOffset) * RAD2DEG; offset = newOffset; r1 = dial.rotation; t1 = getTimer(); } function mouseUpHandler(event:MouseEvent):void { dial.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler); dial.removeEventListener(Event.ENTER_FRAME, enterFrameHandler); var time:Number = (getTimer() - t2) / 1000; var rVelocity:Number = getShortAngle(dial.rotation, r2, false) / time; var max:Number = 145; var min:Number = 0; var resistance:Number = 250; //calculate the duration so that we can plug it into the calculateChange() method to find out where exactly the rotation will end up if we don't apply any limits (max/min) var duration:Number = ThrowPropsPlugin.calculateTweenDuration(dial, {throwProps:{rotation:rVelocity, resistance:resistance}, ease:Strong.easeOut}, 10, 0.25, 2); //figure out where it'll land normally var landingValue:Number = dial.rotation + ThrowPropsPlugin.calculateChange(rVelocity, Strong.easeOut, duration); //translate the end rotation into a value between 0 and 360 var normalized:Number = landingValue % 360; if (normalized < 0) { normalized += 360; } if (normalized < min || normalized > max) { //figure out the angle to the min and the max and then whichever one is less (shorter distance), we'll snap the end value to that one. var angleToMin:Number = getShortAngle(normalized, min, false); var angleToMax:Number = getShortAngle(normalized, max, false); if (Math.abs(angleToMin) < Math.abs(angleToMax)) { landingValue -= angleToMin; } else { landingValue -= angleToMax; } } ThrowPropsPlugin.to(dial, {throwProps:{rotation:{velocity:rVelocity, min:landingValue, max:landingValue}, resistance:resistance}, ease:Strong.easeOut, onComplete:startAgain}, 10, 0.25, 2); //This was the normal tween with no min/max //ThrowPropsPlugin.to(dial, {throwProps:{rotation:{velocity:rVelocity}, resistance:250}, ease:Strong.easeOut}, 10, 0.25, 2); } //////to start the slow rotation again after the ThrowProps has finished /////// function startAgain(event:Event):void { dial.addEventListener(Event.ENTER_FRAME, noMouseDownHandler); } function getShortAngle(angle1:Number, angle2:Number, useRadians:Boolean=false):Number { var cap:Number = useRadians ? Math.PI * 2 : 360; var dif:Number = angle1 - angle2; if (dif != dif % (cap / 2)) { dif += (dif < 0) ? cap : -cap; } return dif; } Any help much appreciated. Ben.
  2. Hi Vic, I really like your info box animations and scroll down info panels as well from the link you posted . Have you set up a toolTip class to achieve this? Just interested to see how you'd done it. Nice work. Ben.
  3. Thank you. Gosh. I wasn't thinking it was the event listeners at all. Silly me. This platform is the best! Thanks again. Your time is much appreciated. Cheers, Ben.
  4. hello, I have a glowFilter issue I wish to get some advice on. The issue is with a MC which consists of a bitmap image layered on vector graphics and the problem is I can't seem to get the glowFilter to work properly WHEN MOUSING OVER THE IMAGE ITSELF. I have attached an example of the problem. One MC works fine while the other doesn't. Container1 (left on stage) Is a MovieClip instance of imported assets from Illustrator with all the graphics as a single bitmap image but in doing so I lost the quality of the image and of course you can't scale it up etc… However this glow filter effect works as expected. Container2 (right on stage) Is a MovieClip instance of imported assets with layered vector graphics and a bitmap image sitting on top. All layers were separate when importing from Illustrator. This one has kept its full pixel image quality but the glow filter doesn't work when you mouse over the bitmap image itself, very strange? However, I do get the glow effect to work when the mouse is at the very edge(because there is a thin lip of the container around the edge) and on the top of the container where there is on image. Any suggestions? If anyone has a chance to look at the file it may be easier to diagnose. Cheers, Ben
  5. That's great Carl. It's working spot on! I'm starting to understand now and thank you for your generosity to respond and share your knowledge here. The rewinding bit was crucial, gotoSoundTime(0, true) Again, thanks I'm very grateful to you. I really value all these small steps in the learning process and it's people like yourself and Jack here who make that possible. Cheers, Ben.
  6. Hi, I want to be able to have 2 short mp3 sound files play sequentially, one after the other with about 1 second delay/gap between them. This is my code so far but of course it's not working. Please help. In addition, I have a replaying issue. If I click on the button once then the sound plays once but if you click again, not sound? How can I reload/reactivate the sound files to play each and every time you click on the button? var sound1:MP3Loader = new MP3Loader("SweetAlertSound1.mp3", {autoPlay:false}); var sound2:MP3Loader = new MP3Loader("Spring_1.mp3", {autoPlay:false}); var queue:LoaderMax = new LoaderMax(); queue.append(sound1); queue.append(sound2); queue.load(); button.addEventListener(MouseEvent.CLICK, buttonHandler); function buttonHandler(e:MouseEvent):void { sound1.playSound(); //TweenLite.delayedCall(sound1, 3, {onComplete:playsecondSound}); ///I was thinking about using the delayedCall here and then an onComplete function to be able to play the next sound. } function playsecondSound(e:LoaderEvent):void{ sound2.playSound(); }*/ Ben.
  7. Fantastic Carl. works like a dream.Thank you very much. I do have another problem to resole round loading and playing sound files. I posted a comment on your tutorial page http://www.snorkl.tv/2011/07/easy-as3-toggle-and-fade-sound-with-tweenlite-volume-plugin/#more-1127 a few weeks back but since then I've done a little research and I've made some progress so I'll post what I'm up to and where the issues are now. But maybe I'll post it in a new thread not to confuse this one. Cheers Carl. Ben.
  8. Oh sorry. My mistake. I thought it was included. Thanks. That change fixed up the error message. But I still can't get the crosses and ticks to appear on stage>? There must be something wrong with the as file. I'm having trouble uploading the .AS file so see a copy of it below. Cheers Ben. package { import flash.events.*; import flash.display.InteractiveObject; public class ButtonSequencer extends EventDispatcher { public static const CORRECT:String = "correct"; public static const INCORRECT:String = "incorrect"; private var buttonArray:Array; private var currentIndex:int = 0; private var currentButton:InteractiveObject; public function ButtonSequencer(arrayOfButtons:Array) { buttonArray = arrayOfButtons; for(var i:int = 0; i < buttonArray.length; i++) { buttonArray[i].addEventListener(MouseEvent.CLICK, button_onClick); } } private function button_onClick(event:MouseEvent):void { //save a reference to the button that was clicked: currentButton = InteractiveObject(event.currentTarget); if(currentButton == buttonArray[currentIndex]) { //the correct button was clicked dispatchEvent(new Event(ButtonSequencer.CORRECT)); currentIndex++; if(currentIndex > buttonArray.length - 1) { reset(); } } else { //the wrong button was clicked dispatchEvent(new Event(ButtonSequencer.INCORRECT)); } } public function get lastClicked():InteractiveObject { return currentButton; } public function reset():void { currentIndex = 0; } public function set enabled(value:Boolean):void { for(var i:int = 0; i < buttonArray.length; i++) { if(value == true) { buttonArray[i].addEventListener(MouseEvent.CLICK, button_onClick); } else { buttonArray[i].removeEventListener(MouseEvent.CLICK, button_onClick); } } } } }
  9. Hello. I want to use TweenLite to display 'ticks & crosses' on stage to represent correct & incorrect click/selection from the user. But I'm not having much luck. I have make some progress.I am using a ButtonSequencer class file, also see attached, to get the correct & incorrect responses for 2 selections with the use of event dispatching. It uses the public getter method called lastClicked to get a reference to the last button that was clicked.. See .AS & .FLA example files attached. On good advice, I have tried isolating the issue in a separate FLA for easier trouble shooting but have only ended up getting an addition issue. See output panel message below. ArgumentError: Error #1063: Argument count mismatch on button_sequence_fla::MainTimeline/removeCross(). Expected 1, got 0. at Function/http://adobe.com/AS3/2006/builtin::apply() at com.greensock.core::TweenCore/complete() at com.greensock::TweenLite/renderTime() at com.greensock::TimelineLite/forceChildrenToEnd() at com.greensock::TimelineLite/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll() What I want to be able to do: 1. Display ticks when correct buttons are clicked in the correct sequence 2. Display crosses when wrong buttons are clicked in the wrong sequence 3. Remove ticks after a short time on stage 4. Remove crosses after a short time on stage Hope someone could give me some pointers.. Cheers, Ben.
  10. Hi again, Is this the correct way to activate the colourTransform Plugin. It's not working for me and I'm getting the following message in the output panel. Scene 1, Layer 'AS', Frame 1, Line 5 1120: Access of undefined property TweenPlugin. import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.ColorTransformPlugin; TweenPlugin.activate(ColorTransformPlugin); Ben.
  11. Hi Carl, Was interested to know more about the tint property you have used in your example here on the Orange button mc. I wasn't able to see a change when I altered the amount of tint? Was the tint supposed to change here because I can't see any ? and I'm sure I'm not colour blind. hehe TweenMax.to(orangeBtn_mc, .3, {colorTransform:{tint:0xffff66, tintAmount:0.25}}); love your work ! Keep it up. Cheers, Ben.
  12. Thanks for your replies. Actually, I took the target placeholder mc out of the other container mc and put it on top and the following code worked. Sorry to confuse you! I was complicating things when it didn't need to be. Thanks again. TweenLite.to(em_Word, 1, {x:mc_Target, y:mc_Target, ease:Quad.easeInOut});
  13. Yeah, I've got at nested moiveclip. I mean, one within another so I want to refer to the destination position of the inner mc but target the mc. For example: mc_Container.mc_Inner So the target values here( x:441.00, y:355.0) is just the exact position on stage where that mc is but I want the tween to target the mc_inner MoiveClip itself on the stage. TweenLite.to(em_Word, 1, {x:441.00, y:355.00, ease:Quad.easeInOut}); So for example:Can I do this? TweenLite.to(em_Word, 1, {mc_container.mc_Inner, ease:Quad.easeInOut});
  14. Hello, I have set up an example of a nice tween, thanks Greensock, that uses the x and y values like in the dynamicProps example on your site and it works fine. See my code below. But I want to be able to reference my MC's position using its name instead so that I could change it's position on the stage but it will still tween to the correct spot wherever it is without having to change the x & y properties. Could anyone help me to do this? Ben. em_Mc.addEventListener(MouseEvent.CLICK, clickHandler); em_Mc.buttonMode = true; function clickHandler(event:MouseEvent):void { TweenLite.to(em_Word, 1, {x:441.00, y:355.00, ease:Quad.easeInOut}); }
×
×
  • Create New...