macromedia DIRECTOR MX 1002004 training from the source [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

macromedia DIRECTOR MX 1002004 training from the source [Electronic resources] - نسخه متنی

Dave Mennenoh

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید











Math and Numbers


A couple of tips on dealing with math in Director.

JavaScript Math


If Lingo doesn't have a particular math function you needarcSin, for instanceyou can use JavaScript's math library. Simply create a new movie script and set its type to JavaScript, instead of Lingo. You can then create your own math function in JS like so:


function arcSin (num) {
return Math.asin(num);
}
function arcCos (num) {
return Math.acos(num);
}

Once created, the functions can be called like any method, even from within Lingo:


on test num
as = arcSin(num)
trace(as)
end

Integer Numbers


Here is a question that repeatedly appears in the newsgroups: Why do certain calculations produce incorrect results? The answer is always the same: you're doing integer math, and Director rounds integers. Use floats instead.

Look at this example from the Message window:


trace(21 / 5)
-- 4

To get the correct result turn one of the numbers into a floating-point, or real, number:


trace(21 / 5.0)
-- 4.2000

Or use the float method:


trace(21 / float(5))
-- 4.2000


/ 165