ActionScript 2.0 :: Using SetInterval With MovieClips - Instance Not Been Scoped
Dec 18, 2009
I have created a number of Movieclips as part of my Navbar such as About Us, Contact etc. I'm using setInterval to send them to a function that springs them open one after another using the tween class. The they are dynamically generated and positioned using the following code, however when I want to use them as buttons by using onRollOver or onRelease they act like I'm not scoping them correctly. In other words the cursor does not change into a hand when over them. This is a setInterval issue as if I have them open just using attachMovie, the scoping works just fine.
The actual code is as follows:
function aboutUs () {
var mcAboutUs:MovieClip = this.attachMovie("mcAboutUs", "aboutUs_mc", 20, {_x:197, _y:520});
var x_elasticTween:Tween = new Tween (aboutUs_mc,"_xscale",Elastic.easeOut,0,100,1,true );
var y_elasticTween:Tween = new Tween (aboutUs_mc,"_yscale",Elastic.easeOut,0,100,1,true );
clearInterval(_global.intervalID1);
} function setIntervals() {
_global.intervalID1 = setInterval(this, "aboutUs", 1000);
There are more in here, each going to its own function to attachMovie and Tween them. This all works fine.
setIntervals();
this.aboutUs_mc.onRelease = function() {
OnRelease is suppose to activate another function that generates the "About Us" page but nothing happens as if the instance is not been scoped.
page_aboutUs();
}
View 2 Replies
Similar Posts:
Jul 17, 2009
I'm trying to pass two movie clips into a set interval function, just for a simple fade effect. It's been a little while since I've used the setInterval so I may be missing something, but I thought it was possible to pass movie clips into a interval function.
Here is what I have so far:
Code:
btnHitArea.onRelease = function() {
intMain = setInterval(fuzzy, 100, ["mc1", "mc2"]);
}
[Code]....
View 1 Replies
Nov 3, 2005
Is there an easy way to animate multiple movieclips without using a lot of functions and setInterval??I want an animation to start and before it's finished another one starts, right now I'm using a ton of functions and setInterval but I'm sure there's a cleaner more efficient way to achieve this.
View 6 Replies
Jan 11, 2009
I am generating movieClips dynamically using attachMovie and then using a setInterval to animate them. However, if I repeat the operation the second set of mcs move twice as fast, the third set three times as fast etc. I can't for the life of me work out why.
[Code]....
View 7 Replies
Feb 6, 2010
it doesn't seem like you can use locally scoped vars within a static block?For example I was thinking I could do:
Code:
public static var standardAgeRange:ArrayCollection = new ArrayCollection();
//static block
{
[code]....
but apparently I have to first declare _n as a static var of my class (or as a static var within the block itself) in order to use it within the static block.needed to do...
private static var _n:int = 2;
then in the static block:
for (_n=2; _n<120; _n++)
In Java I'm able to use locally scoped variables within the static block. I know this isn't Java, just wondering if I'm missing something fundamental. (I couldn't find a lot of documentation online concerning static blocks in AS.)
View 1 Replies
Jul 5, 2011
I see this type of apparent magic in all sorts of AS3 code, but here is a reduced example:
[Code]...
As indicated in the code comment, the loader variable should fall out of scope after the URLLoaderExample constructor. However... it still seems to be kept alive (not garbage collected) somewhere since the onComplete listener/handler is able to receive it cleanly. Where is the magic/hidden/global reference to loader that keeps it alive so that it can complete it's load operation, and then be handed to the onComplete listener/callback? Can this reference be seen somewhere?
To help with context... as a similar example, I know that the loader instance will have the onComplete listener registered. I also know I need to be careful to use removeEventListener at all times (?) to avoid potential memory leaks resulting from stranded listeners. What concerns me is that I don't understand where the magic loader reference is and whether (or when) I need to clean that up.
View 3 Replies
Feb 18, 2010
Is it possible to compile movieclips to swc with the instance name as property name? This happends when I add a dynamic text field, but i would like this also on some UI elements.
View 1 Replies
Jan 27, 2012
I have 2 copys of the same Movieclip on the timeline and I need them both to do the exact same thing, so I figured I'd give them the same instance name.
I have an event listener on the stage that listens for a mouse click and then checks what has been clicked usiing a switch statment, but the switch statment only picks up one instance of the movieclip, the other one comes up as the default.
Mainly what i'm asking is, is it possible to have to movieclips on the timeline with the same instance name?
public function Main() {
stage.addEventListener(MouseEvent.CLICK, doStuff);
}
public function doStuff(e:MouseEvent):void {
[Code]....
View 2 Replies
Aug 28, 2010
I've been working on a game recently. I wanted to know if I can have two movieclips (Tabl1_ON & Table2_ON) have the same instance name, as long as they are in different movieclips. Will it cause an error? or will AS3 be kind to me.
View 1 Replies
Feb 3, 2009
I have one MC on stage with instance name "box". That MC duplicates by using this script:
Code:
duplicateMovieClip (box, newname="box2", this.getNextHighestDepth());
box2._x = xPoz;
box2._y = yPoz;
So the new MC is now called "box2".
Inside original MC "box", I have one button. After click on that button, I need to know on which MC I clicked. box, or box2. I tried to use:
Code:
trace (this._name);
But, that get me only instance name of the button.
View 4 Replies
Jan 3, 2011
I'm creating a platform game, and I have those boxes which needs hitTests on all sides - including the bottom.I want my hit areas to have the same instance names. With that I mean, that I want only one instance name for all the bottom hits, one instance name for alle right hits - and so on. If it's possible. 'Cause else there will be so much actionScript code to write.I've been trying to simply make a normal hitTest on for example hitGround, and then place two movieclips with the instance name hitGround, but the hitTest function only works on the last added movieclip with that instance name.I have also been trying to look up some for each in-arrays, but I don't really get the meaning of how to use them.
View 2 Replies
Apr 27, 2011
I'm following a tower defence tutorial and part of the code is set up so I can build towers on the "grass" movie clip. I wanted to add more patches of "grass" and gave them all the same instance name so I can be able to place towers on them, but I have the problem that I can only place towers on the first item I placed and has the instance name of "grass". I can't seem to place towers on the other patches of grass.I removed the instance name of the first patch of grass and it let me build towers on the second patch, but the second patch only.
[Code]...
View 1 Replies
Feb 21, 2010
I have a movie clip and inside that movie clip there is a button. I will be copying this movie clip 40+ times. When you click the button it must seek out the reference name of the movie clip it is nested in. The point of the script on the button is to make all other boxes but its self vanish. The script needs to know what box it is so it can make all boxes but it's self vanish. I know that _name returns the name of the object the code is on but what about the movie clip the object is in maybe _parent._name?
View 5 Replies
Nov 1, 2010
I've got a movieclip in my library called primaryCommMC.I'm loading these 5 times onto the stage and naming them commMC0-4 using the following:[code]Right now they're all obviously loading on top of each other. I want to stack these movieclips on top of each other so the first movieclip will be at y=0 and the following at y=(the height of the proceeding MC + 5 (a little gap)).
View 1 Replies
Feb 4, 2010
It might sound confusing so let me explain the situation. I made a movieClip. And in that movieClip I have a dynamic textfield set. I called this textfield "AmmoCount".I dragged this movieClip onto the stage several times and each time I called on the AmmoCount varible in each movieclip and gave it a different value. I get the following error TypeError: Error #1009: Cannot access a property or method of a null object reference.[code]
When I trace these objects, weapon1.AmmoCount works, but weapon2.AmmoCount shows as empty. Yet they both contain a value in them. Ive used the weapon1 property and weapon2 property countless times and there is no doubt that it works. so why doesnt it work for weapon2. but for weapon1. Below is some code that I called on earlier that shows they work.[code]these worked! but when I called on the AmmoCount text box within them, I get the error. The following image you can find within the weapon1 movieClip
View 1 Replies
Oct 28, 2010
cat 1 and cat2 are the instance names of the movieclips when using the trace command to find out the values of the array this returns both movieclips undefined.Is that correct output window (undefined; undefined)how can trace name of movieclips in the array.[code]
View 5 Replies
Jan 2, 2007
I am going through the tutorial in the Flash MX 2004 Bible, Chap 33 "Creating A Game in Flash" when on page 1000, the author states in a side note that "We don't use the var keyword here because we want the style variables to be scoped to the main timeline of the movie. In this way, we can access the styles from various functions throughout the game."I've noticed what I thought were two ways to declare variables:
1. "someVar:Type = someThing"
2. "var somVar:Type = someThing"
I never knew what the difference was between these two methods.
View 14 Replies
Jun 14, 2006
im looking for how to remove a setInterval. i searched but the answer which was supposed to work dident for me.
[Code]...
View 1 Replies
Jun 13, 2009
Is it possible to iterate through MV copies with the same instance name? It would be very useful for my project.
View 5 Replies
Jun 1, 2004
getting angles, of two movieclips that are on my stage. With instance names: circle1,circle2. I read that I should use the function Math.atan2 to get the angle, in radians, then I convert it to degrees, but it doesn't make sense, the angles aren't correct.. Here I paste the code I use (its AS not PHP don't know how to add the AS tags):
[Code]...
View 2 Replies
Nov 12, 2004
I have an actionscript that controls the movieclips _alpha through instance names. The problem is: I habe a lot of movieClips and I will use the same action in all of them. The same action, just changing the instance name.
View 4 Replies
Oct 2, 2006
Right check this:
/////////////////////////////////////
/////////////////////////////////////
///////////////FUSE//////////////////
/////////////////////////////////////
import com.mosesSupposes.fuse.*;
[code]....
But the problem is the thumbMov movies will obviously have a uniquely generated instance name i cant target directly due to the "for" loop..How can i modify what ive done to target any of the thumbMovs with the FUSE functions?
View 3 Replies
Mar 3, 2008
I am using attachMovie in a for(var i=1; i<50; i++) loop.Everything loads fine, but I am having difficulty referencing the dynamically created instance names.I don't want to reference individually ie movieclip1, movieclip2 etc.but more by movieclip[i].Basically - if movieclip instance 1 is rolled over I want to display image 1, and so on?
View 2 Replies
Nov 28, 2010
i want to use a variable(text) to refrence a movieclips instance name
Code:
function InventoryShow(event:Event):void
{
var SC:URLVariables = new URLVariables(event.target.data);
[Code].....
View 1 Replies
Oct 16, 2009
I'm trying to make an array of movieclips (on stage with instance names);My code:
PHP Code:
var regions:Array=new Array("britain.eastAnglia","britain.eastMidlands","britain.ireland");
[code]......
View 2 Replies
May 28, 2011
I am trying to use a for loop, to place 5 instances of the same movieclip on the stage. In the loop I used .name to give each movieclip a unique instance name. But when I try to reference one of those instance names in an event listener I get an error. Here is an example of what I am trying to do:
Quote:
var xPos:int = 120;
var yPos:int = 60;
for (var i:Number = 1; i<=5; i++) {
[Code].....
This code generates an error saying that the cStar2 property is undefined. In the example above, does the for loop create 5 copies of the movieclip starC_moov, and give them unique instance names cStar1, cStar2, cStar3, cStar4 and cStar5?
View 1 Replies
May 28, 2011
I am trying to use a for loop, to place 5 instances of the same movieclip on the stage. In the loop I used .name to give each movieclip a unique instance name. But when I try to reference one of those instance names in an event listener I get an error. [code]...
View 1 Replies
Dec 1, 2004
Is it possible to hide several movie clips at once by adding their instance names to an array, and then creating some kind of function?
View 1 Replies
Sep 26, 2008
I want to change the movieclips' width whose instance names are in an array. However I can't change this value even for one instance.
Code:
this.holder_mc.onEnterFrame = function() {
_root.edges[1]._width = 24-_root.holder_mc._x;
trace(_root.edges[1]._width);
};
View 2 Replies
Dec 29, 2011
I am an AS3 code developer but this time I need to deal with a FLA that has an instance on timeline with complex nesting of movieclips and textfields (that are named via the instance field in Flash). The problem is that events (I put in the Documentclass) on nested movieclips inside that timeline placed instance are never dispatched.
example code:
// my instance on Stage in all Frames of the timeline
public var thewall:MovieClip;
// event directly on thewall works
[Code].....
View 1 Replies