Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Skew Function Not Accurate: Need Rounding... Where Are You Mathematicians? :)



Hello you Flashers and Mathematicians, i got a problem with a nice skew function From Ericlin of http://ericlin2.tripod.com/skew/skewt.html Here is the content of the original Actionscript Function:
PHP Code:


function skewObj (obj, mcW, mcH, pt0, ptH, ptW) {    function distance (pt1, pt2) {        var dy = pt2.y-pt1.y;        var dx = pt2.x-pt1.x;        var side = Math.sqrt(dy*dy+dx*dx);        return side;    }    obj._x = pt0.x;    obj._y = pt0.y;    obj._yscale = 100;    var angleP2 = Math.atan2(ptW.y-pt0.y, ptW.x-pt0.x);    var angleP1 = Math.atan2(ptH.y-pt0.y, ptH.x-pt0.x);    var dAngle = (angleP1-angleP2)/2;    var arm = Math.sqrt(2)/2/Math.cos(dAngle);    // original a 100x100 model , now use 1x1 model    obj._rotation = (180/Math.PI)*(angleP1-dAngle);    obj.mc._rotation = -45;    obj._yscale = 100*Math.tan(dAngle);    obj.mc._xscale = distance(ptW, pt0)*100/arm/mcW;    obj.mc._yscale = distance(ptH, pt0)*100/arm/mcH;} 



So far so good. This kind of "three-point-skew" function is really great and working (check out the URL). I use the function to transform a simple rect Movieclip that way it could be an isometric wall. this is not a very special transformation, so the point placement is pretty easy (look at the pt0, ptH and ptW variables):
PHP Code:


H = obj.mc._height;W = obj.mc._width;pt0 = {x:0, y:0};ptH = {x:0, y:H};ptW = {x:W, y:(H/2)};skewObj(obj, W, H, pt0, ptH, ptW); 



i have prepared a small and plain .fla for you so you can check it out right here, its also attached to the posting (Flash MX 2004 File but should be ok for earlier versions?): http://public.moonground.de/kirupa/skew-wall-test.fla Here is the swf:http://public.moonground.de/kirupa/skew-wall-test.swf Well now here is the Problem:while the borders of isometric walls are still exactly vertical (90 deg) the function is producing lines which are very slightly skew. might be something like 90.1 deg... but this inaccurancy produces ugly gaps between walls i put together later. This function is maybe not accurate enough, maybe to accurate, i am not sure. But i need probably some rounding in there but i dont know where, really (is that a wonder? look at the script! ;)) you can check out the swf, or the fla, see url or also attached: when you zoom in and look at the "orientation bar" (thick dark blue bar), you will notice that there is a very small gap on the top right corner but its bigger on the bottom right corner of the wall texture. Question:Can you fix the problem by changing the script?Please give it a try!



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 08-22-2004, 08:21 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Skew Function Not Accurate: Need Rounding... Where Are You Mathematicians? :)
Hello you Flashers and Mathematicians,

i got a problem with a nice skew function From Ericlin of http://ericlin2.tripod.com/skew/skewt.html

Here is the content of the original Actionscript Function:

PHP Code:



