ActionScript 2.0 :: Using Variable Value To Refer To A Movieclip On Stage

Aug 8, 2006

asically I have a variable in which I store various numbers depending on other aspects of the flash movie and I have a bunch of movieclips that are on the stage all named by number. I want to use the variable value to access and run methods etc of these movieclips.

e.g.
var myVar = "10";
myVar.myFunction();

where the item on stage called '10' will react. I realise this is a confusion between a string and an object/movieclip reference but i'm almost certain ive done this before and ive got a feeling it had something to do with [] brackets on the end of something...

View 5 Replies


Similar Posts:


ActionScript 3.0 :: Refer To Movieclip On Stage Through .as File?

Jun 25, 2009

I have a movieclip on stage, but I want to move it or animate it with the use of an .as file, how do I refer to a movieclip on stage through a .as file?

Is this even possible or do I have to pass the actual movieclip as a parameter to a function of the class?

To make things more clear, here is my code:

Code on main timeline:

Code:
var myBox:Box = new Box();
myBox.x = 80;
myBox.y = 160;

[Code].....

View 2 Replies

ActionScript 3.0 :: Refer Back To The Movieclip In Main Stage From Other Movie Clip?

Jun 25, 2009

I had attach a few movieclip in the main stage by using addChild() method. If I going to refer back to them inside other movieclip, How can i do so..

For example,
//attaching at the main stage
var earth1:MovieClip = new earth()
addChild(earth1);

[Code].....

How can I refer back this Movieclip from other movieclip's timeline?

View 1 Replies

ActionScript 2.0 :: Refer To The Button Inside The Movieclip After Attach It Onto The Stage Using AttachMovie?

Nov 17, 2003

I had a movieclip which contained a button in it exported as "mc". Then I attach this movie clip onto the stage using: _root.attachMovie("mc", "link1", 1); But i couldn't find it with AS. I mean, how can i refer to the button inside the movieclip after I attach it onto the stage using attachMovie?

View 2 Replies

ActionScript 3.0 :: Can't Access Variable On Stage From Within Movieclip Thats Placed On Stage

Aug 18, 2009

I can't access a variable on a the stage from within a movieclip thats placed on the stage.

View 4 Replies

ActionScript 3.0 :: Refer To Variable Using Strings And Others?

Jun 10, 2009

How do I refer to a variable using strings and other variables? What I mean is, for example, you can refer to an instance of a MovieClip on the root level with instance name "mc1" by doing this[code]...

View 5 Replies

ActionScript 3.0 :: Refer To The Stage From A Class?

Jun 7, 2010

I have a class that places objects on stage with addChild(obj) it allowes me to position objects using pixels( say obj.x = 10; obj.y= 50; ) just fine but if
I try this:  obj.x = stage.stageWidth / 2;  I get a message that I Cannot access a property or method of a null object reference

View 4 Replies

Actionscript 3 :: Refer Objects On The Stage?

Oct 1, 2011

I have an object created visually. How should I refer to it from classes of other objects? MovieClip(this.root).someObj or stage.someObj or MovieClip(this.root).stage.someObj? And moreover, if I want to see which frame is current on the main timeline, why I cannot just check stage.currentFrame? Why there is no such property of the stage, currentFrame? It has timeline, right?

View 1 Replies

ActionScript 3.0 :: Refer To An Instance On The Stage If

Feb 9, 2009

How can I refer to an instance on the stage if:

- I added it to the stage using the GUI
- I wrote its implementation in an external AS file

I can't assign it a instance name otherwise I get this error: Code: ReferenceError: Error #1056: Cannot create property myInstance on MyClassName.

View 4 Replies

ActionScript 2.0 :: Refer Certain Variable And Instance Names Within Loops?

Aug 18, 2010

Trying to set up a world of warcraft like hotkey setup for an RPG i'm making for a school project, where you drag spells from the spellbook onto the hotkeys. Understand all the concepts, however, instead of doing a ridiculous amount of if statements, I want to loop the functions. Unfortunately, I don't know how to refer to certain variable and instance names within loops. I shall show you what I have:

ActionScript Code:
for(var i; i<2; i++){
spellbook_inst["spell_"+i+"_inst"].onPress = function(){
this.startDrag();
_root.hold_spell_position_inst._x = this._x;
_root.hold_spell_position_inst._y = this._y;
}}

The "spells" (i.e., icons you drag from the spellbook) are all named spell_(number)_inst, and are movieclips within the spellbook_inst movieclip. I want the drag function to be available for all spells. At the moment, I don't get any syntax errors, but nothing happens, so I presume I have referred to it incorrectly.

