A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: Wheel of fortune Random spin

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    6

    Wheel of fortune Random spin

    Looking to make this wheel spin randomly when clicked. Any help is appreciated
    The goal is to put in a smart board file, so i'd like to have the background of the wheel transparent
    Attached Images Attached Images

  2. #2
    Teacosy is coming ranoka's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    123
    Hmm.
    I'd try putting the registration point at the center of the wheel, and use the rotation property to spin it. If you have so that every frame is slows it down a bit (reduce the spinning speed that it's rotated by), if you start with a random spinning speed, then it will stop somewhere different each time it comes to a halt.

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    6
    I really haven't learned enough to know what your talking about. I agree that the wheel should spin in the center, but no idea how. Yes, I would like to have it random
    Quote Originally Posted by ranoka
    Hmm.
    I'd try putting the registration point at the center of the wheel, and use the rotation property to spin it. If you have so that every frame is slows it down a bit (reduce the spinning speed that it's rotated by), if you start with a random spinning speed, then it will stop somewhere different each time it comes to a halt.

  4. #4
    Junior Member
    Join Date
    Oct 2008
    Posts
    3
    What script are u using?

  5. #5
    Junior Member
    Join Date
    Oct 2008
    Posts
    6
    Quote Originally Posted by pgasson
    What script are u using?
    I have CS3 so I could use action script 1 2 or 3, doesn't matter to me

  6. #6
    Junior Member
    Join Date
    Oct 2008
    Posts
    3
    Make a movie clip of the wheel and put it on the stage and give it an instance name of 'wheel'. Then in the first frame of a script layer type in this:

    wheel.addEventListener(MouseEvent.MOUSE_DOWN, spin);

    function spin(e:MouseEvent)
    {
    import fl.transitions.*;
    import fl.transitions.easing.*;

    TransitionManager.start(wheel, {type:Rotate, direction:Transition.IN *Math.random(), duration:Math.random() *10, easing:Regular.easeInOut, ccw:false, degrees:Math.random()*1200});
    }

    Only problem is that it always finishes in the same place and I do not know how to rectify this.

  7. #7
    Junior Member
    Join Date
    Oct 2008
    Posts
    6
    Quote Originally Posted by pgasson
    Make a movie clip of the wheel and put it on the stage and give it an instance name of 'wheel'. Then in the first frame of a script layer type in this:

    wheel.addEventListener(MouseEvent.MOUSE_DOWN, spin);

    function spin(e:MouseEvent)
    {
    import fl.transitions.*;
    import fl.transitions.easing.*;

    TransitionManager.start(wheel, {type:Rotate, direction:Transition.IN *Math.random(), duration:Math.random() *10, easing:Regular.easeInOut, ccw:false, degrees:Math.random()*1200});
    }

    Only problem is that it always finishes in the same place and I do not know how to rectify this.
    Thanks, that's a good start. Anyone know what i can do to make it random?

  8. #8
    :
    Join Date
    Dec 2002
    Posts
    3,518
    AS2 code...
    Code:
    function spinIt() {
    	var mc = this;
    	if (!mc.spinning) {
    		mc.spinning = true;
    		var easeType = mx.transitions.easing.Regular.easeOut;
    		var spinTime = Math.min(12.2, Math.max(2.12, ((getTimer() - mc.startTime) / 100)));
    		var endRot = Math.round((spinTime * 360) + (Math.random() * 360));
    		myTween = new mx.transitions.Tween(mc, "_rotation", easeType, mc._rotation, endRot, spinTime, true);
    		myTween.onMotionFinished = function() {
    			mc.spinning = false;
    			//trace("done");
    		};
    	}
    }
    wheel.spinning = false;
    wheel.onPress = function() {
    	this.startTime = getTimer();
    };
    wheel.onRelease = spinIt;

  9. #9
    Junior Member
    Join Date
    Oct 2008
    Posts
    6
    Awesome! Thank you!!
    Attached Files Attached Files
    Last edited by daveguenther; 10-27-2008 at 12:37 PM.

  10. #10
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code needs to be on the main timeline, not on the wheel. Also make sure the symbol 'wheel' has an instance name of 'wheel'.

  11. #11
    Junior Member
    Join Date
    Oct 2008
    Posts
    6
    I am also making flash buttons for the letters. I have 2 key frames one with the green wheel of fortune symbol and the next with the a letter of the alphabet to be revealed.

    I have converted the first frame 'mask' to a symbol button. I would like to press it and have the next frame revealed.

    Any thoughts on code?

  12. #12
    :
    Join Date
    Dec 2002
    Posts
    3,518

    Maybe you can adapt this to what you are trying to do...

    See attached files...
    Last edited by dawsonk; 11-14-2008 at 04:06 PM.

  13. #13
    Junior Member
    Join Date
    May 2005
    Posts
    2

    wheel of fortune

    hi can you attach the files for review?

  14. #14
    Junior Member
    Join Date
    May 2005
    Posts
    2
    where are the files

  15. #15
    Junior Member
    Join Date
    Aug 2011
    Posts
    2

    Thank you

    Quote Originally Posted by dawsonk View Post
    Code needs to be on the main timeline, not on the wheel. Also make sure the symbol 'wheel' has an instance name of 'wheel'.
    Hello Dawkson, First of all thanks for all the help, I used the Actionscript that you created , to do a wheel of fortune for a project, everything is working perfectly, exept for the fact that I need it to spin without the onPress and onRelease,
    is there any way to do this click automatically , or to make the wheel of fortune spin after 3 seconds..

    Thank you, I hope you can reply to this, I know its an old post

  16. #16
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    So, I like helped someone with a similar problem, making a Spinner, 1 or 2 months ago, and I've edited the code to suit your needs

    It's just a movieclip with the Wheel of Fortune/Spinner, and all the codes are on the Frame. The 3 Second start over is already implemented, so Enjoy
    Attached Files Attached Files
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  17. #17
    Junior Member
    Join Date
    Aug 2011
    Posts
    2

    Thumbs up Thank You!

    Quote Originally Posted by Nig 13 View Post
    So, I like helped someone with a similar problem, making a Spinner, 1 or 2 months ago, and I've edited the code to suit your needs

    It's just a movieclip with the Wheel of Fortune/Spinner, and all the codes are on the Frame. The 3 Second start over is already implemented, so Enjoy
    Nig 13 thank you very much, You saved my life and my computers life, because I was about to throw it out through the window!! Thank you again for your help, and fast response.
    By the way, would you recommend any good books or webpages where i could learn more about ActionScript?

    Thanks Again

  18. #18
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Quote Originally Posted by glrocha View Post
    Nig 13 thank you very much, You saved my life and my computers life, because I was about to throw it out through the window!! Thank you again for your help, and fast response.
    By the way, would you recommend any good books or webpages where i could learn more about ActionScript?

    Thanks Again
    Haha, glad to hear I prevented something awful to happen xD

    Books? I honestly don't know, because I learned Actionscript through online Tutorials, Forums like this one, so basically just the internet, and some time

    If you start looking at tutorials or learn new things, and are doubting something, just come here and ask a question, and we'll try to answer it and help you understand actionscript, more and more
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center