PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
ProgressBar
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: ProgressBar

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    27

    ProgressBar

    Hi guys,

    I want to make a progressbar. I got a blanc bar and I want to let a red bar grow (from left to right).

    I got this code so far:

    Actionscript Code:
    var StartDatum:Date = new Date(2011, 01, 16, 09, 05, 15, 0);
    var EindDatum:Date = new Date(2011, 01, 16, 11, 05, 15, 0);
    var TotaleTijd = EindDatum.getTime() - StartDatum.getTime();

     

    var MijnTimer:Timer = new Timer(1000);


    MijnTimer.addEventListener(TimerEvent.TIMER, Detijd);
    MijnTimer.start();

     

    function Detijd(e:TimerEvent=null):void {

           
         var Nu:Date = new Date();    
         var TijdOver:Number = Nu.getTime() - StartDatum.getTime();
         var Voortgang:Number = TijdOver / TotaleTijd;
         rodelijn.scaleX = Voortgang;
         
    }
    Detijd();

    No error but nothing is happening...

    Can somebody help me out with this?

    Tnx

  2. #2
    Member
    Join Date
    Mar 2003
    Location
    The Netherlands
    Posts
    61
    Something should be happening with that script, but the variable 'Voortgang' has VERY small changes, so it would be hard to spot the 'rodelijn' growing.

    I'm thinking it has to do with the 'StartDatum' and 'EindDatum' as they are set for january 16th, perhaps you meant to use ( 2011, 02, 16 ) ???

    Perhaps it's unclear what you're trying to measure with this script, can you elaborate a bit ?

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    27
    Hi,

    Tnx for thinking with me... 01 is February because it start with 00 and that is January.
    I put the Start and End Date closer and there is some movement but not the movement I want... It has to grow as a line... now its just growing a little bit on each side...

    Sorry for the bad english... not my mother language(a)

  4. #4
    Junior Member
    Join Date
    Feb 2010
    Posts
    27
    Hey Guys,

    My progress bar is working ok now but cant get this bus to the right position.

    code:

    var StartDatumate = new Date(2011, 01, 16, 17, 19, 0, 0);
    var EindDatumate = new Date(2011, 01, 16, 22, 0, 0, 0);
    var TotaleTijd = EindDatum.getTime() - StartDatum.getTime();



    var MijnTimer:Timer = new Timer(1000);


    MijnTimer.addEventListener(TimerEvent.TIMER, Detijd);
    MijnTimer.start();



    function Detijd(e:TimerEvent=null):void {

    var Nuate = new Date();
    var TijdOver:Number = Nu.getTime() - StartDatum.getTime();
    var Voortgang:Number = TijdOver / TotaleTijd;
    bus.x = stage.stageWidth * Voortgang;
    lijn.scaleX = Voortgang;

    }
    Detijd();




    The bus is working the same as my progress bar. The bus is moving the whole width of the stage but I want to give it a start and end position so that he is moving between the start en end point.

    Lets say he starts about 200px from the left and his end position is about 200px from the right... How can I manage this?

  5. #5
    Member
    Join Date
    Oct 2010
    Posts
    55
    try this:

    PHP Code:
    bus.xz*(Voortgang); 

    where z is your desired x position.

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    27
    Hi,

    I tried that but it wont work...

    I got this for the end point

    PHP Code:
     bus.= (stage.stageWidth 200) * Voortgang
    That is working because the stage is 200px shorter now...

    The start point is not working... I dont know how to do it...

    I tried this:

    PHP Code:
    car.100 *(Voortgang); 
    and this

    PHP Code:
    car.100 stage.stageWidth Voortgang
    But nothing will work...

    Can somebody help me out here

    Tnx

  7. #7
    Member
    Join Date
    Mar 2003
    Location
    The Netherlands
    Posts
    61
    If I understand correctly, you want to have the bus start a desired position and end at another, i.e. start position = x200 and end position is 200 px from the right of the stage.

    That means you have to calculate the range it has to travel

    Actionscript Code:
    var startPoint:int = 200;
    var endPoint:int = stage.stageWidth - 200;
    var totalDistance:int = endPoint - startPoint;

    and match this range against the time range ( i.e. the starttime should have the bus set at it's startPoint, and the endtime should have the bus set at it's endpoint ), to do this you must find a multiplier as the time range is a lot larger than the pixels necessary for the bus to travel!

    Actionscript Code:
    var ratio:Number = totalDistance / TotaleTijd;

    You then use this ratio to set bus position accordingly to the time that has passed:

    So, let's say the time range from start to end is 4000 ( which would be a ridiculously small 4 seconds, but it's an example ). And your stage width is 900 pixels, which would mean the endpoint is at ( 900 - 200 ) 700 pixels.

    4000 ms should match up with 700 px. The ratio for this is:

    700 / 4000 = .175;

    so after 3000 ms have passed, the distance on the X scale would be 3000 * .175 = 525 px, which is indeed 75 % of the total distance. Whoop, it matches.

    I'd also calculate the Voortgang ( "elapsed time" ) as such:

    Actionscript Code:
    var Voortgang:Number = Nu.getTime() - StartDatum.getTime();
    var Remaining:Number = TotaleTijd - Voortgang.

    if 'Remaining' is smaller than 0, this means that the amount of time that has passed, is beyond the endpoint which was set at the start of this function, when this moment is reached you stop the timer.

    Het helpt dat ik Nederlands kan lezen

  8. #8
    Junior Member
    Join Date
    Feb 2010
    Posts
    27
    Ja dat is inderdaad wel fijn

    But I still cant get it to work... This project is to difficult for me... My ActionScript is not good enough for this...

    This is my code now:

    PHP Code:
    var StartDatum:Date = new Date(201101171434300);
    var 
    EindDatum:Date = new Date(20110117143600);
    var 
    TotaleTijd EindDatum.getTime() - StartDatum.getTime();

     

    var 
    MijnTimer:Timer = new Timer(1000);


    MijnTimer.addEventListener(TimerEvent.TIMERDetijd);
    MijnTimer.start();

     

    function 
    Detijd(e:TimerEvent=null):void 

         var 
    Nu:Date = new Date();    
         var 
    TijdOver:Number Nu.getTime() - StartDatum.getTime();
         var 
    Voortgang:Number TijdOver TotaleTijd;
         var 
    Remaining:Number TotaleTijd Voortgang;
         var 
    startPoint:int 200;
         var 
    endPoint:int stage.stageWidth 200;
         var 
    totalDistance:int endPoint startPoint;
         var 
    ratio:Number totalDistance TotaleTijd;
         
    bus.totalDistance Voortgang;
         
    lijn.scaleX Voortgang;
         
    }
    Detijd(); 
    I think it is better for me to stop because I'm putting to much time in it for nothing or a little progress...

    Tnx for your help

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