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




Time-out Function



Could someone tell me how I should make this:

After 30 sec. of mouse inactivitie the movie should jump to a certainframe, but when you move your mouse within those 30 seconds the counter should reset.



ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 01-26-2005, 12:45 AM


View Complete Forum Thread with Replies

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

:: HELP ::: About Call Function First Time, Y Dont Work ? Next Time Work
http://202.57.150.77:8083/index.html

c at product click particle mdf or hdf then c animation wasnt play at first time y not ?


Code:
_root.readDB();
_root.onData = function() {
_root.selectLang();
PlayAnimate();
};




Code:
function PlayAnimate() {
for (i=1; i<=6; i++) {
if (this["obj" + i].mystate==_root.lastKeyAccess) {
deepMc = deepMc + 1;
duplicateMovieClip("theAnimate", deepMc, deepMc + 100);
this[deepmc]._x = this["obj" + i].mcx;
this[deepmc]._y = this["obj" + i].mcy;
this[deepmc]._visible = true;
this[deepmc].gotoAndPlay(1);
this[deepmc].PName = _root.lastKeyAccess;
}
}
}

Time Out Function?
Is there anyway to have a movie where if the user has no mouse activity for a designated period of time then it would go to a certain scene/frame?

A Time Function
hi,

i'm trying to develop a little movie that records reaction time. the time it takes you to click a button after the light turns green.

can anyone point me in the right direction?

thanks for your help.

Time Out Function
I am creating a menu system that works like a roll-over drop-down menu. I have set it up so that when a user moves their mouse off the particular menu section it collapses. However l have noticed that if you move it off the menu onto the html page quickly the menu stays open.
So l was wondering if there was some actionscript l could use to set a time out so that the menu collapses on it's own?

Any suggestions anyone?

P.S. I use Flash MX (Have both 2003 and 2004)

I Need A Little Help With XML Time Function. . .
I am trying to make a function for looping according to my endtime. The jpeg loads up and once it hits the endtime it needs to jump to the next jpeg. I have my jpeg fading in and out with a regular setInterval function, but I need a time function according to the xml file endtime.

Here's a sample of xml file:
<count id="1">
<mediatype>1</mediatype>
<information>Introduction</information>
<endtime>12</endtime>
</count>
<count id="2">
<mediatype>2</mediatype>
<information>Clip 2</information>
<endtime>50</endtime>
</count>
<count id="3">
<mediatype>3</mediatype>
<information>Clip 3</information>
<endtime>150</endtime>
</count>

This is a sample of my actionscript:

Code:
myInterval = setInterval(beginFadeOut, time());

function beginFadeOut() {
clearInterval(myInterval);
mc.fadeIn(100, 7);
}
function time() {
sec = ((10/5)*1000);
trace("seconds called");
return sec;
}
I need this time function to be replaced with a function that holds the value of endtime, then loops to get the other value once endtime has been met.

Could someone help me on this topic or point me in the right direction?
You help would be greatly appreciated!

Thanks in advance,
cbs

Use One Function From Two MCs At Same Time
Hi

I have two buttons from what I want to call two functions, one on onRollOver, and one on onRollOut. It works fine, as long as I dont call the function when the other button calls it... heres my code:


k1.onRollOver = k2.onRollOver=NaviRollOver;
function NaviRollOver() {
c = new Color(this);
t = c.getTransform();
onEnterFrame = function () {
if (t.rb<255) {
t.rb += 10;
t.gb += 10;
t.bb += 10;
c.setTransform(t);
} else {
delete this.onEnterFrame;
}
};
}
k1.onRollOut = k2.onRollOut=NaviRollOut;
function NaviRollOut() {
c = new Color(this);
t = c.getTransform();
onEnterFrame = function () {
if (t.rb>0) {
t.rb -= 10;
t.gb -= 10;
t.bb -= 10;
c.setTransform(t);
} else {
delete this.onEnterFrame;
}
};
}


How do I fix it?


/Klas

Time Function
Hey guys, this is the time function im using :

var dt, timeint;
dt = new Date();
ch = dt.getHours();
cm = dt.getMinutes();
cs = dt.getSeconds();
timeint = setInterval(timer, 1000);
function timer() {
dt = new Date();
ch = dt.getHours();
cm = dt.getMinutes();
cs = dt.getSeconds();
}

..but im having some problem with its display, is there any way to sort it out so that it shows a 0 infront of single digits?

this one displays like this : 10:35:14
when single digit : 10: 6: 8

is there any way to make it 10:06:08? a different function perhaps?

thanks

Time Out Function
Hello,

Could anybody tell me how I can use a time function to make an event wait for a certain moment of time please?

I tried using getTimer(). This what I have done, I created this function in the first keyframe on the timeline.

function autoplay(starttime){
curtime = getTimer();
elapsedTime = curtime - starttime;

if(elapsedTime >= 3000){
boardBox.text = defaultmsg;
}
}

Then I called it in a button
on(realease){
....some code
starttime = getTimer();
autoplay(starttime );
}

However, it does not work.

The idea behind this code is that the function is supposed to populate a text box with some text after 3 seconds from the time the user hits the button.

Thanks

Help Out With Get Time Function
Hey guys

I need to be able to get the time and then depending on the time move an mc to a certain Y position this is what I thought it could be but it dont seem to work...


ActionScript Code:
onClipEvent (load) {
     _y = 600;
     div = 5;
     endY = -36;
     hours = clock.getHours();
}
onClipEvent (enterFrame) {
     _y += (endY-_y)/div;
     
     if (hours == 06)
     endY = -183;
     
     if (hours == 07)
     endY = -135;
     
     if (hours == 10)
     endY = -85;
     
     if (hours == 14)
     endY = -36;
     
     if (hours == 18)
     endY = 14;
     
     if (hours == 22)
     endY = 62;
     
     if (hours == 01)
     endY = 111;
     
}

If someone could point me in the right direction i would most appreciate it

Time Function? At 12:00 Go To And Play...
Hi All,

I want to be able to loop a movie, however, when the current time gets to the top of the hour, make the movie go and play another part of the movie.

E.g.

If time = 12.00 go to and play frame32
If time = 1.00 go to......... etc.

Is this possible?
Cheers,

James.

