Works a treat!

Thank you plenty

Richard Poole


----- Original Message -----
From: "Tab Julius" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, November 28, 2001 10:32 AM
Subject: Re: <lingo-l> no percentage value


>
>
> That's because by the time you do the float, it's too late.
>
> Things evaluate from the inside of the parentheses out.  So first, it does
> current / videoDuration.  You say they both have values but don't say what
> they are, but I'll guess they're integers.
>
> Assuming current is less than duration, the result would probably be some
> value less than 1, like 0.xxxx.  But since both are integers, that'll just
> convert the answer to 0 when doing integer math.
>
> Then you have 0, and THEN you convert it to a float, making it 0.0, and
> then you multiply it by mysize, but you'll just end up with 0.0.
>
> INSTEAD, if you make one of the values a float BEFORE you divide it, the
> division will be treated as floating point division, and you'll actually
> get a number out of the process.  What you really want is something like:
>
> myvalue = (float(current) / videoDuration) * mySize
>
> The difference is subtle, but important.  Current is now converted to a
> float BEFORE the division.  Alternately you could float(videoDuration).
It
> doesn't really matter which is floated as long as at least one of the
> operands is a float, which will force it to use floating point math and
not
> integer division.  You were dividing and then floating the result AFTER
the
> divide, which is too late and gives you zero.
>
> - Tab
>
>
> At 10:01 AM 11/28/01 +0000, Richard Poole wrote:
> >Hi
> >
> >I am currently trying to create a progress bar for a movieclip in
director.
> >I have managed to create the same progress bar before, but for some
reason
> >now it just wont work.  I have managed to find the area which is going
> >wrong.
> >
> >myvalue = float(current / videoDuration) * mysize
> >
> >'current', 'videoDuration' and 'mysize', all have values, however when I
try
> >read 'myvalue' no value is displayed.
> >???????????
> >
> >Where am I going wrong?
> >_______________________________________________________
> >
> >global myvalue
> >global mysize
> >global videoDuration
> >global videoSprite
> >
> >property progressbar
> >property videoSprite
> >property videoDuration
> >property mysize
> >
> >on beginSprite me
> >   initialize me
> >end beginSprite
> >
> >on prepareframe me
> >   myupdate me
> >end prepareframe
> >
> >on initialize me
> >   videoDuration = sprite(videoSprite).duration
> >   mysize = sprite(progressbar).width
> >end initialize
> >
> >on myupdate me
> >   current = sprite(videoSprite).movieTime
> >   myvalue = float(current / videoDuration) * mysize        <<<<< The
problem
> >area
> >   sprite(progressbar).width = myvalue
> >   member("check").text = string(myvalue)                    <<<<using
this
> >to debug
> >end myupdate
> >
> >on getPropertyDescriptionList me
> >   description = [:]
> >   addprop description, #videoSprite, [#comment:"Video Sprite",
> >#format:#sprite, #default:0]
> >   addprop description, #progressbar, [#comment:"Progress Sprite",
> >#format:#sprite, #default:0]
> >   return description
> >end getPropertyDescriptionList
> >__________________________________________________________________
> >
> >Many thanks in advance
> >
> >Richard Poole
> >
> >
> >[To remove yourself from this list, or to change to digest mode, go to
> >http://www.penworks.com/lingo-l.cgi  To post messages to the list,
> >email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> >Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>
>
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to