ActionScript 2.0 :: Dynamically Naming & Clearing Intervals?
Dec 19, 2006I am trying to dynamicallly name intervals and clear them. Here's my code:
[AS]
_root.onMouseDown = function() {
setMyInterval();
};
[Code]....
I am trying to dynamicallly name intervals and clear them. Here's my code:
[AS]
_root.onMouseDown = function() {
setMyInterval();
};
[Code]....
Ok, I've been climbing the walls trying to figure this out, looked everywhere for an answer, learned a few bits and pieces along the way, but still can't do it.I've made my Class which is a little movieclip called 'block', it's fine and does what I tell it to do ie. I can reposition itstretch itotate it and stuff.The problem is.. I want to make more of them and reference them individualy so I can change the properties of them individualy ie, the x and y values etc.
for (var i=0; i<2; i++){
var newBlock:blocks = new blocks();
this.addChild(newBlock);
[code].....
or some reasons i need to create var dynamicaly.
Exemple
I have first an Array wich i want to use to "compose" my vars names
myArray:Array = new Array("aa","bb","cc");
In my final project this Array is created from a xml.
I want to do something like this, but doesn't work...
var ["myvar" + myArray[0]]:Sound = new Sound();
var ["myvar" + myArray[1]]:Sound = new Sound();
var ["myvar" + myArray[2]]:Sound = new Sound();
[Code].....
Is it possible to dynamically name a variable? Like set a certain string as a variable name wouldn't think so but just in case.
View 2 RepliesCode:
public function btnU1Out_Handler (event:Event ):void {btnUOut_Handler(1);}
public function btnU2Out_Handler (event:Event ):void {btnUOut_Handler(2);}
[code]......
I am going to have a button that when you click on it it creates a movieclip and adds a certain child to it (In this case, its linkage is set as "Rifle"). Each time you click on the button I need to give the new movieclip a different instance name then the last, such as "Riflemen1", "RifleMen2" etc.. I will need to be able to refer to each movieclip seperatly in my code, such as for example:
You spawn three Riflemen.. You click on one of them, which selects it, you then click on an "Attack" button which makes only him start firing (in my case gotoAndStop(2)), you then decide you want the third one to attack and so forth..
I'm trying to name the instances of MovieClips that I dynamically load.
I tried doing this:
comp = new Comp();
// and also tried doing this--> var comp:MovieClip = new Comp();
comp.name = "comp"; // comp is the name I want the instance to be
[Code]....
i am using a loop function to generate an place instances of a movie clip on the stage. the movie clips are being used as buttons, they have text in them. here is the code
ActionScript Code:
// butAniMini is an external custom class animating the buttons
var _sideBarBut:butAniMini;
//variables to hold the first buttons x an y position
[code]...
the problem is that i dont no how to set the text in the buttons so u can change the text and add event listeners etc to them
I have a project that requires manipulation of a movie clip (swf file). This clip is called clip_mc.I have functions such as:[code]If I add to the stage the swf and call it clip_mc, then everything is fine and it all works - BUT I have a few of these files that need to be loaded when the button is clicked.I understand the loader() class and the addChild class but cant get my head around bringing them all together!so essentially I would like to know; How to dynamically load the swf and name it clip_mc so that the functions will work?!
View 2 Repliesk say i wanted to create a bunch of movieclips in a for loop but wanted to name them something different each time, how would i dynamically name them?
View 1 Repliespanning my content from left to right (with stop as intervals) then right to left (also with intervals)
1. I created an mc (name: "content")Notice in this mc, I layout 4 sets of text (like a page) from left to right
2. I created another mc (name: "pancontent_mc")
-I added a layer for "content" and created a motion tween for it to pan from left to right
-I created a mask layer on top of "content" that will show 1 set at a time
-I created an action layer that has total of 4 stops(); on each frame where the 4 sets of text will show directly under the mask.
3. maintimeline -There's only 1 layer. I placed an instance of buttons (left/right) and an instance of "pancontent_mc"
4. actions for right button, works fine and stops on each set of text.
on (release) {
this.pancontent.play();
}
5. actions for left button - none. I havent figured this out yet.
on (release) {
this.pancontent. - something like play previous frame until stop...
}
I'm having some issues with a thumbnails scroll that I found in another forum. I was able to modify it to fit my needs, but now I want to incorporate a interval that plays my next image without having to click on the buttons. I have tried several methods but nothing seems to work. here is the code:
descriptions=true;
alert._visible=false;
var ease = 5;
[Code].....
basically what im trying to do is have a basic countup timer that goes in intervals of three. (3,6,9,12,15,ETC.) but it has to run with a 12 fps and not stop. also this cannot be 1000 frames long .
View 12 RepliesI am working on a project and it is almost there basicly its a cracker that opens after a set interval of 1500,
I then want it wait for 20 seconds and open again and in a loop every 20
I have tried clearInterval but doesn't work for me
heres my code & fla attached
Code:
//IMPORT TWEEN ENGINE START
import mx.transitions.Tween;
import mx.transitions.easing.*;
//IMPORT TWEEN ENGINE END
[Code]....
I've got one function that I'm running, but I need it to run at different times for different movie clips.Here's my code. What is wrong with this?
ActionScript Code:
function tweenText(_TEXT:MovieClip, _START:Number, _END:Number, _SEC:Number, _INTERVAL:Number) {
var xTween:Tween = new Tween(_TEXT, "_x", Strong.easeOut, _START, _END, _SEC, true);
clearInterval(_INTERVAL);
[code]....
I'd like to change a timer interval, In my code I first initialize the timer with a selected interval with :
Code:
gameTimer=new Timer(interval,0);
gameTimer.addEventListener(TimerEvent.TIMER, IALoop);
gameTimer.start();
Then, I need afterwards to change the interval, so I try to stop the timer, remove the listener
Code:
gameTimer.stop();
gameTimer.removeEventListener(TimerEvent.TIMER, IALoop);
And when I init again the timer with the same code:
Code:
gameTimer=new Timer(interval,0);
gameTimer.addEventListener(TimerEvent.TIMER, IALoop);
gameTimer.start();
It's like if i had 2 timers, and when i stop the timer, it continues, I guess it's because of the new object that I create, but I can't found a method to change the interval of the existing timer..
i 'd like to know if there is a way to clear all Intervals in a movie with one command.in my current project I use setInterval()very often in different clips and though i cleanly put the corresponding clearInterval() commands in the script I realized, that on slow computers some of them don't get stopped.Which puts more weight on the CPU and sometimes slows down the comp very much.
View 9 RepliesI am working on a project that need to countdown what is in stock.
Right Now I have the banner counting down but how do I get it to count in different intervals?
Right now I have an interval setIt = setInterval(this, "counter", 8000);
But I want it to go form 8 sec. to 1 sec. to 8 sec.
I just started learning Flash as part of a project, consisting of a spider-like figure which is supposed to vibrate every 20 seconds. I've basically got the vibrating to work but am having more trouble learning about getting it to vibrate at different intervals. I was hoping that someone here could point me in the right direction as to where to find this information, even an applicable tutorial or something.
View 6 RepliesI am working on a Flash Video player and am implementing the ability to start a video at x time within the span of an FLV (served from FMS). I am able to start it x seconds into a stream without any issue using
netStream.play(source, startTime);
but as far as I can tell, it only supports seconds. I am looking to be able to give a start time (or even a seek time if that is supported) in milliseconds, or really anything more precise than whole seconds.
Anyone know of any way to achieve this even by monkey patching the fl classes?
I have a Flex chart and on the x-axis want to be able to have different intervals set so I can draw gridlines.For example the axis may be from 0 to 82 and I would want to have an interval at 6,8, 21, 29, 40, 49, 52, 59 and 70.
View 1 RepliesI have three Flash movies (all the same pixel size) that I want to use on the home page of my website which is built in MX 2004.
How often the movie changes is not critical, but I think once an hour will be fine. What's the best way to get Flash to automatically change the movie every hour and where should I attach any code - to an Actions layer in movie no. 1?
As a summary, here's what I want to achieve;
12.00pm - movie no. 1 plays
1.00pm - movie no. 2 plays
2.00pm - movie no. 3 plays
3.00pm - movie no. 1 plays again
...and so on for 24 hours until you get back to 12.00pm when movie no. 1 plays again.
check this code out:
[Code]...
I was wondering, is there a way to change if (myClip_mc._x < 400) { to a relative position of myClip_mc. I mean, i want myClip_mc to move 100px from it's current position everytime the button is clicked. Instead of only moving it if it's x position is less than 400. So it needs to somehow check it's current position everytime the button is clicked and then make it shift from that position. I know this is a long winded way of doing it but i want it this way so i can use it for something different.
A project I'm working on is working just fine at first, but as I perform more actions, it slows down noticeably. I've made sure to clear any onEnterFrame and setInterval events, so I don't think the problem lies there. Most likely, it's because practically every time an action occurs, much of the content on the screen is redrawn/recreated. However, every time I create a movie clip, text field, shapes, etc., I call a function to remove it beforehand:
Code:
function killThis(mc:MovieClip, thingsName:String):Void{
var obj:Object = mc[thingsName];
if (obj instanceof MovieClip){[code]..........
Its seems a problem I am having is to do with setIntervals in a while loop. I clear what seems to be the interval but as another interval is started before the last one finish I then have multiple intervals. I can close them all down with this...
for (i= checkImage;i>0;i--){
trace("clearInterval(checkImage) " +i);
clearInterval(i);}
But that ofcourse closes the rest down before they have done what I need.
I think my while loop needs to change? Here is the current while loop code....
function loadImages(){
while (imageWidthList[leftPictureNumber+imagesDisplayed] > 0 and xPosition +(imageWidthList[leftPictureNumber+imagesDisplayed]+(borderThickness*3)) < 700) {
var img_mcl:MovieClipLoader = new MovieClipLoader();
linkLayer = this.createEmptyMovieClip("link"+(leftPictureNumbe r+imagesDisplayed), _root.getNextHighestDepth());
[Code] .....
Is there a way that straight after the setInterval and the loadClip the function watchMyImageLoad is run to completion before continuing in the while loop. What I have seen is that the while loop continues until the condition has been met and then all the intervals are run?
There are a few fairly intensive procedures the class goes through, which require me to stagger out the action taking place. That is to say, if I were to use recursion, there are times when I'd easily hit a stack overflow, so to compensate I'm avoiding recursion through recording information in class level variables and running through the routine again (and again and again) on an ENTER_FRAME event.
This all works great, and I'm happy with the result. The only annoying bit is that performance is better when the frame rate's higher (and slower when it's lower). Run the class at 30fps, and the time it takes to complete is significantly slower than at 120fps. No surprise there, but still annoying since I'm not interested in making the user make changes in their framerate to accomodate the class.
So I considered switching to a timer-based method, but then I remembered something about the Timer class accomodating the framerate of the SWF. Looking it up confirmed what I remembered:
...if a SWF file is set to play at 10 frames per second [fps], which is 100 millisecond intervals, but your timer is set to fire an event at 80 milliseconds, Flash Player will fire the event close to the 100 millisecond interval.
Now I'm wondering if it's even worth the effort, since it would appear that the end result would be much the same as it is now using enter frame.
I have a barometer activity flash program. It's weather themed and at each stage of the barometer fill, a movie clip appears that has as-generated weather icons (i.e. rain, clouds) floating across the screen. The problem is once I click to the next level of the barometer, the weather icons keep flashing in the upper left corner. I tried putting clearInterval in various places but it didn't seem to do anything.
View 7 RepliesIs it possible to somehow tell what scripts/intervals/onEnterFrames are still running in a flash file while viewing the .swf? I seem to be having some possible RAM issues with the .swf and just curious if there is a way to track this.
View 9 Replieshow would i resize the window in a flash movie at different intervals? example here:[URL] in that movie, the window box resizes at different set intervals.
View 4 RepliesI have this movie clip that's a solid color with 60% transparency. I have 24 copies of this, all with instance names of light_mc1, light_mc2 and so on. What I'm trying to do is have them transition their colors not only randomly and constantly, but in unison. The transition has to be smooth, it can't just instantly show red in one frame, then green in the next. I have to be able to see it smoothly change to green, or whichever color is randomly selected.
View 7 Replies