Function After Time Delay
Hi everyone,
I have a presentation in flash I completed about a month ago. It is a slideshow like movie, but I created it manually, not using the slides utility. Basically it stops at each slide until a button is clicked, when executes the gotoAndPlay function.

I now need the show to run automatically now; have a time delay once it reaches each slide, then automatically progress as if a button was clicked. I could manually insert frames in the timeline but it is already 1400 frames long and it would take me hours to do.

If someone could write me a litte code that will execute a function after a time delay, I would really appreciate it. I tried help abe tutorials but obviously I am looking in the wrong place.

Cheers,
Ollie
(Flash 8)

Blur Function - Time
Hi, i have a blur function that is called from a mc onto the main time...it works fine however the effect is rather too fast...How do i changed the code below to make the blur transistion take 3 seconds



Code:
import flash.filters.BlurFilter;
var blurX:Number = 30;
var blurY:Number = 30;
filter = new BlurFilter(blurX, blurY, 3);
filterArray = new Array();
filterArray.push(filter);
_root.bk.filters = filterArray;


Note: the frame rate on the maintimeline is 25fps..if this helps!

Many thanks in advance

[MX04] Get The Time Function
is there a way to make flash get the time and split it into 3 seperate numbers, hours minutes and seconds? or im fine with just hours and minutes help please!

Function Running Twice At Same Time?
Hello everybody, I am attempting to make a site draw itself with actionscript courtesy of Jim's Flash Bestiary, which can be found here.

Anyway, to the point:

Is there a way to make multiple instances of this function work at the same time? In other words, I want to have multiple "signatures" drawing themselves each time the frame is entered, instead of just one. I tried to do creative things with the script, but I'm at a loss.

The script:

ActionScript Code:
drawSigEF = function()
{
if (getTimer() - this.t >= this.sig[this.i].t*.5)
{
var px = this.sig[this.i];
if (px.m) this.lineTo(px.x, px.y);
else this.moveTo(px.x, px.y);
if (++this.i >= this.sig.length) delete this.onEnterFrame;
}
}

MovieClip.prototype.drawSig = function(sig, thick, clr)
{
this.clear();
this.lineStyle(thick, clr, 100);
this.i = 0;
this.sig = sig;
this.t = getTimer();
this.onEnterFrame = drawSigEF;
}

// Example script usage (using root)
_root.drawSig(sig, 1, 0xFFFFCC);

// Example of a signature, "sig", (the array of
// points etc that makes the signature or drawing.
sig = [
{m:0,x:196,y:47,t:2009},
{m:1,x:192,y:54,t:2042},
{m:0,x:27.4,y:138.7,t:1968},
{m:1,x:26.6,y:137.9,t:2001},
{m:0,x:0.8,y:564.55,t:34033},
{m:1,x:4,y:571,t:34090},
{m:0,x:118.55,y:31.45,t:46580},
{m:1,x:119.35,y:30.65,t:46614},
{m:0,x:12.9,y:15.3,t:3869},
{m:1,x:15.3,y:27.4,t:3902},
{m:0,x:12.9,y:7.25,t:5496},
{m:1,x:14.5,y:12.9,t:5529},
{m:0,x:12.9,y:9.65,t:6288},
{m:1,x:23.35,y:11.3,t:6321},
{m:0,x:13,y:594.95,t:6816},
{m:1,x:18,y:595.95,t:6850},
{m:0,x:13.7,y:4,t:7413},
{m:1,x:9.65,y:5.65,t:7447},
{m:1,x:138,y:576.95,t:1663}
];

I'd also love to learn a more efficient way of doing this, if there is one out there that exists. I just would love to record my drawing on my graphics tablet, have a flash file "replay" the drawing movements, and have that be the layout of the site. Thanks very much everybody,

-Matt O, AS newb.

Function Works One Time But Not Another
ActionScript Code:
function automortgage(amprop) {
    trace("automortgage() called")
    _root[formatName(amprop)+"-bkg"].gotoAndStop(uni[amprop+" | owner"]+"_mortgaged");
    _root.uni[amprop+" | mortgaged"] = true;
    _root[uni[amprop+" | owner"]+"money_txt"].text = calc(_root[uni[amprop+" | owner"]+"money_txt"].text, uni[amprop+" | mortgageprice"], "+");
}

//this works:
automortgage("Planetarium")

//this changes the uni[amprop+" | mortgaged"] to true and changes the textfield, but it does not move the cursor in the timeline in _root[formatName(amprop)+"-bkg"].  Again, it does do it in the syntax above.
chargeMoney("green", 1001)
changeHands("Planetarium", "green")
automortgage("Planetarium")

function computerMakeMoney() {
    //this is within ifs, loops, etc if that makes a difference
    automortgage(compProps[compi]);
    //where compProps[compi] could be any property including Planetarium, which is my testing property.
}


What is my problem

Looping Xml Time Function. . . Could Someone Help?
I am trying to make a function for looping according to my endtime. The jpeg loads up and once it hits the endtime it needs to jump to the next jpeg. I have my jpeg fading in and out with a regular setInterval function, but I need a time function according to the xml file endtime.

Here's a sample of xml file:
<count id="1">
<mediatype>1</mediatype>
<information>Introduction</information>
<endtime>12</endtime>
</count>
<count id="2">
<mediatype>2</mediatype>
<information>Clip 2</information>
<endtime>50</endtime>
</count>
<count id="3">
<mediatype>3</mediatype>
<information>Clip 3</information>
<endtime>150</endtime>
</count>

This is a sample of my actionscript:

Code:
myInterval = setInterval(beginFadeOut, time());

function beginFadeOut() {
clearInterval(myInterval);
mc.fadeIn(100, 7);
}
function time() {
sec = ((10/5)*1000);
trace("seconds called");
return sec;
}
I need this time function to be replaced with a function that holds the value of endtime, then loops to get the other value once endtime has been met.

Could someone help me on this topic or point me in the right direction?
You help would be greatly appreciated!

Thanks in advance,
cbs

Position As A Function Of Time. How?
I am new to AS and a little confused about the relation between position and time in AS.
If we have this code :

ActionScript Code:
onClipEvent(enterFrame) {    speed = 1;    this._x += speed;}


and a framrate 16 fps, how can we calculate the time it takes to move the MC from position A to position B ?
I mean how can vi control the speed here as a function of time (say as a function av fps) ?