function skewObj (obj, mcW, mcH, pt0, ptH, ptW) {    function distance (pt1, pt2) {        var dy = pt2.y-pt1.y;        var dx = pt2.x-pt1.x;        var side = Math.sqrt(dy*dy+dx*dx);        return side;    }    obj._x = pt0.x;    obj._y = pt0.y;    obj._yscale = 100;    var angleP2 = Math.atan2(ptW.y-pt0.y, ptW.x-pt0.x);    var angleP1 = Math.atan2(ptH.y-pt0.y, ptH.x-pt0.x);    var dAngle = (angleP1-angleP2)/2;    var arm = Math.sqrt(2)/2/Math.cos(dAngle);    // original a 100x100 model , now use 1x1 model    obj._rotation = (180/Math.PI)*(angleP1-dAngle);    obj.mc._rotation = -45;    obj._yscale = 100*Math.tan(dAngle);    obj.mc._xscale = distance(ptW, pt0)*100/arm/mcW;    obj.mc._yscale = distance(ptH, pt0)*100/arm/mcH;} 




So far so good. This kind of "three-point-skew" function is really great and working (check out the URL).

I use the function to transform a simple rect Movieclip that way it could be an isometric wall. this is not a very special transformation, so the point placement is pretty easy (look at the pt0, ptH and ptW variables):


PHP Code:



H = obj.mc._height;W = obj.mc._width;pt0 = {x:0, y:0};ptH = {x:0, y:H};ptW = {x:W, y:(H/2)};skewObj(obj, W, H, pt0, ptH, ptW); 




i have prepared a small and plain .fla for you so you can check it out right here, its also attached to the posting (Flash MX 2004 File but should be ok for earlier versions?):

http://public.moonground.de/kirupa/skew-wall-test.fla

Here is the swf:
http://public.moonground.de/kirupa/skew-wall-test.swf

Well now here is the Problem:
while the borders of isometric walls are still exactly vertical (90 deg) the function is producing lines which are very slightly skew. might be something like 90.1 deg... but this inaccurancy produces ugly gaps between walls i put together later.

This function is maybe not accurate enough, maybe to accurate, i am not sure. But i need probably some rounding in there but i dont know where, really (is that a wonder? look at the script! ;))


you can check out the swf, or the fla, see url or also attached:

when you zoom in and look at the "orientation bar" (thick dark blue bar), you will notice that there is a very small gap on the top right corner but its bigger on the bottom right corner of the wall texture.

Question:
Can you fix the problem by changing the script?
Please give it a try!

Accurate Timing Function
I'm writing a function that basically imitates the Timer Class in AS3 but minimizing the discrepancy between intervals (see here). The problem is that the minimal discrepancies there are with this function have a cumulative effect and I need the timer to stay as close to on the beat as possible rather than getting slightly further away each time.
So i need a way to reset the timer to where it should be if there are any discrepancies. The basic code is:


Code:
function timer(i:Number, n:Number) {
var timeNow:Number;
var timeLast:Number = 0;
var c:Number = 0;

root.addEventListener(Event.ENTER_FRAME, gen);
function gen(e:Event):void {
timeNow = getTimer() - timeLast;
if (timeNow >= i) {
timeLast = getTimer();
c += 1;
trace(c+", timeNow: "+timeNow);

if (c == n) {
root.removeEventListener(Event.ENTER_FRAME, gen);
}
}
}
}
timer(1000, 0);
I've tried a couple of different ways of adjusting the next interval if the timer runs slow to set it back on track but i can't seem to get anything to work.

Any help much appreciated

Rounding Function - Help, ASAP Please
Hey there!
Well, I need to build a function that rounds to the nearest hundredth... 10.099999 = 10.10

Can someone please help me? I tried using something I would do in Java... but it brings up "undefined" when I apply the function to it... let me show you my code.


ActionScript Code:
function rD(n){
        if(n > 0){
            if(n.toFixed){
                return n.toFixed(2);
                return Math.round(n*100)/100;
            }
        } else {
            return 0;
        }
    }


Let me know if there is an easy way of trying to do this... does flash allow you to specify the decimal place, like excel?
Thanks

I Figured Out How To Skew In A Movie Clip, But I Can't Skew It The Way I Want To :(
I use this code to skew in a movie clip:

ActionScript Code:
//Rotate inner rectangle
    _root.monkey.t.s.si._rotation += .09;
         //Scale outer rectangle
    //_root.monkey.t.s._xscale += 5;
    //Rotate outer rectangle backword
    // _root.monkey.t.s._rotation += .3;
the problem is that i want it to skew it the way it would skew while holding alt, how would I do it that way?

Rounding To 2 Decimal Places With Math.round Function.
Hey Everyone

How do you round a number to 2 decimal places using the Math.round function? Thanks in advance.

-turner2000

YIKES Ok Guys - Here Is A Challenge For The Scripters And Mathematicians
... I 've been 'volunteered' for a task: I need to create something similar to the menu system at the lufthansa site at http://www.lhsysnet.com. Can anyone point me to an appropriate direction here? I found this movie in flashkit that comes close (http://www.flashkit.com/cgi-bin/movies/download.cgi?ID=2464) but I don't know how to alter the angles and nodes in it. PLEASE HELP!!!

SetInterval Accurate?
I'm having problems with setting the interval for a function........

Im using this to synchronize two soundobjects. The sound objects are exactly the same length in milliseconds.

First I get the duration of one of the loops. Then I set to interval for the function that starts the second loop exactly to the loop length.
But it doesnt seem to be stable........... sometimes it times it correctly sometimes it's a bit off.

Here's my code:

Code:
s1 = new Sound(this);
s1.attachSound("loop1");
s2 = new Sound(this);
s2.attachSound("loop2");
loopLength = s1.duration;
s1.start(0, 999);
// doSyncStart function
function doSyncStart() {
if (syncStart == true) {
s2.start(0, 999);
syncStart = false;
}
}
setInterval(doSyncStart, loopLength);
I use a button to set the variable "syncStart" to true.

If anyone can give me some insight as to why this is so inaccurate or maybe a way to optimize the code, it would be greatly appreciated

P.S. I've tried the highest movie fps rates but it didnt make much of a difference

SetInterval Accurate?
I'm having problems with setting the interval for a function........

Im using this to synchronize two soundobjects. The sound objects are exactly the same length in milliseconds.

First I get the duration of one of the loops. Then I set to interval for the function that starts the second loop exactly to the loop length.
But it doesnt seem to be stable........... sometimes it times it correctly sometimes it's a bit off.

Here's my code:

Code:
s1 = new Sound(this);
s1.attachSound("loop1");
s2 = new Sound(this);
s2.attachSound("loop2");
loopLength = s1.duration;
s1.start(0, 999);
// doSyncStart function
function doSyncStart() {
if (syncStart == true) {
s2.start(0, 999);
syncStart = false;
}
}
setInterval(doSyncStart, loopLength);

I use a button to set the variable "syncStart" to true.

If anyone can give me some insight as to why this is so inaccurate or maybe a way to optimize the code, it would be greatly appreciated

P.S. I've tried the highest movie fps rates but it didnt make much of a difference

SetInterval Not Accurate Enough
I am coding a metronome for drummers. I need to call a function accuractly within 100 ms or less. There is a slight stutter when producing a beat every time with a milliseconds this low. I'm not sure if the mp3 file is causing the stutter. Is there anyway I can eliminate this? When is trace simple output text, I can't tell if its accurate or not to see if the mp3 is the problem.

Any ideas?

Thanks for your time!

How Accurate Is GetTimer()?
I'm working on a tetris clone and I'm trying to decide on the top of scoring system to implement. I think I'm going to go with a score that depends on the time it takes for the tetris piece to reach the bottom of the screen.
Anyways, my question is how accurate is GetTimer()? A lot of stuff is happening indepedent of the timeline FPS, so if I assigned the value of GetTimer() to a variable once I drop a new tetris piece and then subtracted this from the value of the same tetris piece once it stops falling, am I going to get an accurate measure of the time it took for the tetris piece to fall?

[F8] Specifying More Accurate Cuepoints?
Hey all,
Im trying to call a function at certains beats in an mp3. To do this I want to use cue points and to type them manually for control. However, I cant get the timing more accurate than in seconds using actionscript, it doesnt seem to understand sat 2.5 as opposed to 2. Maybe the syntax is wrong? This is the code I am using to do it.


var aCuePoints:Array = [{cue:3, msg:"Cue point 1"},
{cue:5, msg:"Cue point 2"},
{cue:7, msg:"Cue point 3"},
{cue:9, msg:"Cue point 4"}
]

var sndMusic:Sound = new Sound();
sndMusic.loadSound("Neverending.mp3", true);

var nCuePointCheck:Number = setInterval(checkCue, 1000);

function checkCue():Void{
for(var i:Number=0; i<aCuePoints.length; i++){
if(aCuePoints[i].cue == Math.floor(sndMusic.position/1000)){
trace(aCuePoints[i].msg);
break;
}

}
}

As you can see the cue points are at 3, 5, 7 seconds etc but i need them inbetween.

Any help would be MUCH appreciated!
I dont know any XML either and embedding them into the movie makes them difficult to alter.

More Accurate Slider
Hi

I'm trying to make a slider that is very accurate. Currently, I have one that is 300 pixels wide, and I'm using the offset of the hand (._x) property to determine where the handle is. Clearly, the large the slider, the more accurate it gets.

But I need more accuracy with a slider the same size. I need more significant digits. As it stands, if I were to display the percentage of the slider position (offset / 300px), it gives me .33, .66, 1, 1.33, etc. I need more accuracy for what I am doing.

How would I go about doing this? Is there a way I can make is more accurate?

Thanks in advance,
Alexandre

Number Not Accurate
i=-5

while(i<=5) {
trace(i);
i+=0.1;
}

I'm using MX, but the result not increase 0.1. How to solve it?

Use Counts Accurate?
kornfused...

I am trying to get a big flash file organized, but when I choose the "Select Unused Items" in the library palette drop down menu, Flash identifies a lot of items which have use counts more than zero in the use count column.

I'm wondering which is correct and why this is happening?

Accurate Scoring
Id like to track a user score after they drag a series of objects to the correct location. Ive come up with the following way but this solution increases and decreases the score simply if the mouse is clicked on the object. Does anyone know of a way to prevent this?

Ive attached a sample to clarify what I mean.

Thanks

Accurate Hit Counter
Hi,

I'm in the process of creating a hit counter (number of visitors counter) using Flash. I already seen the PHP based counter here on kirupa.com but it is not accurate enough as it will increment upon each page refresh. I would like to get a more accurate statistic about the number of different visitors rather than the number of page loads.

What I was thinking about was getting and storing the IP addresses and only incrementing the counter if the IP address is not yet known. This will give a higher accuracy but is still not perfect. Does anyone have any better idea?

Many thanks in advance for your help!

Can't Get Accurate Mc Height
Hi

I am attempting to put a vertical menu bar, each made up of a text fields inside a mc. The mcs and text create fine, but I am having "FUN" trying to position them vertically.

In the snippet below you can see that I go round a loop and format the mcs etc - all works. However, when I use trace(linkBtn._height) I get the same value for every button and some are right, some are wrong.

Strangley If I pick one specific button out using the if(i==6) {... it tells me a different height (which happens to be correct)

What's going on? And more importantly, how do I get the correct heights.

Thanks in advance

Edward



Code:
for (var i:Number = 0; i < RootNode.childNodes.length; i++) {
//get the text for the designMenu links
linkText = RootNode.childNodes[i].firstChild.nodeValue;
if (i == 0) {
designMenu.text = linkText;
designMenu.setTextFormat(btnRollOff_fmt);
designMenu.antiAliasType = "advanced";
designMenu.embedFonts = true;
trace(i + "=" + designMenu._height);
} else {
//bring in a movie clip that will form the link
var linkBtn:MovieClip = attachMovie("link_mc", "linkBtn" + i, getNextHighestDepth()); linkBtn.createTextField("linkTxt", getNextHighestDepth(), 0, 0, 169, 0); linkBtn.linkTxt.setNewTextFormat(btnRollOff_fmt); linkBtn.linkTxt.autoSize = "left";
linkBtn.linkTxt.wordWrap = "true";
linkBtn.linkTxt.border = "true";
linkBtn.linkTxt.antiAliasType = "advanced";
linkBtn.linkTxt.embedFonts = true;
linkBtn.linkTxt.text = linkText;
trace(i + "=" + linkBtn._height);
if (i == 6) {
trace("number" + i + "=" + linkBtn._height);
}
}
}

[MX] Very Accurate HitTest
I require a accurate hitTest for my movie.

I have 2 odd shaped movie clips, a "ball" and a "square" (with a bit cut out).

I need to know if the two movies are over lapping. The problem is I can find this out using the following AS



ActionScript Code:
<font size="2">//on the ball movie cliponClipEvent(enterFrame){       if (this.hitTest(_root.square))    {        trace("hits the square");    }}</font>



When I do this it gives the trace when overlapping the Binding Box and I need it to be very exact over the actual shape and contours of the Movie Clip.

Your help would be very much appreciated.

Accurate Scoring
Id like to track a user score after they drag a series of objects to the correct location. Ive come up with the following way but this solution increases and decreases the score simply if the mouse is clicked on the object. Does anyone know of a way to prevent this?

Ive attached a sample to clarify what I mean.

Thanks

Accurate Buttons?
Basically I have a button that when you mouse over plays a movie clip. WHen you mouse out, the movie clip stops playing. However, no matter what combinations on rollover, dragover, dragout, I am finding that sometimes if you move fast enough over the button the on dragout, mouseout whatever combinations don't work and the movie clip still plays, even if you are no longer over the button.

I've seen in several sites features like this (its very commonly used), but how do they get theirs to work in all situations?

Any help would be appreciated!

SetInterval Accurate?
Last edited by DeeLight : 2002-12-06 at 17:48.
























I'm having problems with setting the interval for a function........

Im using this to synchronize two soundobjects. The sound objects are exactly the same length in milliseconds.

First I get the duration of one of the loops. Then I set to interval for the function that starts the second loop exactly to the loop length.
But it doesnt seem to be stable........... sometimes it times it correctly sometimes it's a bit off.

Here's my code:
-----------------------------------------------

s1 = new Sound(this);
s1.attachSound("loop1");
s2 = new Sound(this);
s2.attachSound("loop2");
loopLength = s1.duration;
s1.start(0, 999);
// doSyncStart function
function doSyncStart() {
if (syncStart == true) {
s2.start(0, 999);
syncStart = false;
}
}
setInterval(doSyncStart, loopLength);

-----------------------------------------------
I use a button to set the variable "syncStart" to true.

If anyone can give me some insight as to why this is so inaccurate or maybe a way to optimize the code, it would be greatly appreciated

P.S. I've tried the highest movie fps rates but it didnt make much of a difference

Accurate Representation
I have a flash file which has a canvas size of 1024x768. Some elements in the background are much larger than that. When playing this file via the published html file on 1024x768 screen resolution, some of it i cut off obviously due to the toolbars and such and when playing with higher screen resolutions, the aforementioned background isn't cut off at 1024x768. Is there a script or a different way of publishing which will provide an accurate representation of what the file will actually look like when played in full screen mode via the web?

HitTest Not Too Accurate
Okay, creating a game where one object hits another. When I simply say

object1.hitTest(object2)

hitTest registers true even in cases where the objects aren't touching. As long as they're near each other, a hit is registered. So I tried

object1.hitTest(object2._x,object2._y,true);

This reverses things. Now, the two objects don't register a hit in situatiions that they should. They need to hit each other really well. Any ideas how to make the collisions more accurate? Thanks in advance.

SKEW
There is a skew thing in FLASH
is there some function for skew in AS or i have to do it manually??

How To Skew Something
Hi Flash World!

I have to create a box that I can rotate a little. So I generate three squares one with no skew degrees and the other two with some skew degrees... I would like to move those skewed degrees from the actual position to no skewed position. I've tried to do it by the way to resize the object scale _x or _y and the skew degree is getting lower but also size.... I'd like to get less skew but not less size.... somebody could help me?

Thank very much in advance because of your time reading my question!

360 SKEW
Dear friends,
please take a look at this

http://itimagine.com/main11.htm

click the contact button, then in the contact page, click any of the 3 buttons above.

you will notice the logo rotating above the button you press.

Im trying to make it skew vertically 360 degree. it only goes 180 degree and back. how can i make it skew completely 360.

thank you

Skew?
In 2001 I created a porthole that opened using Flash 4, I was able to make it work because i could skew the the window like you'd skew in photoshop. I now am working with Flash MX. My question is am I right in thinking you can only skew side to side, and can not skew the the sides up and down?

Skew?
Whats the best way to skew an MC without using 3D classes like Papervision?

Also can tweener skew MCs?

Skew An MC?
How can I skew an MC and keep it as an MC (its a video) without using Papervision etc.

I also want it to tween to the skew..

Any ideas?

Skew
If somebody read the scriptable tutorial of eric, please... tell me if there is more tutorial about that subject, bicouse i dont find any.

How To Skew Like This In AS3
Gang,

How do I accomplish this same skewing effect, but in AS3 ? There must be something obvious and simple that I'm missing. A nudge should help just fine thanks! I want to do what is going on in the timeline, but do it through AS3.

SEE ATTACHED

Skew In AS?
anyone knows a way to acess the skewing of objects with as?

the best i found was manipulating xscale and yscale with rotation aplyed...
is is possible?

Skew A Mc
I can't figure this out! I want to skew a mc (animated content) like this:

http://www.abscess.se/skit/skew.gif

Help?

Is GetTimer Actaully Accurate
Im using GetTimer in my movie, but it seems to fluctuate.

Should it be completely accurate, or can it vary like the framerate does?

Anyone else notice this, or is it something Ive done wrong?

How Can I Provide ACCURATE HitTesting?
i hav my "level" mc and my "character" mc. each frame the variable "fall", with equals 10, is added to "character"'s _y. but if the character is like 4 pixels above the level, the character lands 6 pixels in the ground. does anybody kno how 2 prevent this? im using this code on the level:
onClipEvent (enterFrame) {
with (character) {
if (level.hitTest(_x, getBounds(_root).yMax, true)) {
_y -= fall;
}
}
}

Bandwidth Profiler, Is It Accurate?
Is the bandwidth profiler accurate, in terms of its 56k setting? It seems a fair bit slow. If not what is a good average bytes per second on a 56k connection.

Also, if anybody knows the average bytes per second for a DSL and Cable connection. On average

Thanks

To Pull Only The Accurate Amount.
I am with a small problem, is the following one, I have my main file that this calling 10 swfs external, example in frame 1 calls one swf, in frame 150 calls another one, in frame 230 calls another one and thus it goes until completing the 10 swfs, I am using something thus for each swf "tran1_mc.loadMovie(_root.i11)", in the HTML if I to place 10 swfs it pulls normal, all certainty so far, but if in my HTML to say only it to pull 3 swfs, it pulls these 3 swfs and the remaining portion is blank, what necessary to make it is when to finish to show to this 3º swf it comes back to the first one, somebody has an idea of as I can make this?

Xmouse And Ymouse Not Accurate
I have a problem... I have a game that's getting rather complex, and I'm switching the controls over from a keyboard method, to a mouse method. The idea is to have the character's rotation automatically adjusted so he's always facing the mouse. (Which I've got working fine)

The problem is, the mousex and mousey are not updating properly. How I'm pulling the information is like this:
code:
onClipEvent(load) {
_root.cursor = new Object;
_root.cursor.interval = function() {
_root.cursor.x = _root._xmouse;
_root.cursor.y = _root._ymouse;
updateAfterEvent();
}
setInterval(_root.cursor, "interval", 1);
}


Now, when I put this movieclip & script in to a new fla that doesn't have the processing overhead that my game does, the cursor.x and cursor.y stay updated just fine (because it's updating them every 1 miliseconds, instead of at the normal frame rate). However, when it's in my game, If I move the mouse quickly, I can "leave flash behind", meaning that my cursor is across the screen, yet flash still thinks that the mouse is still sitting idle where I just left it.

This isn't just a matter of flash "catching up" because of processor load, because I can sit there forever and the variables will not update. I have to move my mouse around for it to return the correct data.

What I am assuming is happening, is that the _xmouse and _ymouse variables only update themselves when flash notices the mouse has moved, and if the processor is busy with other things, the _xmouse and _ymouse might not update. Am I correct in this? And if so, is there a way to force flash to update it's _xmouse and _ymouse variables, regardless of whether flash thinks the mouse has moved or not?

Has anyone else had a problem like this?

Thanks,
Chris

Frames Not Accurate When I Play The .fmw
Hi, I have a problem when I export my movie. First, I will explain what the fmw contains.

Two chapters (chapter one works fine)
In the second chapter I have:
background sound (me speaking)
background video
Images and video clips up in the corner.

This might sound like alot, especially since I have a big video, but listen to the problem first. What I want to do is that the pictures and images in the corner should appear at the exact moment when I say certain stuff. So I moved them in the layers and previewed the chapter each time to get it exactly right. Later, when I previewed the entire .fmw including the first chapter everything was totally out of sync by many seconds. I did a bit of checking, and as it turned out, the images doesnt appear at the correct place when I only preview the second chapter. So I tried to put the second chapter in a seperate file and export it standalone, but even then it doesnt appear correctly. The images only appear on the exact frame when I export it together with the first chapter, which makes it impossible to keep working on it since I dont want to watch through the first chapter for every time I test it.

Oh, another thing I noticed is that the problem lies in that the images appear too late. Which means, if I want to switch images after 120 frames (10 seconds), it might actually switch after 148 frames (12 seconds) when I play the preview of chapter 2.

Limits Of Accurate Timing?
Hi, I'm trying to create a drum machine.

To do this I need to be able to accurately trigger drum sounds every sixteenth note, or around once every 125ms, even more often at higher tempos.

I've created a timer at this interval to play the sound, but even with some error correction I read about (checking against getTimer and compensating) it's pretty inaccurate.

Is there any way to reliably play sounds at this small interval?

Thanks for any help!
Brian

ps. I'm new to making internet apps. If this is beyond what Flash is designed to do, are there other products/languages that could handle this?

100% Accurate Countdown Timer?
Hi,

BACKGROUND
I need to make a countdown timer in Flash that will countdown in seconds to the next whole hour and then will reset and countdown to the following next hour
The timer needs to be 100% accurate.

QUESTION
Is it possible to create a countdown timer in actionscript which will be perfectly accurate - ie. will always be identical when compared with actual rea-life time, irrespective of the hardware, processing of applications done on a client machine?

If this is not possible, is it possible to include in the code a detection of when the timer becomes inaccurate and then further code to get it back on track to correct the inaccuracy?

Any code examples/links to tutorials regarding above issues would be greatly appreciated.

Thanks

Accurate Preloader For FLV Streaming
Hi Everyone,

I'm working on accurate preloader for FLV video... The problem is that since it's streamed video it starts to play once it buffers enough of it (usualy around 8% to 15%)... So this 8% to 15% is the 100% of the loader bar but since it's changes from video to video I'm trying to find out how I can get this percentage before hand to estimate total size of preloading segment... Is there any way to do it in AS 2.0 (or AS 3.0)? How much of the FLV does Flash needs to preload to start playing video?

I'm using Flash CS and AS 2.0 for this project...

Any hints, thoughts, links and resources will be greatly appreciated...

Thanks for your time,
Peter

BitmapData.hitTest() How Accurate?
I am using BitmapData.hitTest() and want to know why it is not accurate.
and the next question will be, how to make it accurate.


Code:
public static function pixelHitTest(mc1:MovieClip,mc2:MovieClip):Boolean {
var mc1bd:BitmapData = new BitmapData(mc1.width, mc1.height, true, 0);
mc1bd.draw(mc1);
var mc2bd:BitmapData = new BitmapData(mc2.width, mc2.height, true, 0);
mc2bd.draw(mc2);
if (mc1bd.hitTest(new Point(mc1.x, mc1.y), 0xFF, mc2bd, new Point(mc2.x, mc2.y))) {
return true;
} else {
return false;
}
}


here is the link to show that it is not accurate.
http://www.geocities.com/arian_m3/bitmaphittest.swf

thank you in advance

Accurate Collision Detection (AS3)
i draw some random shaped on a movie clip using MovieClip.graphics tools. now i want to detect collision of that shape with another movie clip.

hittestobject() on movieclip only does the bounding box detection. can anyone help me to do more precise detection as bounding box detection is useless in my case.

Strange: If Evaluation Not Accurate...?
I'm observing a strange occurrence. When I evaluate for the following:
Code:
//Create Logo Holder & Position
if(Stage.width > 210 && Stage.height > 210){
_level0.attachMovie("Logo", "LogoClip1", 1, {_x: 0, _y: 0});
_level0.LogoClip1._alpha = 50;
}
else{
_level0.attachMovie("LogoTile", "LogoClip2", 1, {_x: -15, _y: 5});
_level0.LogoClip2._alpha = 50;
}
I would assume that if my movies dimensions we set to 209 x 209, my second case would execute. However, after some testing I've determined the result is that case 1 will not execute until my movie dimensions are set to 311 x 311. This is weird.

Below is my entire move script:
Code:
//Disable Context Menu
Stage.showMenu = false;

//Set Stage
Stage.scaleMode = "noScale";
Stage.align = "TL";

//Import path
var vidPath = path;

//Create Logo Holder & Position
if(Stage.width > 210 && Stage.height > 210){
_level0.attachMovie("Logo", "LogoClip1", 1, {_x: 0, _y: 0});
_level0.LogoClip1._alpha = 50;
}
else{
_level0.attachMovie("LogoTile", "LogoClip2", 1, {_x: -15, _y: 5});
_level0.LogoClip2._alpha = 50;
}



function positionLogo1(clip) {
clip._x = Math.round((Stage.width/2)-(215/2));
clip._y = Math.round((Stage.height/2)-(60/2));
}

//Create HolderMC & Load sample
var j:MovieClip = this.createEmptyMovieClip("Holder_mc",0);
var mcl:MovieClipLoader = new MovieClipLoader();
var mcl_listener:Object = {};

mcl_listener.onLoadInit = function(target_mc:MovieClip) {
target_mc._visible = true;
positionLogo(_level0.Logo);
}

mcl_listener.onLoadProgress = function(target_mc:MovieClip,bl:Number,bt:Number) {
trace(target_mc + " has loaded: " + bl + " of total: " + bt);
}

mcl.addListener(mcl_listener);
mcl.loadClip(vidPath,j);

positionLogo1(_level0.LogoClip1);

stop();
But I don't see what could be causing that kind of oddity.

Any clues?

100% Accurate Countdown Timer?
Hi,

BACKGROUND
I need to make a countdown timer in Flash that will countdown in seconds to the next whole hour and then will reset and countdown to the following next hour.
The timer needs to be 100% accurate.

QUESTION
Is it possible to create a countdown timer in actionscript which will be perfectly accurate - ie. will always be identical when compared with actual rea-life time, irrespective of the hardware, processing of applications done on a client machine?

If this is not possible, is it possible to include in the code a detection of when the timer becomes inaccurate and then further code to get it back on track to correct the inaccuracy?

Any code examples/links to tutorials regarding above issues would be greatly appreciated.

Thanks

Flv Seek Control Not Accurate
i am trying to write a function that will play a segment of an flv.

I am using a blank movie clip called "timer" to keep track of things and pause the video at the appropriate time


ActionScript Code:
var my_nc = new NetConnection();
my_nc.connect(null);
var ns = new NetStream(my_nc);
vid_holder.attachVideo(ns);
function loadvideo(what, startTime) {
    vid_holder.attachVideo(ns);
    ns.play(what+".flv");
    ns.onStatus = function() {
        ns.seek(startTime);
        ns.onStatus = null
    };
}

function playToFrom(file, startTime, endTime) {
    loadvideo(file, startTime);
    timer.onEnterFrame = function() {
        currentTime = ns.time;
        if (currentTime>=endTime) {
            ns.seek(endTime);
            ns.pause();
            this.onEnterFrame = null;
        }
    };
}

it seems when i call

ActionScript Code:
playToFrom("game1", 10, 15);
it seeks to 10.99 (almost a second late)

does anyone have any information or a link that might be helpfull.

thanks.

++ Most Highly Accurate Preloader ++
Anyone know any links/.flas/examples of preloaders that you think are very accurate???

To Pull Only The Accurate Amount.
I am with a small problem, is the following one, I have my main file that this calling 10 swfs external, example in frame 1 calls one swf, in frame 150 calls another one, in frame 230 calls another one and thus it goes until completing the 10 swfs, I am using something thus for each swf "tran1_mc.loadMovie(_root.i11)", in the HTML if I to place 10 swfs it pulls normal, all certainty so far, but if in my HTML to say only it to pull 3 swfs, it pulls these 3 swfs and the remaining portion is blank, what necessary to make it is when to finish to show to this 3º swf it comes back to the first one, somebody has an idea of as I can make this?

Copyright © 2005-08 www.BigResource.com, All rights reserved