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




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 MenuStage.showMenu = false; //Set StageStage.scaleMode = "noScale";Stage.align = "TL";//Import pathvar 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 samplevar 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?



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 02-05-2007, 05:19 PM


View Complete Forum Thread with Replies

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

:: If Statment Evaluation Help ::
If (this is the second time youve play this in a row)
gotoAndplay (frame 7);
else( go to play frame 1)
}

Basically I want to have a script that if you click a button then click it again it will take you somewhere else. BUT if you click it once, then click something else, then click the first button again it will take you to the original spot.

thanks
n

sorry if that didnt make any sense

Array Evaluation
i have an array that is populated with times...and i was wondering if there was a function to return the lowest value in the entire array? or if there is a loop i would go through to establish what the lowest value is? any help is appreciated, thank you

Array Evaluation
Hey!!!

I'm working on a playlist that makes tracks clickable/'listenable' when
the tracknumber appears in a textfile that gets loaded in. The file
looks likes this:
audioText=1,4,2,8,

I'm trying to loop through a array that looks which looks like this:
for(var i=0; i<audioArray.length; i++)

the array is build by the following script which works just fine:
audioArray = this.audioText.split(",");

To the point now - It doesn't work at all!!! The number of ellements
in my array is correvt, but the wrong tracks are enabled....

Here's my script:

ActionScript Code:
for(var i=0; i<audioArray.length; i++)
    {
        if(audioArray[i] != "")
        {
            // trackID
            var trackID = int(audioArray[i] + 1);
           
            // show icon
            _root["icon"+trackID]._alpha = 100;
            // save id
            _root["track"+trackID].id = i + 1;
            // mouseover
            _root["track"+trackID].onRollOver = function()
            {
                // grow
                this._alpha = 12;
            }
            // mouseout
            _root["track"+trackID].onRollOut = function()
            {
                // shrink
                this._alpha = 0;
            }
            // release
            _root["track"+trackID].onRelease = function()
            {
                // handle markers
                playTrack(this.id); // starts at 0
                audioActive = 1;
            }
        }
    }

In-line Evaluation
Is there any function in flash that allows for 'in-line evaluation'?

For example, in php I can type

eval ( 'php statement here' );

and php will execute 'php statement here' as if I typed it as a command. I'm trying to execute dynamic code is the problem.

In-line Evaluation
Is there any function in flash that allows for 'in-line evaluation'?

For example, in php I can type

eval ( 'php statement here' );

and php will execute 'php statement here' as if I typed it as a command. I'm trying to execute dynamic code is the problem.

Dynamic Evaluation
Hello all,

Working on a project here where I need to dynamically attach movie clips to some predefined movieclips on the stage. I have a resultset that is returned from CF that contains the base movieclip info which needs to be dynamically evaluated then used in the attachMovie() method.

Here is my code for reference:



Code:
getPositions();

function getPositions ()
{
manager.getSlipPos();
}

function getSlipPos_Result(result)
{
for (i = 0; i < result.length; i++) {
id = result.getItemAt(i).ID;
slip = result.getItemAt(i).slip;
pos = result.getItemAt(i).pos;
spaces = result.getItemAt(i).spaces;
type = result.getItemAt(i).typeAbbr;

place(id, slip, pos, spaces, type);
}
}

function place(id, slip, pos, spaces, type)
{

thisMC = "CP1_" + slip + pos + "MC";


CP1MC.thisMC.attachMovie(type, type + "_" + id, CP1MC.thisMC.getNextHighestDepth());
}
The base movie clips used for attachment are names as follows:

CP1_Slip1aMC
CP1_Slip1bMC
CP1_Slip2aMC
CP1_Slip2bMC

. . . etc.

Where "Slip1" variable
And "a" or "b" is variable.

Does this all make sense?

In summary im needing to loop the recordset which is working fine then place a movie clip dynamically with a dynamically SPECIFIED movieclip based on the current looping record.

Please let me know if you have any questions. . .

Multiple Variable Evaluation
Hi

I have a number of clips (drawers (named d1, d2 etc...)) each of these can have their variable (state) set to open or closed.

I need to be able to make a button that when clicked performs one action on the clips that are set to "open" and another action on the clips that are set to "closed"

I thought this would be simple, maybe i am jus havin a memory block :S anyway can anyone help me out with the script i need to put on the button.

cheers

3quid

Establishing Variables For Evaluation...
I'm having a little situation...

I'm scripting a menu which consists of 5 items. I am attempting to script each menu items button so if the user were to select the same item button twice successively, the actions tied to that button will only execute on the first time selected.

The process I've used in the past has been to establish variables for each menu item and test for those variables on(release); i.e.