Thanks for helping me with this.

mx-guest2004

Set Time(r )function Help MX Question
does anyone know how to set a time. I.E I have a sound and I want to set a time for this sound to make it play for a certain time and after it plays it should go to a certain frame, any help or tutorial will be helpful an dgreatfully appreciated

Defining The Time Of Day Function
Okay don't laugh, this is my first attempt at defining a function all by myself and surprise it don't work!

I'm sure you can see from below what I'm trying to create.

stop();
daytime = function () {
myDate = new Date();
var h = myDate.getHours();
if (h > 0 < 11) welcome = morning;
if (h > 11 < 17) welcome = afternoon;
if (h > 17 < 23) welcome = evening;
}
statement = ("good" + welcome + "!");

Basically dependent on the hour the text displays a relevent welcome message. Once I cracked this I was going to use the same code to alter an animaton of a scene to reflect the time of day.

Any help, as usual appreciated.

Mhunki

Help Needed With Time Function
Hi, I'm trying to make a clock that shows different times for different countries. here is the code for the clock but how do I make it show the time x hours forward or back?

onClipEvent (enterFrame) {
time = new Date();
mil = time.getMilliseconds();
s = time.getSeconds();
m = time.getMinutes();
h = time.getHours();
seconds._rotation = s*6+(mil/(1000/6));
minutes._rotation = m*6+(s/10);
hours._rotation = h*30+(m/2);
}

cheers

Optimize Time Function
Hi,

heres one for all you hardcore coders


My code works fine, but there is a LOT of redunancy, does anyone know how i can reduce the bloat ?


PHP Code:



// GMT offsets var moscow:Number = 3;var signapore:Number = 7;// get current time from time.php var sendData:LoadVars = new LoadVars();var receiveData:LoadVars = new LoadVars();receiveData.onLoad = function(success):Void  {    if (success) {        minutes = parseInt(receiveData.tm_min);        hours = parseInt(receiveData.tm_hour);        my_date = new Date(2007, 4, 15, hours, minutes, 0);        myDate_num = my_date.getTime();        getGmt();        getMosDub();        getSing();    } else {        trace("PHP fail");    }};sendData.sendAndLoad("php/time.php", receiveData, "POST");updateTimes = setInterval(function () {    getGmt();    getMosDub();    getSing();    myDate_num += 1*60*1000;}, 60000);function getGmt() {    my_date.setTime(myDate_num);    var hour = my_date.getHours();    var min = my_date.getMinutes();    if (min<10) {        min = "0"+min;    }    if (hour == 0) {        hour = 12;    }    if (hour>12) {        hour -= 12;        ampm = "pm";    } else {        ampm = "am";    }    brighton.text = hour+":"+min+ampm;}function getMosDub() {    my_date.setTime(myDate_num);    var hour = my_date.getHours()+signapore;    var min = my_date.getMinutes();    if (min<10) {        min = "0"+min;    }    if (hour == 0) {        hour = 12;    }    if (hour>12) {        hour -= 12;        ampm = "pm";    } else {        ampm = "am";    }    mos.text = hour+":"+min+ampm;}function getSing() {    my_date.setTime(myDate_num);    var hour = my_date.getHours()+moscow;    var min = my_date.getMinutes();    if (min<10) {        min = "0"+min;    }    if (hour == 0) {        hour = 12;    }    if (hour>12) {        hour -= 12;        ampm = "pm";    } else {        ampm = "am";    }    sing.text = hour+":"+min+ampm;} 

Function And Delay Time
Hi,

i have this as


ActionScript Code:
function animaTexto(txt, pt) {    attachMovie(txt, txt, this.getNextHighestDepth());    this._x = (Stage.width/2);    this._y = (Stage.height/2);    this._alpha = 0;    Tweener.addTween(this, {_alpha: 100, time: t, delay: d+pt});    Tweener.addTween(this, {_xscale: 150, _yscale: 150, time: t, delay: d+pt, transition: "easeoutelastic", onComplete: OutTxt});}function OutTxt() {    Tweener.addTween(this, {_alpha: 0, time: tO, delay: dO});    Tweener.addTween(this, {_xscale: 1500, _yscale: 1500, time: tO, delay: dO, transition: "easein"});}animaTexto("t10", 0);animaTexto("t9", 2);


but show me the text at same time, like do not reading the delay time.
i using mcTweener class.

any idea what can be wrong?

Run A Function On String All At The Same Time?
Okay....How can I put this... Okay, here goes nothing.. I have an online app that allows a user to select as many strings as they want from a dynamic textbox, then run a function on them. Can you do that without a for loop so that it runs the function on them all at once?

Please help,
-The M95

Position As A Function Of Time. How?
I am new to AS and a little confused about the relation between position and time in AS.
If we have this code :

ActionScript Code:
onClipEvent(enterFrame) {    speed = 1;    this._x += speed;}


and a framrate 16 fps, how can we calculate the time it takes to move the MC from position A to position B ?
I mean how can vi control the speed here as a function of time (say as a function av fps) ?

Thanks for helping me with this.

mx-guest2004

Set Time(r )function Help MX Question
does anyone know how to set a time. I.E I have a sound and I want to set a time for this sound to make it play for a certain time and after it plays it should go to a certain frame, any help or tutorial will be helpful an dgreatfully appreciated

Defining The Time Of Day Function
Okay don't laugh, this is my first attempt at defining a function all by myself and surprise it don't work!

I'm sure you can see from below what I'm trying to create.

stop();
daytime = function () {
myDate = new Date();
var h = myDate.getHours();
if (h > 0 < 11) welcome = morning;
if (h > 11 < 17) welcome = afternoon;
if (h > 17 < 23) welcome = evening;
}
statement = ("good" + welcome + "!");

Basically dependent on the hour the text displays a relevent welcome message. Once I cracked this I was going to use the same code to alter an animaton of a scene to reflect the time of day.

Any help, as usual appreciated.

Mhunki

Function () Set Time Out Problem
hi.
i want to make a slide show and my .*fla contains 20 frames and every frame contains a picture.
how can i make the movie wait for... let's say 5 sec before it plays the next frame?

i tried to put a function with set time out in every frame, but the movie gets quit messy... and seems to play all images in random order.

any solutions?

