ActionScript 2.0 :: Remove A MovieClip W/reference As Variable
Nov 23, 2011How would I remove this attachMovie? [code] I have tried these codes with no success [code]I am using flash 10.2, in flash professional 5.5.
View 1 RepliesHow would I remove this attachMovie? [code] I have tried these codes with no success [code]I am using flash 10.2, in flash professional 5.5.
View 1 RepliesI have a movieclip (childMc) that is the child of another movieclip (parentMc) on the stage.My code creates a reference (refMc) to the child movieclip on the stage, and then deletes the previous parent movieclip (parentMc) through a call to function deleteChild. The problem is that the delete is deleting the reference also. How do I break the reference so that the reference (refMc) is kept on the stage? Here is my code:
Stage Code:
var refMc:MovieClip;
var parentMc:MovieClip=this.addChild(new parentSymbol()); // parentSymbol has childMc
[code].....
this array prototype manage to remove Strings and Integers but not movieclip references.
PHP Code:
Array.prototype.removeArrayItem[code].....
The scene is a number of movie clips, all already added to the stage (i.e. not dynamically) and when one is clicked, I need to call a property of that clip. [code]...
View 3 RepliesHow do you use a variable value as a reference to aMovieClip?I'd like to do this:
A2.visible = false;
myVar = A2;
myVar.visible = true;
[code]......
i'm referencing variable names and object names dynamically such as:[code]i have 5 balls (insert joke here) which get all the same functions etc so i wanted a way to avoid making 5x functions to handle each one of the balls. Now one function can handle all 5, etc.what i can't figure out is how to use this same set up to reference a variable or object name inside another movieclip. if i have another movieclip named "myParent" for example, i thought i could refer to it with:[code]but this doesn't work.
View 5 RepliesI need to remove the word Button from the reference to reference the actual item that will be tinted.
[Code]...
How do I reference the variable pointed to by the variable text but pointed to by more than one function?Say I have:
engine_level = 5;
tank_level = 3;
v_name = 'engine';
[code].....
How do I reference the variable pointed to by the variable text?
Say I have:
engine_level = 5;
v_name = 'engine';
pb_name = v_name + '_p_button'; // so pb_name = 'engine_p_button';
level = v_name + '_level'; // so level = 'engine_level';
[Code]......
I'm making a game for children where they have to pay money by dragging it on a square. It al works wel only when i pick the first coin of one euro without going over the coin of 2 euro and then pick up a 2 euro coin the one euro disappears. after then it all works fine.i cant remove my duplicate euro's from the stage when i clic on pay here is my code for the euro's the euro's are in a emty movieclip
[code]...
I am creating a generic button that will remove items created dynamically in a movie clip container from memory (not just from the display list).
To track which item the user has selected for deletion, I have a click function that stores the name of the clicked object in a variable called objName. I then store a reference to the object itself in another variable called targetObj. I can then easily remove the object from the stage like this[code]...
I am trying to figure out the logic to remove a nullreference error that is popping up when an item is not dragged. Inthe code, I have a stopDrag setup for the stage. It works asexpected unless the user clicks the item but doesn't drag it. Itcauses the variable I have set to bring the name of the dropTargetto be a null which crashes the system. I have tried to declare thevariable with a default value but it still doesn't work.It is the targetStop code that it is crashing on. Is thereanyway to default a value so I can do an if / then statement todetermine if there is a value? I've tried: if (targetStop == null)but that doesn't seem to work.
View 8 RepliesI'm not even sure if the title reflects what I want to do. Here's backstory. I have a movieclip with 5 'holder' movieclips in them. They are my containers for dynamically added movieclips. The parent containers has an instance name of pyramid, the holder instance names are labeled after the 6 food groups, i.e., 'grainholder', 'fruitholder', 'vegetableholder', etc etc...The holders are within the pyramid container, instance names as above, and the pyramid container is added to the display list. I have a addFoodToPyramid() function which adds 'foodMC' mc's to their respective holders. So an [object Apple] will be dynamically added by way of pyramid.fruitholder.addChild(Apple). The function also adds a listener. Heres the call and the function:The call (I will use grains as example) is this:
addFoodToPyramid(grainArray, grainHolder, grainCounter);
And the function is:
function addFoodToPyramid(thisArray:Array, thisHolder:MovieClip, thisCounter:Number):void
[code].....
I want to be able to reference the text of a text box within an MCThe MC is called "box1", the text field is called "field1"...I have many MCs (all with field1 in them)... box1, box2, box3 etc etcObviously I can set the text to being something by saying...box1.field1.text = "set_this_text"However, I'm using a variable to come up with the "box1" bit. (Using an array and a loop to figure out which box I want to update based on where the user clicked). So, let's say I have a variable... and I want to say..boxClickedon = box1 //will be defined by userSo I don't know in advance about box1... I can only access it through "boxClickedin" variable, but
boxClickedin.field1.text = "set_this_text"
or
[boxClickedin].field1.text = "set_this_text"
[code]....
Is there a way to reference a function via a variable? In other words, instead of saying something like:
var theVar = someString + 'function';
if (theVar == 'functionName') functionName ();
to access it directly:
(someString + 'function') ();
using some kind of bracket notation?
I am trying to make a reference to a movieclip instance that is in another movieclip.
Here's the deal: I have a main timeline for different pages of a website...then within that I make all of the art on each page into a movieclip so I can do animations every time that main timeline frame is called to, yet still keep my main timeline clean.
Within one page's movieclip I have a few buttons that I want to use to go to other pages by referencing them on the main timeline.I have been using this: (home_about is the about us button on my home page, and frame 31 is on the main timeline).
home_about.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_6);
function fl_ClickToGoToAndPlayFromFrame_6(event:MouseEvent) :void
{[code].............
Since this home_about is within another movieclip,I get the access of undefined property error. Do I need to change the code I've pasted above or add in variable definitions to fix this?
I have a page that I'm working on that works great except I keep getting an "Output" message stating: TypeError: Error #1009: Cannot access a property or method of a null object reference. at StillFrameFoto_fla::MainTimeline/portfolioOut() I'm pretty sure I just need to get rid of my button instance, but I don't know how. I have my buttons on frame 1 and I want them completely gone when it moves to frame 2. Here is the code for one of my buttons on the first frame:
[Code]....
Using AS2. I have a variable defined:
activenav = "services";
I then want to reference the variable in a MC string. I've tried many variations of this:
_root.my[activenav]Clip.gotoAndPlay("Out");
Essentially, I want Flash to see this as:
_root.myservicesClip.gotoAndPlay("Out");
Getting syntax error.
i have a function that read a variable from a text file, yet i can only read the variable from within the function. How could i create a global variable or such that i can then read from outside of the function.
Code:
var Make:LoadVars = new LoadVars();
Make.onLoad = function() {
VARIABLE = Make.textVariable;
[Code].....
I am trying to write an attachMovie statement with a variable feeding the ID parameter.[code]...
View 1 RepliesI want to loop through an array and use the array value to reference a variable. The Setup:(For illustration only. Not actual script)
[Code]...
Can you have "ByRef" arguments in AS3 functions?
Primitive types in AS3 pass by value instead of reference. Is there a way to override that behavior and pass by reference for certain variables? [code]...
Is it possible to reference an object using a variable value?
For example, I have a function that is supposed to hide an image and add that image to an inventory list when the item is clicked.
All the image info is stored in an object (name, imgSource, visible, x, y);
I was thinking I could do something like this:
<fx:Script>
<![CDATA[
public var item:Object = new Object();
[Code].....
I want "item" to stand for knife so that I could change knife.visible, knife.xPos, ect.
Code:
public function Text1Down(e: MouseEvent): void{
var textArea:Label=Label(e.currentTarget.id);
.......
}
I get this error:
Code:
TypeError: Error #1034: Type Coercion failed: cannot convert "text1Area" to mx.controls.Label.
I know that e.currentTarget.id is of type Label. All I want is to make a reference variable so I don't have to keep typing long names.
I'm writing a function which can take the names of different variables and use them to do some calculations. Long story short, I want to be able to call the function like this:
It probably seems like a really roundabout way to pass the variable through its name rather than just passing the variable itself. This is related to me using XML to get the variable names, so they come in as strings. Just bear with me here.
Inside the function, I want to be able to do something like this:
which should then trace the variable's value. Unfortunately, I just get an 'undefined'. How do I use 'this[]' to get the value of the variable from a string corresponding to the variable's name?
I'm not entirely sure that I've even asked the question correctly in the title but hopefully) this description will make it a little more clear.
Code:
private var mySpriteA:Sprite;
private var mySpriteB:Sprite;
[code]......
function foo(bar:Number){
bar = 5;
}
simple example. How do I pass bar by reference to change it's value in the function.
well at least in C++ it's called passing a variable by reference.
Is there, uh, a way to use the value of a string to reference a variable name?
I'm trying to dynamically assign XML node names and attributes using a string value, I tried something like this:
Code:
var sItem:String = "book"; // to be dynamically assigned
for (var i:uint; i < _xml.book.length(); i++) {
aList.push(_xml.(this[sItem])[i].@title);
[Code]....
If I wanted to change the 'x' of a object, and a variable contained a the object's name, how would I change the 'x' by using the variable.Without variable:
Code:
myObject.x = 123;
With variable maybe?:[code]....
I'm writing a function which can take the names of different variables and use them to do some calculations. Long story short, I want to be able to call the function like this:
function caseConditionEvaluator( nameOfVariable:String )
It probably seems like a really roundabout way to pass the variable through its name rather than just passing the variable itself. This is related to me using XML to get the variable names, so they come in as strings. Just bear with me here.
Inside the function, I want to be able to do something like this:
trace( this[nameOfVariable] )
which should then trace the variable's value. Unfortunately, I just get an 'undefined'. How do I use 'this[]' to get the value of the variable from a string corresponding to the variable's name?