A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Preloader percentage in feet and inches.

  1. #1
    Junior Member
    Join Date
    Jan 2009
    Posts
    21

    Preloader percentage in feet and inches.

    Hi, so I've been trying to work this out on my own and have just completely failed, what I'm trying to do is have to numbers count up to 6' by feet and inches, it would be easy enough to animate, but I can't seem to wrap my head around Flash's math functions.

    Right now I have the feet and inches in two separate dynamic text boxes ("feettext" and "inchestext") nested inside the main loader movieclip, I've got the feet counting up fine, but I can't get the inches to count to 11 then repeat.

    Any help would be much appreciated, thanks.

    Flash version CS4, Actionscript 2, preloader tutorial I used here.

  2. #2
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    can you post your code for the feet/inches conversion?
    Z¡µµ¥ D££

    Soup In A Box

  3. #3
    Junior Member
    Join Date
    Jan 2009
    Posts
    21
    Quote Originally Posted by sadspectacle View Post
    Hi, so I've been trying to work this out on my own and have just completely failed, what I'm trying to do is have to numbers count up to 6' by feet and inches, it would be easy enough to animate, but I can't seem to wrap my head around Flash's math functions.

    Right now I have the feet and inches in two separate dynamic text boxes ("feettext" and "inchestext") nested inside the main loader movieclip, I've got the feet counting up fine, but I can't get the inches to count to 11 then repeat.

    Any help would be much appreciated, thanks.

    Flash version CS4, Actionscript 2, preloader tutorial I used here.


    Whoops, in my hasty stupidity, I forgot to upload my .fla.
    Attached Files Attached Files

  4. #4
    Junior Member
    Join Date
    Jan 2009
    Posts
    21
    Quote Originally Posted by ZippyDee View Post
    can you post your code for the feet/inches conversion?
    Here's what I've got right now, and it by no means works.

    Code:
    this.onEnterFrame = function () {
    	var ammount:Number = getBytesLoaded() / this.getBytesTotal() *100
        loader.feettext.text = Math.round (ammount *72 /12);
    	loader.inchestext.text = Math.round (ammount);
    	loader._xscale = ammount;
    	loader._yscale = ammount;
    	if(ammount == 100) {
    		this.gotoAndPlay(3);
    		delete this.onEnterFrame;
    	}
    }

  5. #5
    Senior Member
    Join Date
    Dec 2009
    Posts
    109

    Smile

    feet = 0;
    inch = 0;
    onEnterFrame = function(){
    inch+=1/30;
    if(inch >= 11.5){
    inch = 0;
    feet+=1;
    }
    total.text = feet+"' "+Math.round(inch)+"''";
    }
    You can make one box called "total".
    Syntax Error

  6. #6
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    Code:
    var feet=(6*ammount)/100;
    var inches=Math.floor(12*(feet-Math.floor(feet)));
    feet=Math.floor(feet);
    loader.feettext.text=feet + "'";
    loader.inchestext.text=inches + "\""
    Any questions?
    Last edited by ZippyDee; 12-07-2009 at 11:19 PM.
    Z¡µµ¥ D££

    Soup In A Box

  7. #7
    Junior Member
    Join Date
    Jan 2009
    Posts
    21
    Quote Originally Posted by ZippyDee View Post
    Code:
    var feet=(6*ammount)/100;
    var inches=Math.floor(12*(feet-Math.floor(feet)));
    feet=Math.floor(feet);
    loader.feettext.text=feet + "'";
    loader.inchestext.text=inches + "\""
    Any questions?
    Thank you very much!

  8. #8
    var x:Number = 1; x /= 0;
    Join Date
    Dec 2004
    Posts
    549
    No problem

    If you have any other questions, you can just ask!
    Z¡µµ¥ D££

    Soup In A Box

  9. #9
    Junior Member
    Join Date
    Jan 2009
    Posts
    21
    Quote Originally Posted by ZippyDee View Post
    No problem

    If you have any other questions, you can just ask!
    Aha! You shouldn't have given me that freedom!

    Actually, I do have a question, is there any way that I (and by that, I mean you) could get rid of the zero?

    Edit: you know, so it wouldn't say like 0'6". It would just say 6".

  10. #10
    Bacon-wrapped closures Nialsh's Avatar
    Join Date
    Dec 2003
    Location
    Houston!
    Posts
    338
    This should do it.
    Code:
    var feet=(6*ammount)/100;
    var inches=Math.floor(12*(feet-Math.floor(feet)));
    feet=Math.floor(feet);
    if(feet == 0)
      loader.feettext.text="";
    else
      loader.feettext.text=feet + "'";
    loader.inchestext.text=inches + "\""

  11. #11
    Junior Member
    Join Date
    Jan 2009
    Posts
    21
    Quote Originally Posted by Nialsh View Post
    This should do it.
    Code:
    var feet=(6*ammount)/100;
    var inches=Math.floor(12*(feet-Math.floor(feet)));
    feet=Math.floor(feet);
    if(feet == 0)
      loader.feettext.text="";
    else
      loader.feettext.text=feet + "'";
    loader.inchestext.text=inches + "\""
    Works perfectly, thanks mate!

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