Setting A Time Function
OK...So I saw a bad mambajamba site the other day where I believe the creator uses a movie clip to display a different background image that coincides with the time of day where the viewer is. Its a fun little item but now some other guy wants me to do a similar variation. How would I even go about setting that one up? and I know I suck at AS so can anyone throw me a bone.

Anyone seen a Tut on this one?

I don't want to go all out. I just want to have the MC switch between two different images, or rather color backgrounds, for two set parameters of the day.

i.e. 7 AM thru 7 PM = orange color image, 7:01 PM thru 6:59 AM = dark blue color image.

Any help?

Spanks

[NEED FUNCTION] Time Calculator
Anyone have a handy function that adds two times together i.e start and end time to get the time duration??

Cheers!

Calling A Function Every Amount Of Time
I want a function to be called every certain amount of seconds ... and Ill eventually want it to be a random number between like 2-10 seconds ... how would I do that?

Time Function Not Working Properly?
Hello all,

I've been working on this project for months and I'm finally coming near the end and things are getting a little tougher.
I am wonder if anyone could help me on solving my time function problem.

The old way I have it at a standard 5 seconds, but when I try to read in the xml file put in an array and make it display according to the endtime, it outputs NaN, when I trace the sec.
ex. If endtime is 6 I need it to display for 6 second, then read the next endtime. The next endtime is 3, display for 3 seconds, and so on.
If I'm not making sense I will post a .fla file.


Code:
load_xml = new XML();
load_xml.ignoreWhite = true;
load_xml.onLoad = function(success) {
if (success) {
process(load_xml);
} else {
trace("Something is wrong, we're not opening!");
}
};
//Load up the XML file into Flash
load_xml.load('xmlFade/images2.xml');
//---Function that will be called when xml loads succesfully
//xmlDoc_xml is now a reference to the XML object where our information is stored
//item_arr = new Array("img", "startdate", "enddate", "url");
var cnt = 0; // jbum - counter for fades
var outputAry = new Array(); // jbum
var timerAry = new Array();
var tcnt = 0;
function process(xmlDoc_xml) {

var count = 0; // jbum counter for loading array
var tmrCnt = 0;
for (var n = 0; n<xmlDoc_xml.firstChild.childNodes.length; n++) {
if (xmlDoc_xml.firstChild.childNodes[n].nodeName == "promo") {
var str = xmlDoc_xml.firstChild.childNodes[n].childNodes[0].firstChild;
_global.timer=xmlDoc_xml.firstChild.childNodes[n].childNodes[1].firstChild;
trace(" output ["+count+"] = "+str);
outputAry[count++] = str; // store in array
trace(" Timer ["+tmrCnt+"] = "+timer);
timerAry[tmrCnt++] = timer; // store time in array
}
//This is where the loop ends
}
mc.fade(0, 7);
}
MovieClip.prototype.fade = function(endAlpha, speed) {
trace("called fade");
if (outputAry[cnt] == undefined) {
stop();
myInterval = setInterval(stopFade, time());
} else {
output = outputAry[cnt];
cnt = cnt+1;
}
if (this._alpha>endAlpha) {
speed *= -1;
}
this.onEnterFrame = function() {
if (Math.abs(endAlpha-this._alpha)>Math.abs(speed)) {
this._alpha += speed;
} else {
this.onEnterFrame = undefined;
myInterval = setInterval(beginFadeOut, time(sec));
this._alpha = endAlpha;
}
};
};
MovieClip.prototype.fadeIn = function(begalpha, speed) {
trace("called fadeIn");
this._alpha = 0;
if (this._alpha<begalpha) {
speed *= -1;
}
this.onEnterFrame = function() {
if (Math.abs(begalpha-this._alpha)>Math.abs(speed)) {

this._alpha -= speed;
} else {
process();
this._alpha = begalpha;
}
};
};
function beginFadeOut() {
clearInterval(myInterval);
mc.fadeIn(100, 7);
}
function time(sec) {
sec = ((timerAry[tcnt])*1000); //I need this one to work according to the xml file.
tcnt = tcnt+1;
//sec = ((10/2)*1000); //this is the old seconds holder.
trace("seconds called");
trace("here sec is "+sec);
return sec;
}
function stopFade() {
clearInterval(myInterval);
}

Here is my xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<images>
<promo>
<img>promo1.jpg</img>
<endtime>6</endtime>
<url>website</url>
</promo>
<promo>
<img>promo2.jpg</img>
<endtime>3</endtime>
<url>website</url>
</promo>
<promo>
<img>promo3.jpg</img>
<endtime>1</endtime>
<url>website</url>
</promo>
</images>

If anyone could help me with this particular function it would be greatly appreciated!

Thanks,
cbs

Can I Simply Invoke A Function Every Time A Var Changes?
Say I wanted to do something like this (not possible):
aNumber=99
aNumber.onChange=function(){
dNumber=aNumber
}

How would I do something like this?

Function Going Crazy Second Time Round
Okay, I've got an interactive flash app which creates survey questions and stores them in a database through ASP.

On one frame of the app there is a way of changing the order of the questions by use of a pseudo drag-and-drop function. The function essentially gets the original position of the question line (oldPos), then works out the new position based on the mouse Y position at release (y_pos) and changes the order accordingly. See code below.