View 2 Replies

ActionScript 2.0 :: Refer To A Variable In A Class File Separate From The Other One?

Feb 24, 2010

Is it possible to refer to a variable in a class file separate from the one you are working in? Say Class1.as had a variable named "exampleVar", and in Class2.as you wanted to put something like "exampleVar++;". Is this possible and if so how would it be achieved?

View 1 Replies

ActionScript 2.0 :: Refer To All Movie Clips On Stage At Once?

Oct 25, 2011

Way of referring to all the movie clips on the stage at once, and of putting that information into a variable for use with hit detection.

View 3 Replies

ActionScript 2.0 :: Put The Character Variable And Info In The First Keyframe And Refer To These Via _root In Any Frame

Dec 29, 2010

I am trying to make a game to learn actionscript. my game is going to have multiple keyframes, ie one for dungeon, 1 for a large map yadda yadda yadda. Things like the character i would like to be available to all keyframes. i am assuming i put the character variable and info in the first keyframe and refer to these via _root in any frame. However if i want to make a dungeon and use the dungeon scene variables i would use this.

right now since i am only on the making a dungeon part i can refer to anything using this or _root. Case: my dungeon scene consists of walls and paths. right now i can do something like if(_root["path" + yPos + xPos]) _root["path" + yPos + xPos].removeMovieClip;

i can also call the same code using this instead of _root and it works. when i add a main new main frame and move the dungeon scene from frame 1 to frame 10, will i still be able to inter use _root and this and have the same effect, or once i move the dungeon scene from frame 1 to frame 10 i will no longer be able to use _root. also i only have 1 layer.

View 3 Replies

ActionScript 3.0 :: Refer The Main Time Line Or Stage From Inside The Class?

Apr 13, 2009

how to refer the main time line or stage from inside the class.

class sample{
function sample(){
trace(root); // its displaying as null
}
}

in actionscript 2 we use _root for this... in actionscript3 if we use root...why its not working inside the class....?

View 1 Replies

As3 :: Professional - Adobe Flash - Refer A Button That In Main Stage While In An Another Clip's Substage

Jan 25, 2010

I just wonder that how can i write this code that means if the "specific" button is clicked(i mean if the homebutton is clicked=true) like this.. and how can i refer a button that in main stage while in an another clip's substage..

View 1 Replies

ActionScript 3.0 :: Adobe Flash Cs4 - Refer A Button That In Main Stage While In An Another Clip's Substage?

Jan 25, 2010

I just wonder that how can i write this code that means if the "specific" button is clicked(i mean if the homebutton is clicked=true) like this..and how can i refer a button that in main stage while in an another clip's substage..

View 3 Replies

ActionScript 3.0 :: Refer To Movieclip Within Array

Mar 16, 2010

I have an array that movieclips are added into depending on the users actions. When they are added to the the array, they are also added to the display list of another movieclip on the stage.I'm trying to refer to them later so I can remove them from this movieclip's display list, but I can't work out the wording.[code]

View 2 Replies

ActionScript 1/2 :: Refer To A Movieclip Within The Root?

Jul 15, 2010

I am using the load movie from my main file (main.swf) as:
 
mc_zoom.loadMovie("detail.swf");
  
I then have a loader as a movieclip with the detail.swf
 
when the movie (detail.swf) is loaded the preloader I am trying to make/set the play to go:
 
_root.gotoAndStop(2);
 
But this does not work - it works locally but when used with the main file (main.swf)

View 5 Replies

ActionScript 2.0 :: Can't Refer To An Instance Of A Movieclip

Feb 19, 2009

the second bit of code "mc_inst1.onRollOver..." works, but the first bit of code, which tries to loop through all movie clip instances, will not work.I think this is because myReference is a String. But can anyone suggest how else I should construct my reference to the instance name?