Code:
//script for menu item 1 (button 1)//
on (release) {
if (button1!=1) {
//execute action//
_root.BG2.gotoAndPlay(1);
}
button1=1;
button2=0;
button3=0;
button4=0;
button5=0;
}
//script for menu item 2 (button 2)//
on (release) {
if (button2!=1) {
_root.BG2.gotoAndPlay(1);
}
button1=0;
button2=1;
button3=0;
button4=0;
button5=0;
}
I have used the above process a number of times without flaw with V5.

Now, for some reason this is not working. I can only seem to get one button to execute its action. After doing so, none of the other buttons function.

I'm a bit lost...any thoughts...

Thanks

Chessgenie In Flash MX For Evaluation
Do you play Chess? I've just created a Chess diagram generator and Chess game Viewer (Chessgenie) written in Actionscript. This is data driven and interactive and currently is used as front-end program to view chess games. Can anyone evaluate my Chessgenie and tell me which area it can be improved. Any suggestions and comments are highly appreciated. You'll find Chessgenie at www.rootyhillchess.org

Nested Evaluation Functions
The problem I am stuck on is that I have a function evaluating if the date has passed. Then within that function I am wanting it to make the first unpassed date red and all the subsequent unpassed dates black. I've tried everything I can think of but I can't get it to work. I tried the statements if, for, while, do while, else if. None of them worked right. Here is the code

Code:
now = new Date();
month = now.getMonth()+1;
day = now.getDate();
year = now.getFullYear();
var event = new LoadVars();
event.load("text/calruns.txt");
event.onLoad = function(success){
if(success){
compare();
for (i=0; i<c; i++){
runslist.htmlText += this["month"+i]+"/"+this["day"+i]+"/"+this["year"+i]+newline+this["notes"+i]+newline+this["loc"+i]+newline+this["url"+i]+newline+"----------";
printMC.pmain.htmlText += this["month"+i]+"/"+this["day"+i]+"/"+this["year"+i]+newline+this["notes"+i]+newline+this["loc"+i]+newline+this["url"+i]+newline+"----------";
}
}else{
//the vars couldn't be loaded.
}
};;
function compare(){
c = (this.event["counter"]);
for(i=0; i<c; i++){
emonth = this["mexpired"+i] = false;
eday = this["dexpired"+i] = false;
if(this.event["month"+i]<month){
emonth = true;}
if(this.event["day"+i]<day){
eday = true;}
if(emonth == true && eday == true || this.event["month"+i] == month && eday ==true || emonth == true){
fcolor = 1;
}else{
/**something needed here to make it change the first one
to red then the rest to black**/
}
switch(fcolor){
case 1:
this.event["month"+i] = "<FONT COLOR="#999999">"+this.event["month"+i];
this.event["day"+i] = "<FONT COLOR="#999999">"+this.event["day"+i];
this.event["year"+i] = "<FONT COLOR="#999999">"+this.event["year"+i];
this.event["loc"+i] = "<FONT COLOR="#999999">"+this.event["loc"+i];
this.event["notes"+i] = "<FONT COLOR="#999999">"+this.event["notes"+i];
this.event["url"+i] = "<FONT COLOR="#999999">"+this.event["url"+i];
break;

case 2:
this.event["month"+i] = "<FONT COLOR="#FF0000">"+this.event["month"+i];
this.event["day"+i] = "<FONT COLOR="#FF0000">"+this.event["day"+i];
this.event["year"+i] = "<FONT COLOR="#FF0000">"+this.event["year"+i];
this.event["loc"+i] = "<FONT COLOR="#FF0000">"+this.event["loc"+i];
this.event["notes"+i] = "<FONT COLOR="#FF0000">"+this.event["notes"+i];
this.event["url"+i] = "<FONT COLOR="#0066CC">"+this.event["url"+i];
break;

case 3:
this.event["month"+i] = "<FONT COLOR="#000000">"+this.event["month"+i];
this.event["day"+i] = "<FONT COLOR="#000000">"+this.event["day"+i];
this.event["year"+i] = "<FONT COLOR="#000000">"+this.event["year"+i];
this.event["loc"+i] = "<FONT COLOR="#000000">"+this.event["loc"+i];
this.event["notes"+i] = "<FONT COLOR="#000000">"+this.event["notes"+i];
this.event["url"+i] = "<FONT COLOR="#0066CC">"+this.event["url"+i];
this.event = "<FONT COLOR="#000000">";
break;
}
}
}
I've also attached the fla, it was made in MX2002.

Text Field Evaluation
Could anyone tell me how to evaluate content of a text field? Such as looking for certain words in an open response, and if they're there, then, score adds, if not score subtracts. Thanks.

MovieClip Path Evaluation
Hi everybody,

please don't you know, how to evaluate string MovieClip path that contains nested MovieClips?

e.g. this won't work:
var path : String = 'window_mc.button_mc';
var clip : MovieClip = _root[path];

is there a simple way (like deprecated eval) or should I have a loop and evaluate each dot-separated tail of the string?

Thanks

Poker Hand Evaluation
I'm creating a Texas Hold'em poker game and I was wondering if there was any poker hand evaluation code around that I could use or learn from. So far I have everything worked out, dealing the cards, etc. I only need to work out this code. Figured I can do it long hand no problem, but it might take me a good 8 hours worth of coding. Hopefully this 2 minutes of thread typing will alleviate that

Thanks
webG

String Evaluation [returns]
Hi,

I was wondering if it's possible to evaluate a string of text to see how many [returns] (lines) it contains. i.e. I have a paragraph in a dynamic textfield and I'd count the # of chr(13) instances in there.

thanks!

Runtime Code Evaluation
Hello everyone,

i'm pretty new to actionscript and maybe this is a totaly rookie question but:

Is it possible to instanciate a class via a string containing the class name.

ex:

var className:String = "StarSprite";
s:StarSprite = new className; // Cannot compile !

I tried to play around with eval

var className:String = "StarSprite";
s = eval("new"+className);
etc...

But i could'nt manage to get it right. In a more general way, is it possible to generate code, evaluated at runtime ?

thanks for any help

emmanuel:

*********** JTools 1.2 Evaluation (Trial Version)
Does anyone have the JTools 1.2 Evaluation (Trial)?

Please send to mikalux@gmx.de if anyone have it.

Thank you!

Mikalux

How Can I Do A Limit Day Evaluation Period In A Flash Exe
Hello, I´m new in flash and i need please!!! all infomation about how can i do to set a day evaluation period in a demo of flash aplication
I apreciate all your help
thanks a lot

Logical Evaluation With Dynamic Operator
Hi, all.

I have a function that evaluate numeric values based on a dynamic operator.

Something like:


Code:
function ev(value1:uint, value2:uint, operator:String = ">")
{
return operator == ">" ? value1 > 2 : value1 < value2;
}

For performance improvement issues, I want to remove the first condition (operator == ">"). Is there a way? In AS2 I could use the eval, for example.


Thank you,
CaioToOn!

Runtime Expression Evaluation AS3 To AS2 Conversion
Hey guys,

Unfortunately the company I work for uses a AS2 engine which I build components for. I'm trying to build a expression evaluation function for one the the components. Found a great library at sephiroth.it

http://bit.ly/3HPLh9

Unfortunately for me, it's in AS3. I'm going to try and convert it, if anyone would like to help it would be greatly appreciated. The link to the source code is broken but I found another one here

http://bit.ly/1I6dMc

Also, if anyone knows of any already made runtime expression evaluations for AS2, please let me know.

Thanks. I'll post anything I get working.

How Can I Do A Limit Day Evaluation Period In A Flash Exe
Hello, I´m new in flash and i need please!!! all infomation about how can i do to set a day evaluation period in a demo of flash aplication
I apreciate all your help
thanks a lot

AS3 - Runtime Expression Evaluation AS3 To AS2 Conversion
Hey guys,

Unfortunately the company I work for uses a AS2 engine which I build components for. I'm trying to build a expression evaluation function for one the the components. Found a great library at sephiroth.it

http://bit.ly/3HPLh9

Unfortunately for me, it's in AS3. I'm going to try and convert it, if anyone would like to help it would be greatly appreciated. The link to the source code is broken but I found another one here

http://bit.ly/1I6dMc

Also, if anyone knows of any already made runtime expression evaluations for AS2, please let me know.

Thanks. I'll post anything I get working.

AS3 - Logical Evaluation With Dynamic Operator
Hi, all.

I have a function that evaluate numeric values based on a dynamic operator.

Something like:


Code:
function evaluate( value1:uint, value2:uint, operator:String = ">" )
{
return operator == ">" ? value1 > 2 : value1 < value2;
}

For performance improvement issues, I want to remove the first condition (operator == ">"). Is there a way? In AS2 I could use the eval, for example.


Thank you,
CaioToOn!

How To Make Trail Version/Evaluation
Anyone know how to make a Flash (exe) become a Trail Version, so that people can only access/use it for 30 days. Even if they change their system clock back to the previous date also doesn't affect it.
Or can make something like the shockwave.com games trail funtion?

Multiple MC Controld And _current Frame Evaluation
I have 13 movie clips in my root. I want to to activate and deactivate each with on(press). I'm having trouble writing an If And or Else statement that accurately processes where each moving clip current frame is, and to make it deactivate if any or all movie clips are on a certain frame. ie frame 15.

Easy solutions?

Thanks in advance...

Adding String Data To An Expression For Evaluation
Hi, I have the following function:


Code:
getInfo = function (input, arrayData, desiredResult)
{
for (i = 0; i < arrayData.length; i++)
{
if (arrayData[i].button == input)
{
return arrayData[i].desiredResult;
}
}
};
arrayData is a multidimensional array containing objects.

What I need returned is arrayData[i].desiredResult, where desiredResult is a string passed to the function. For example:

test("dogs", theArray, "color") needs to return the evaluated value of arrayData[i].color. How can I achieve this? Thanks!

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.

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?

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