code:
function getFormattedPosition(y_pos,oldPos){

newPosition = Math.round((y_pos - startHeight)/30)+1 + adjuster;
trace("newPos=" + newPosition);
if (newPosition >= _root.totalQs)
{
newPosition = _root.totalQs - 1;
}
if (newPosition < 1)
{
newPosition = 1;
}
trace(newPosition);
if (newPosition > oldPos)
{

temp= _root["survLine"+oldPos].ans;
tempDate= _root["survLine"+oldPos].date;
tempTitle= _root["survLine"+oldPos].title;
tempId = _root["survLine"+oldPos].id;
n = oldPos;
for (n==oldPos;n<=newPosition;n++){
changer=n+1;
_root["survLine"+n].title = _root["survLine"+changer].title;
_root["survLine"+n].ans = _root["survLine"+changer].ans;
_root["survLine"+n].date = _root["survLine"+changer].date;
_root["survLine"+n].id = _root["survLine"+changer].id;
//trace("changed= " + _root["survLine"+n].ans);
}
_root["survLine"+newPosition].ans = temp;
_root["survLine"+newPosition].date = tempDate;
_root["survLine"+newPosition].title = tempTitle;
_root["survLine"+newPosition].id = tempId;
}
else(newPosition < oldPos)
{
difference = oldPos-newPosition;
if (difference >0){
trace("difference="+difference);
temp= _root["survLine"+oldPos].ans;
tempDate= _root["survLine"+oldPos].date;
tempTitle= _root["survLine"+oldPos].title;
tempId = _root["survLine"+oldPos].id;
n = oldPos;
for(n==_root.oldPos;n>=newPosition;n--){
changer=n-1
_root["survLine"+n].ans = _root["survLine"+changer].ans;
_root["survLine"+n].date = _root["survLine"+changer].date;
_root["survLine"+n].title = _root["survLine"+changer].title;
_root["survLine"+n].id = _root["survLine"+changer].id;
trace(_root["survLine"+n].ans);
}
_root["survLine"+newPosition].ans = temp;
_root["survLine"+newPosition].date = tempDate;
_root["survLine"+newPosition].title = tempTitle;
_root["survLine"+newPosition].id = tempId;
}
}
}

Additionally, the cursor changes to a "gripping hand" MC while 'dragging' the line.

Anyway, problem comes after submitting the changes to the database. If you then return to the frame to re-edit the order the code starts acting strangely. The newPosition is recorded inaccurately and the gripping hand MC refuses to vanish on release.

Anyone know why it should work first time fine, but screwy after that? Sorry if I haven't explained it very well, thanks for any help.

E


EDIT: Ah, is fixed now.

Execute Function After Time Period
I would like to know what actionscript I need to add to the following code in order for the second function (gotoAndStop) to occur after a three second pause. Thanks.




on (release) {
getURL("http://www.chasingerections.com/ChasingErectionsSmall.mov",_blank);
gotoAndStop(order);
}

Display Time Using GetUTCHours Function
Hello

I downloaded one of the analog clock fla file and wants to change the time in it. Actually I want to display time of 4 different locations namely

New York
London
Karachi
Delhi

To do that I simply change the following line in my script according to the location
mydate.getUTCHours()


For example do display New York time I use
mydate.getUTCHours() - 10

To display London time I use
mydate.getUTCHours()

To display Karachi time I use
mydate.getUTCHours()+5

But when I use the following for Delhi it doesn't show the correct time
mydate.getUTCHours()+5.5

As you can see Delhi time is 5:30 hours ahead of GMT and it doesn't display the correct time when I use 5.5 or any other value with decimal like 6.5, 7.5 e.t.c.

Please tell me what do I do?

What's The Function That You Use To Wait For A Set Amount Of Time?
Searching this board for some keywords I'd think would be helpful, I came across setInterval(), but I can't seem to make it do what I want. Also, I seem to have to put a function as one of its parameters, whereas I simply want to insert a number into it and have it wait that long.

All I want to do is just make my code wait a while, then continue. So, basically, I'm looking for something like delay(3000); to wait 3000 milliseconds.

If you want some context on what I want to do, my Script creates a new movie clip, which scrolls onto the screen, where I want it to wait a few seconds, and then it continues off the screen.

For Loop Function That Parses 3 At A Time..
Hello!

I'm stumped on where to begin writing a for-loop that will help me populate a mc with three (or four) buttons at a time from an array. Conceptually it makes sense, but I don't know how to begin structuring the function.

Any pointers?

Function Called At Wrong Time?
I'm trying to call a function (loadLevel()) from within another function (Incarnate()), the problem is, the function loadLevel that I'm calling is executing after the rest of the Incarnate function, so I can't access the array created by the loadLevel function in the Incarnate function!

This is the code:

ActionScript Code:
package {
   
    import flash.display.Sprite;
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Loader;
    import flash.geom.Point;
    import flash.geom.Rectangle;
    import flash.net.*;
    import flash.events.*;
    import flash.text.*;
   
    public class Incarnate extends Sprite {
        // Create a bitmapData object which will hold the bitmap data for the currently displayed world
        private var world_bmpData:BitmapData = new BitmapData(stage.stageWidth,stage.stageHeight,false,0x666666);
        // Create a bitmap display object to hold the bitmapData object! [Otherwise we can't display it on screen!]
        private var worldBitmap:Bitmap = new Bitmap(world_bmpData);
        // This is used to load the XML level data.
        private var xmlLoader:URLLoader;
        //This variable is used for storing XML level data.
        private var tileData:XML;
        // This array holds the locations/types of all tiles in the world map.
        private var aLevelMap:Array=new Array();
        // This variable brings in and holds the Bitmap Data from our library tilesheet image.
        // The arguments are width, height.
        private var tile_bmpData:BitmapData = new tileSheet(80,40);
        // This rectangle is used to select the tiles for copying pixels to the world bitmap
        private var tileType:Rectangle;
       

        public function Incarnate():void {
            loadLevel();
            trace ("aLevelMap after loadLevel called is " + aLevelMap[1]);
           
            // add the main bitmap
            //addChild(worldBitmap);
        }
       
       
        private function loadLevel():void {
            // Load the XML file and call the loadComplete function to create a 2-dimensional array of tile locations.
            xmlLoader = new URLLoader();
            xmlLoader.addEventListener(Event.COMPLETE,loadComplete);
            xmlLoader.load(new URLRequest("level1.xml"));
           
        }

        private function loadComplete(evt:Event):void {
            tileData = new XML(xmlLoader.data);
            //For every column in the XML file
            for each (var vCount:XML in tileData.tilecol) {
                // Grab the values of the rows, convert the list to an XML string, and split them into an array,
                // then append this array to the end of aLevelMap array, making a 2-dimensional array.
                // This means Tiles can be accessed by their x,y coordinates by calling aLevelMap[x][y]
                aLevelMap.push( vCount.tilerow.text().toXMLString().split("
") );
            }
            trace("aLevelMap at end of function is " + aLevelMap[1]);
        }
    }
}

The array I'm trying to access is called aLevelMap, and the two traces come up in this order:

aLevelMap after loadLevel called is undefined
aLevelMap at end of function is 5,5,0,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,0

so it is clearly running the trace in loadLevel() after the one in Incarnate(), which is causing big problems

Any help would be greatly appreciated!

Thanks in advance!

Edit: Removed non-essential/commented out code for easier legibility

Call Function In Another Time Line
Hi i want to call a function that is its parent time line.

how can i do it in AS3.

i used to do it like this in as2:

_parent.myFunction();

Time Function Not Working As Expected. . .
Hello all,

I've been working on this project for months and I'm finally coming near the end and things are getting a little tougher.
I am wonder if anyone could help me on solving my time function problem.

The old way I have it at a standard 5 seconds, but when I try to read in the xml file put in an array and make it display according to the endtime, it outputs NaN, when I trace the sec.
ex. If endtime is 6 I need it to display for 6 second, then read the next endtime. The next endtime is 3, display for 3 seconds, and so on.
If I'm not making sense I will post a .fla file.

Code:
load_xml = new XML();
load_xml.ignoreWhite = true;
load_xml.onLoad = function(success) {
if (success) {
process(load_xml);
} else {
trace("Something is wrong, we're not opening!");
}
};
//Load up the XML file into Flash
load_xml.load('xmlFade/images2.xml');
//---Function that will be called when xml loads succesfully
//xmlDoc_xml is now a reference to the XML object where our information is stored
//item_arr = new Array("img", "startdate", "enddate", "url");
var cnt = 0; // jbum - counter for fades
var outputAry = new Array(); // jbum
var timerAry = new Array();
var tcnt = 0;
function process(xmlDoc_xml) {

var count = 0; // jbum counter for loading array
var tmrCnt = 0;
for (var n = 0; n<xmlDoc_xml.firstChild.childNodes.length; n++) {
if (xmlDoc_xml.firstChild.childNodes[n].nodeName == "promo") {
var str = xmlDoc_xml.firstChild.childNodes[n].childNodes[0].firstChild;
_global.timer=xmlDoc_xml.firstChild.childNodes[n].childNodes[1].firstChild;
trace(" output ["+count+"] = "+str);
outputAry[count++] = str; // store in array
trace(" Timer ["+tmrCnt+"] = "+timer);
timerAry[tmrCnt++] = timer; // store time in array
}
//This is where the loop ends
}
mc.fade(0, 7);
}
MovieClip.prototype.fade = function(endAlpha, speed) {
trace("called fade");
if (outputAry[cnt] == undefined) {
stop();
myInterval = setInterval(stopFade, time());
} else {
output = outputAry[cnt];
cnt = cnt+1;
}
if (this._alpha>endAlpha) {
speed *= -1;
}
this.onEnterFrame = function() {
if (Math.abs(endAlpha-this._alpha)>Math.abs(speed)) {
this._alpha += speed;
} else {
this.onEnterFrame = undefined;
myInterval = setInterval(beginFadeOut, time(sec));
this._alpha = endAlpha;
}
};
};
MovieClip.prototype.fadeIn = function(begalpha, speed) {
trace("called fadeIn");
this._alpha = 0;
if (this._alpha<begalpha) {
speed *= -1;
}
this.onEnterFrame = function() {
if (Math.abs(begalpha-this._alpha)>Math.abs(speed)) {

this._alpha -= speed;
} else {
process();
this._alpha = begalpha;
}
};
};
function beginFadeOut() {
clearInterval(myInterval);
mc.fadeIn(100, 7);
}
function time(sec) {
sec = ((timerAry[tcnt])*1000); //I need this one to work according to the xml file.
tcnt = tcnt+1;
//sec = ((10/2)*1000); //this is the old seconds holder.
trace("seconds called");
trace("here sec is "+sec);
return sec;
}
function stopFade() {
clearInterval(myInterval);
}
Here is my xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<images>
<promo>
<img>promo1.jpg</img>
<endtime>6</endtime>
<url>website</url>
</promo>
<promo>
<img>promo2.jpg</img>
<endtime>3</endtime>
<url>website</url>
</promo>
<promo>
<img>promo3.jpg</img>
<endtime>1</endtime>
<url>website</url>
</promo>
</images>

If anyone could help me with this particular function it would be greatly appreciated!

Thanks,
cbs

OnRelease...different Function Called The Second Time?
If I have a onRelease event on a MC...is it possible to have one set of functions called the first time it is released and a different set called the second time it is released?

Function Doesnt Work The 2nd Time
this is the xml




code:
Code:

<?xml version="1.0" ?>
- <images>
- <Branch name="1">
<Leaf text="bilder/1/ersie.jpg" url="bilder/1/ersie.jpg" width="300" height="500" />
<Leaf text="bilder/1/gbook.jpg" url="bilder/1/gbook.jpg" width="100" height="19" />
<Leaf text="bilder/1/map.jpg" url="bilder/1/map.jpg" width="300" height="500" />
<Leaf text="bilder/1/minime.jpg" url="bilder/1/minime.jpg" width="300" height="500" />
<Leaf text="bilder/1/ztourist.jpg" url="bilder/1/ztourist.jpg" width="300" height="500" />
</Branch>
- <Branch name="2">
<Leaf text="bilder/2/ersie.jpg" url="bilder/2/ersie.jpg" width="300" height="500" />
<Leaf text="bilder/2/map.jpg" url="bilder/2/map.jpg" width="300" height="500" />
<Leaf text="bilder/2/minime.jpg" url="bilder/2/minime.jpg" width="300" height="500" />
<Leaf text="bilder/2/tourist.jpg" url="bilder/2/tourist.jpg" width="300" height="500" />
</Branch>
- <Branch name="3">
<Leaf text="bilder/3/ersie.jpg" url="bilder/3/ersie.jpg" width="300" height="500" />
<Leaf text="bilder/3/gbook.jpg" url="bilder/3/gbook.jpg" width="100" height="19" />
<Leaf text="bilder/3/map.jpg" url="bilder/3/map.jpg" width="300" height="500" />
<Leaf text="bilder/3/minime.jpg" url="bilder/3/minime.jpg" width="300" height="500" />
</Branch>
</images>






this my main-as




code:
Code:


//include tween extension
#include "lmc_tween.as"
//
_global.SITE = "http://archiv/sites/flash/";
var data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {
if (success) {
trace("done loading");
makeArray(this);
slider(Menu_array);
} else {
trace("error");
}
};
function makeArray(_xml) {
if (!_global.pic_array) {
_global.pic_array = new Array();
}
this._xml = _xml;
var rootNode = _xml.firstChild;
//bilderchanger
var theNode = rootNode.childNodes;
var len = theNode.length;
var theSubNode = rootNode.firstChild.childNodes;
//array für bilderchanger
_global.Menu_array = new Array(len);
_global.Active_array = new Array(len);
//array für jedes unterbild
for (i=0; i<Menu_array.length; i++) {
var sublen = theNode[i].childNodes.length;
Menu_array[i] = new Array(sublen);
//array für die daten jedes bildes
for (j=0; j<Menu_array[i].length; j++) {
Menu_array[i][j] = new Array(3);
}
}
//fertiges array durcharbeiten
// anzahl der bilderchanger
var tmp_xpos = "0";
for (i=0; i<=Menu_array.length; i++) {
//erzeuge unterbilder
for (j=0; j<theNode[i].childNodes.length; j++) {
var cur = _level0.attachMovie("square", "sq"+i+"_"+j+"_mc", _level0.getNextHighestDepth(), {_y:ypos+50*j});
loadMovie(String(SITE+theNode[i].childNodes[j].attributes.url), cur);
//pos and scale
var cur_xpos = tmp_xpos;
cur._x = cur_xpos;
//erste bild zeigen rest nicht ;
if (j == 1) {
//cur._alpha = "100";
Active_array[i] = cur;
} else {
//cur._alpha = "0";
}
//menu array erstellen
Menu_array[i][j]['path'] = String(SITE+theNode[i].childNodes[j].attributes.url);
Menu_array[i][j]['mcname'] = cur;
Menu_array[i][j]['xscale'] = String(theNode[i].childNodes[j].attributes.width);
}
tmp_xpos = Number(tmp_xpos)+Number(spacer)+Number(Menu_array[i][0]['xscale']);
//trace(Number(tmp_xpos) + Number(spacer) + Number(Menu_array[i][0]['xscale']));
}
}
function callback() {
trace("callback_tween_out");
}
function acallback() {
trace("callback_tween_in");
}
function slider(array) {
//random picture group
changer_num_1 = random(array.length);
//fadeout old picture
fade_out_mc = Active_array[changer_num_1];
trace("fadeout-->"+fade_out_mc);
fade_out_mc.tween("_alpha", 0, 4, "linear", 0, callback);
//set the active pic of a pic group and show it
tween_in_mc = array[changer_num_1][random(array[changer_num_1].length)]['mcname'];
//set the new active array of a group
Active_array[changer_num_1] = tween_in_mc;
//fadein the new picture
trace("fadein-->"+tween_in_mc);
tween_in_mc.tween("_alpha", 100, 4, "linear", 1, acallback);
}
// alle 2000 ms einen bildwechsels durchführen
setInterval(function () {
slider(Menu_array);
}, 10000);
//
data_xml.load(SITE+"directory.php");





Homepage and main discussion thread of this tween extension http://proto.layer51.com/d.aspx?f=1142

want i would like to do ?
the picture of the xml should be shown in group.(in this case 3).
in each group are x subpictures


if the user loads the script, the three group should be shown with one picture (active), after some seconds one of the group change the subpicture by using the "alpha_to" prototype.


the problem is that i can see 3 pictures but nothing happens (no change)

thx

OnRelease...different Function Called The Second Time?
If I have a onRelease event on a MC...is it possible to have one set of functions called the first time it is released and a different set called the second time it is released?

Function Doesnt Work The 2nd Time
this is the xml




code:
Code:

<?xml version="1.0" ?>
- <images>
- <Branch name="1">
<Leaf text="bilder/1/ersie.jpg" url="bilder/1/ersie.jpg" width="300" height="500" />
<Leaf text="bilder/1/gbook.jpg" url="bilder/1/gbook.jpg" width="100" height="19" />
<Leaf text="bilder/1/map.jpg" url="bilder/1/map.jpg" width="300" height="500" />
<Leaf text="bilder/1/minime.jpg" url="bilder/1/minime.jpg" width="300" height="500" />
<Leaf text="bilder/1/ztourist.jpg" url="bilder/1/ztourist.jpg" width="300" height="500" />
</Branch>
- <Branch name="2">
<Leaf text="bilder/2/ersie.jpg" url="bilder/2/ersie.jpg" width="300" height="500" />
<Leaf text="bilder/2/map.jpg" url="bilder/2/map.jpg" width="300" height="500" />
<Leaf text="bilder/2/minime.jpg" url="bilder/2/minime.jpg" width="300" height="500" />
<Leaf text="bilder/2/tourist.jpg" url="bilder/2/tourist.jpg" width="300" height="500" />
</Branch>
- <Branch name="3">
<Leaf text="bilder/3/ersie.jpg" url="bilder/3/ersie.jpg" width="300" height="500" />
<Leaf text="bilder/3/gbook.jpg" url="bilder/3/gbook.jpg" width="100" height="19" />
<Leaf text="bilder/3/map.jpg" url="bilder/3/map.jpg" width="300" height="500" />
<Leaf text="bilder/3/minime.jpg" url="bilder/3/minime.jpg" width="300" height="500" />
</Branch>
</images>






this my main-as




code:
Code:


//include tween extension
#include "lmc_tween.as"
//
_global.SITE = "http://archiv/sites/flash/";
var data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.onLoad = function(success) {
if (success) {
trace("done loading");
makeArray(this);
slider(Menu_array);
} else {
trace("error");
}
};
function makeArray(_xml) {
if (!_global.pic_array) {
_global.pic_array = new Array();
}
this._xml = _xml;
var rootNode = _xml.firstChild;
//bilderchanger
var theNode = rootNode.childNodes;
var len = theNode.length;
var theSubNode = rootNode.firstChild.childNodes;
//array für bilderchanger
_global.Menu_array = new Array(len);
_global.Active_array = new Array(len);
//array für jedes unterbild
for (i=0; i<Menu_array.length; i++) {
var sublen = theNode[i].childNodes.length;
Menu_array[i] = new Array(sublen);
//array für die daten jedes bildes
for (j=0; j<Menu_array[i].length; j++) {
Menu_array[i][j] = new Array(3);
}
}
//fertiges array durcharbeiten
// anzahl der bilderchanger
var tmp_xpos = "0";
for (i=0; i<=Menu_array.length; i++) {
//erzeuge unterbilder
for (j=0; j<theNode[i].childNodes.length; j++) {
var cur = _level0.attachMovie("square", "sq"+i+"_"+j+"_mc", _level0.getNextHighestDepth(), {_y:ypos+50*j});
loadMovie(String(SITE+theNode[i].childNodes[j].attributes.url), cur);
//pos and scale
var cur_xpos = tmp_xpos;
cur._x = cur_xpos;
//erste bild zeigen rest nicht ;
if (j == 1) {
//cur._alpha = "100";
Active_array[i] = cur;
} else {
//cur._alpha = "0";
}
//menu array erstellen
Menu_array[i][j]['path'] = String(SITE+theNode[i].childNodes[j].attributes.url);
Menu_array[i][j]['mcname'] = cur;
Menu_array[i][j]['xscale'] = String(theNode[i].childNodes[j].attributes.width);
}
tmp_xpos = Number(tmp_xpos)+Number(spacer)+Number(Menu_array[i][0]['xscale']);
//trace(Number(tmp_xpos) + Number(spacer) + Number(Menu_array[i][0]['xscale']));
}
}
function callback() {
trace("callback_tween_out");
}
function acallback() {
trace("callback_tween_in");
}
function slider(array) {
//random picture group
changer_num_1 = random(array.length);
//fadeout old picture
fade_out_mc = Active_array[changer_num_1];
trace("fadeout-->"+fade_out_mc);
fade_out_mc.tween("_alpha", 0, 4, "linear", 0, callback);
//set the active pic of a pic group and show it
tween_in_mc = array[changer_num_1][random(array[changer_num_1].length)]['mcname'];
//set the new active array of a group
Active_array[changer_num_1] = tween_in_mc;
//fadein the new picture
trace("fadein-->"+tween_in_mc);
tween_in_mc.tween("_alpha", 100, 4, "linear", 1, acallback);
}
// alle 2000 ms einen bildwechsels durchführen
setInterval(function () {
slider(Menu_array);
}, 10000);
//
data_xml.load(SITE+"directory.php");





Homepage and main discussion thread of this tween extension http://proto.layer51.com/d.aspx?f=1142

want i would like to do ?
the picture of the xml should be shown in group.(in this case 3).
in each group are x subpictures


if the user loads the script, the three group should be shown with one picture (active), after some seconds one of the group change the subpicture by using the "alpha_to" prototype.


the problem is that i can see 3 pictures but nothing happens (no change)

thx

Random Time Interval To Call Function
what i'm trying to achieve is to be able to create a random time frame betw 1 to 8 seconds before it calls a movie clip from the library.


Code:
function layEgg(hens) {
//set random time in sec
var timeGap = Math.floor(Math.random()*(8-1))+1;
trace(timeGap);

hens.stop();

//converts to milliseconds by * 1000
var randomness = setInterval(hens,"playAfterRandomInterval", timeGap*1000);
}
hens.playAfterRandomInterval = function() {
trace("laying egg");

//plays the hen MC frame
hens.gotoAndPlay("layeggs");

//calls the function placeEgg where it will call a Mc from the library
placeEgg(hens);
clearInterval(randomness);
}


//movieclip henMC1
layEgg(henMC1);




however the time interval is not working. i managed to trace the random timeGap.

in summary: I have a hen MC playing, i want it to call another MC from library at a random time repeatedly. It all happens in 1 frame only.

Same Button Performing Different Function Each Time It Is Pressed?
Seems simple enough, but I just can't figure out how this is achieved. For instance I want one button to play a song and upon hitting the same button will stop it and so on and so forth. I can control it using multiple buttons, no problem of course. But that same button... that's my conundrum.

Can I Make A Function Wait For A Period Of Time?
Hey everyone

I just wanted some idea's on how best to tackle this problem in actionscript.

All I want is that when a button is pressed it fades out the current page and then fades in the new page to be displayed. How ever when trying to fade out the current page i doesn't because it goes to the label and starts to play but the next part of the script tells it to go straight to the label to load the new page. Does anyone have a clever way of making it wait till the current page is faded out?

If worse comes to worse can I just make it wait a set period of time before fading in the new page?

Ive attached a bit of the current code and comment it with where the current page is faded out.

Thanks in advance for any help

Gaunt







Attach Code

function homeClick(event:Event):void {
if(prevPage != "home")
{
if(prevPage == "advertising")
{
// Here is where the current page is told to fade out
MovieClip(this.parent).pages_mc.gotoAndPlay("advertisingEnd");
}
else if(prevPage == "websites")
{
// Here is where the current page is told to fade out
MovieClip(this.parent).pages_mc.gotoAndPlay("websitesEnd");
}
MovieClip(this.parent).pages_mc.gotoAndPlay("homeStart");
prevPage = "home";
}
}

Random Time Interval To Call Function
what i'm trying to achieve is to be able to create a random time frame betw 1 to 8 seconds before it calls a movie clip from the library.

Code:

function layEgg(hens) {
//set random time in sec
var timeGap = Math.floor(Math.random()*(8+1))+1;

hens.stop();

//converts to milliseconds by * 1000
var randomness = setInterval(hens,"playAfterRandomInterval", timeGap*1000);
}

//after time interval it should play the frame and call the MC from function placeEgg
hens.playAfterRandomInterval = function() {
trace("laying egg");
hens.gotoAndPlay("layeggs");
placeEgg(hens);
clearInterval(randomness);
}


//these hens are the MC
this.onEnterFrame= function(){
if(timeLeft >= 0){
layEgg(henMC1);
layEgg(henMC2);
layEgg(henMC3);
}else{
delete this.onEnterFrame();
}
}




//hens. refers to the henMC
//parent is where henMC is in
//this function calls the MC from library
function placeEgg(hens){
var depth:Number = hens._parent.getNextHighestDepth();
var egg:MovieClip = hens._parent.attachMovie("eggMC", "eggMC_" + depth, depth);
}
however the time interval is not working. i managed to trace the random timeGap. any idea?

Call A Function Every Time On Movie Load
Hi everyone
I have a movieclip by name popup1. When I click on a button I am calling this movielcip using
popup1._visible=true;
I want that whenever I am calling this popup1, a function refresh should always be called. How can I do that?
Thanks

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