Code:
for (var a:Number = 1; a<myCount; a++) {
myReference="mc_inst"+a;
var myClip:MovieClip = myReference;

[code]....

View 5 Replies

ActionScript 3.0 :: Refer To MovieClip At Specific Position

Apr 1, 2010

How can I refer to an MC that is at a specific position (using frame label) to start playing based on a current event?

View 6 Replies

ActionScript 3.0 :: Refer A Class From A Nested Movieclip?

Jun 19, 2011

I have the class avanzada.as:

package
{
import flash.display.MovieClip;

[code]........

View 2 Replies

ActionScript 2.0 :: Refer To The Main Timeline Within A Movieclip?

Dec 4, 2006

Is there a way to refer to an object on the main timeline from inside another movie clipThe "_root." function does not work and I am still unfamiliar with the "_parent." functions purpose.

View 2 Replies

ActionScript 3.0 :: Refer A Class From A Nested Movieclip

Jun 15, 2011

I have this class:

package {
import flash.display.MovieClip;
import flash.filters.BitmapFilter;

[Code]....

Appears this error message:

"1137: Incorrect number of arguments. Expected no more than 0."

I try with:

new MovieClip(this.root).cambiaBlur(gift);

but also fails.

View 1 Replies

ActionScript 3.0 :: Refer To XML Object In Main Timeline From Within A Movieclip?

Feb 1, 2010

I would like to know how to access a XMLList object in main timeline from movieclips.Can XML be accessed through 2nd level(nested movieclips)? In frame 1 of main timeline, the XML file has been loaded.

var xmlData:XML = new XML();
var data:XMLList;
xmlData.ignoreWhite = true;

[code].....

View 0 Replies

ActionScript 3.0 :: Call Function, Pass Value, Access Variable In Movieclip Class From Main Stage?

Nov 20, 2008

I have a movieClip named MC, and it's enabled with action script, with the class name MC_Rectangle and a Stage.I override the MC_Rectangle class file in a mc_rectangle.as external file.here is the code:

package{
import flash.display.*;
import flash.events.*;[ code].....

I have new a object in the main stage var

mc_rect:MC_Rectangle = new MC_Rectangle()

in main stage:

1. how can i access the variable "sequence" in "mc_rect"

2. how can i pass parametre from main stage to mc_rect via function setSequence(data:int)?

3. how can i call the function in addSequence() in mc_rect.

in asp.net, i usually use mc_rect.sequenct,mc_rect.setSequence(data), mc_rect.addSequence() to achieve my goals......btw, can function in mc_rect return out result to main stage?

View 1 Replies

ActionScript 3.0 :: Keyword "this" - Refer To The Current Instance Variable Being Created When Its The Only One Being Created?

Dec 11, 2009

When an instance variable is constructed by a constructor method, why do you need to refer to the current instance variable being created when its the only one being created? I understand assigning an expression to it but why name it "this." when it is the only object that the constructor is building? Does it have some hing to do with being able to naming that object in the Local Variable? In other words am I creating a generic object that will be named in another class?

View 7 Replies

ActionScript 2.0 :: Flash8 Variable Set-up - 'if' Statement To Run From Variable When Playhead Encounters MovieClip

Aug 21, 2009

I want to declare a variable on the main timeline that can be called from anywhere in my movie. So, _global var should be the right approach. I want to declare a movie clip 'MC1' "open", or "closed" so that when it is revisited, my flash file knows the user has been there before and performs a different task from the one it does when 'MC1' was first encountered. So, i need a 'if' statement to run from the variable, when the playhead encounters the movieClip.

[Code]..

View 2 Replies

ActionScript 3.0 :: Change String Variable To A MovieClip Variable?

Oct 10, 2008

I have been banging my head against a brick wall regarding the following problem which must be very simple to fix, just can't see the answer.I have a class assigned to a movieclip called canvas. The class is called drawClass. I have called the instance of canvas on the stage 'drawingCanvas'.When I trace "drawingCanvas" I get object drawClass] which is fine. Tracing drawingCanvas.name gets me the instance name 'drawingCanvas'.This is a String variable.Basically what I am trying to do is pass the MovieClip name to another class. In my example the class 'toolBar', which can then interact with the MovieClip.

The problem is passing 'drawingCanvas.name' results in a String, so I get an error saying :TypeError: Error #1034: Type Coercion failed: cannot convert "canvasArea" to flash.display.MovieClip.I can't for love or money find a way to convert a String variable to a MovieClip variable! I have the name of the MovieClip, I just need to tell the toolbar class. But I can't find a way of doing this as the instance on stage is an object of drawingClass, not a MovieClip (unless MovieClips with attached classes are not treated as standard MovieClips?).

View 9 Replies

ActionScript 3.0 :: Make A Movieclip Move Horizontally From The Start Of The Stage To 3/4 Of The Stage?

Jul 11, 2011

How do you make a movieclip move horizontally from the start of the stage to 3/4 of the stage. Stage size is 700 px by 600 px i want just one row in the middle of the stage. i want that movieclip to disappear right after it reach the end of the 3/4 mark.

View 1 Replies

ActionScript 2.0 :: Position A Movieclip In The Middle Of The Stage Even If The Stage Or Window Resize?

Feb 27, 2006

i saw a thread while ago .. that always position a movieclip in the middle of the stage even if the stage or window resize any1 can point me to it

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved