ActionScript 2.0 :: Use A String Var To Refer To A Mc Instance Name?

Feb 12, 2009

i am having problems referencing an mc's instance name via a string var. I think the solution would be simple, but i have been trying different things for a while

ActionScript Code:
var hitarea:Array = new Array;
function populatehitareas()

[code].....

View 9 Replies


Similar Posts:


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 :: 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 Instance Names Inside A For Loop?

Jun 3, 2010

I have several movie clips labeled thumb0, thumb1, thumb2, etc.
 
How do I refer to these instance names inside a for loop? I want to do something like:
 
//DISPLAY THE THUMBNAILSfor(var thumbCount:int = 0; thumbCount < loadedThumbs.length; thumbCount++) {     ["thumb" + thumbCount].visible = true;
}

View 8 Replies

Flash :: Refer To Text Field By Class Instance Name?

Jun 17, 2011

I need to populate the text field tField (defined on stage) that resides inside ParentClass (MovieClip with same class name). I want to be able to set tField.text to whatever I want from AnotherClass. How do I do it?

View 2 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 3 :: Refer To An Instance From Inside It's Own Code In Adobe Flash?

May 16, 2010

In Adobe Flash, I have a movie clip that is added to the stage when the keyboard is pressed. I want it to travel across the screen and disappear once it reaches the edge of the stage. At the moment I use this but the image appears and then stops. Here is my code:

addEventListener(Event.ADDED_TO_STAGE,runtime);
var c = 0
function runtime(){

[code]....

View 2 Replies

ActionScript 3.0 :: Refer To Instance / Movie Clips (relative Route

Aug 21, 2009

so i finally decided to jump to as3 from as2! (yes, it took me some time XD) I have a better understanding of as3 after reading tutorials, however i have a problem/doubt: I have 2 movieclips on my main timeline with the name of the instances: OBJ_1 and OBJ_2. both have animations. OBJ_1 has a stop on its 1st frame; OBJ_2 has an action in its last frame:

[Code]...

View 9 Replies

ActionScript 3.0 :: Main Class Path Without Carring Around Instance Refer?

Jan 6, 2007

I spent my holyday in studing new Flash 9, very good, powerfull but I doesn't find anymore my root, in teory is transformed in stage.root but it doesn't work.I want to understand if I make a mistake in my code or in my approach.I make a simple example with a few object containers.In the firsts lines of the constructor of the mail class I create the style class named tf and then the interface class called interf.Here is my class

Code:
package test {
import flash.display.Sprite;
import test.tf;[code]....

how to get the tf1 Object that as to be in stage.root.mytf.tf1 as some documentation say? If you doesn't comment that line you have an error. Obviously you can carry with you the object because is a small object with a few nidification but It seems to me very very bad for performance and code.

View 2 Replies

Actionscript 3 :: Switch / Case To Evaluate The Current Frame - What Instance Should Refer To

Jan 12, 2010

I'm trying to make a menusystem that will jump to specific frames depending on what frame I'm currently on. I have made a switch/case to evaluate the current frame. I have managed to find this code to get the current frame but I need an instance of my entire flash movie it seems? I have tried this (psudo code sort of). var frame = myClip.currentFrame; I then proceed to test frame in the switch/case statement. (All this is an event for a mouse event listener BTW). Now how can I refer to myClip?

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 3 :: Set String To Instance Name

Feb 25, 2010

i'm having some problems with as3

[Code]....

this is my code, i'm trying to set the title value for every child instance of eventChild, as i am new to action script in general, and action script 3 in particular i don't really know what i'm doing wrong here. I'm trying to set the text for ev1.title1, ev2.title2, etc. from values in eventChildren like this : first child, sets ev1.title1, second ev2.title2 and so on.

[Code]....

View 2 Replies

ActionScript 3.0 :: Add A String To Name Of Instance?

Feb 1, 2010

I am trying to capture the name of a target and add the letters "hl" on to the end and then set the visibility of another object with this modified name to true. Here is the code. The trace shows exactly what I want. Now how do I take that and set the visibity to true?

Code:

var highLight:String = evt.currentTarget.name + "hl";
trace(highLight);
highLight.visible = true;

View 6 Replies

ActionScript 3.0 :: Converting A String To An Instance Name?

Jun 8, 2009

Code:
//declare variables and create arrays
var initx=80;
var inity=80;


[Code]......

Alright, what I am trying to do here is get 15 buttons arranged on the stage in a random order. The buttons are all named "butt1" "butt2" etc. First step, getting the numbers 1-15 in a random order in an array (successful). Then I concatenate "butt" before the number so the array contains the button names.

However, when I try to place them I get the following message:

ReferenceError: Error #1056: Cannot create property x on String.
at numbersgame_fla::MainTimeline/frame1()

Flash is interpreting my array values as strings rather than the buttons they are supposed to be, and failing as a result. How can I fix this?

View 2 Replies

ActionScript 3.0 :: Using String Var To Reference Instance Name?

Jul 24, 2009

I've got a set of arrays being dynamically generated with paths to nested movieclips. The paths are coming in as strings, and I can't seem to get them to work as movie clip instance variables.as example, a string would be:

siteMC.b1MC.b1f1MC.rMC
(that path works fine outside of the array)

How do I get that kind of nested path from the string to something flash wont spit out as null?

View 4 Replies

ActionScript 3.0 :: Access MC Instance When We Have Only Its Name As A String?

Jun 8, 2009

I am sending the instance name (i.e. String)of the MovieClip to a function.From that function I need to access that same instance of MovieClip using that name.I have a MovieClip Instance name Planet_mc. And I am sending it to function abc()

abc(Planet_mc.name);
function abc(s:String):void
{

View 6 Replies

ActionScript 3.0 :: Convert A String To An Instance Name?

Sep 19, 2010

I'm slowly climbing the AS3 learning curve, I had a query about converting data stored in an Array:

My flash file contains six movieClips arranged into a grid, each movieClip is named with an instance name, increasing sequentially like so:grid1, grid2, grid3 ... etc

What I'm trying to achieve is to have one of the grid items randomly selected to play a contained animation every 2 seconds.[code]...

View 1 Replies

ActionScript 3.0 :: Flash Instance Name From String?

Mar 16, 2004

temp.MissleArt = team1[h].MissleArt;
temp.MissleArt.visible

i have a object(container) with multiple children and based on the units MissleArt i want the objects Child instance visiblehowever when i do this it assumes that temp.MissleArt is a string even tho temp.Arrow is a child of temp (Missleart is equal to arrow)

View 2 Replies

ActionScript 2.0 :: [CS3] MovieClip Instance Name To String ?

Jul 25, 2008

I would like to pass the name of a movieclip to a string so my attachmovie method can work. what I m doin is :

function createBlocks(slot:MovieClip)
{
...
...[code]...

when I call the above function on a keyframe I call it like : this.createBlocks(block4);

block4 is the id name of a movieclip in the library. the problem is that the attachMovie method needs a string as a parameter! how can I convert that to a string? so afterwards, slot , has inside the name "block4" (with the quotation marks)

View 1 Replies

ActionScript 3.0 :: Convert Instance Name To String?

Jul 7, 2009

i have several button that should navigate to frames in my movie. the button have the same name as the frame's labels i need to convert the buttons' instance names to strings

stop();
import flash.events.MouseEvent;
this.Label1.addEventListener(MouseEvent.MOUSE_DOWN ,gotoLabel);
function gotoLabel(event:MouseEvent):void{
gotoAndStop('label1AsString');
}

View 2 Replies

ActionScript 3.0 :: Convert String To Instance Name?

Oct 9, 2009

I have a Flash poetry project in which I have 49 separate dynamic text boxes on stage. Each has a separate instance name - "cell_1", "cell_2", "cell_3" etc. I use the following code to store instance names in an array -

var j:int;
for (j = 1; j < 50; j++) {
instances.push("cell_"+j)

[code].....

View 5 Replies

ActionScript 3.0 :: Flash - Instance Name From String?

Oct 19, 2010

temp.MissleArt = team1[h].MissleArt;temp.MissleArt.visiblei have a object(container) with multiple children and based on the units MissleArt i want the objects Child instance visiblehowever when i do this it assumes that temp.MissleArt is a string even tho temp.Arrow is a child of temp (Missleart is equal to arrow)

View 5 Replies

ActionScript 3.0 :: Possible To Refrence A TextField's Instance Name Using An String?

Jun 4, 2010

I'd like to know if there is a way to reference a dynamic text box's instance name through the use of a string.I know that this["the string"] works for movieclips, but haven't had much luck with the text field.Here's a simplified snippet of code I have so far - The goal is to replace txtInstance with txtInstanceArray[k]

var txtInstanceArray:Array = ["txtInstance","txtInstance1","etc"];
var colArray:Array = ["hitsum","hitsum1","etc"];
for (var k:int = 0; k < 30; k++){

[code]....

View 3 Replies

ActionScript 3.0 :: Create A New Instance Based On String?

Jun 18, 2009

I need to dynamically add some movieclips to the stage. I have some drop downs on the stage which will control what gets added. The value of each selection is the name of each movieclip. How can i take this and create a new instance of the appropriate movie clip?[code]...

View 19 Replies

Actionscript 3 :: Convert Instance Variable To String?

Feb 2, 2011

Is there a simple way to convert an instance variable to a String?

View 2 Replies

Arrays :: Convert String Into An Object Instance Name?

Jun 16, 2011

I'm trying to turn an string into an instance name.

stage.focus = ["box_"+[i+1]];

this gives me back = box_2;

but I need it to be an object not a string.

In as2 I could use eval. How do I do it in as3?

View 3 Replies

Flex :: Air - Find Next Instance Of String In TextArea

Dec 4, 2011

I have a TextArea, a TextInput and a button. When text is entered into the TextInput the TextArea is searched for the matching string, however it only highlights the first found instance of the string. How can I do a 'find next' type of operation.

protected function searchBtn_clickHandler():void
{
text = mainTextField.text;

[Code].....

View 1 Replies

ActionScript 3.0 :: Return Class Instance As String

Feb 1, 2009

Is there anyway to include a function or overrite something in a class that'll output a custom string when the object is called as a string?

So for example if I created a class named "myClass" and I instantiated it:

Code:
var myObject : myClass = new myClass();

When I:

Code:
TextControl.text = "blah blah, " + myObject;
myObject is getting casted as a string. Normally it would output:
"blah blah, [object myClass]"

Is there a built-in function that recast the object as string? Is there anyway for me to change that string output? I know I can just make a public toString() method in the class or something, but just wondering if there was something better.

View 3 Replies

ActionScript 2.0 :: Convert Text String To Instance Name

Aug 10, 2009

so here's my problem. I've got an array (wall_inst[]) containing instance names of 3 objects (for now), however they are stored as text strings. I've got a moving 'ball' object too. The problem is, the values contained in the array are text strings and will not behave as instance names, when I try to get object properties off them etc. Eg, I can do this:

[Code]...

View 6 Replies

ActionScript 3.0 :: Converting String To MovieClip Instance

Nov 4, 2009

I have a slider that the values are passed to a concatenated string.
Example:
trace ("object" + event.value + "_mc");
this gives me "object1_mc"

Now, what I would like to do is use that string to set the alpha to 1
Example:
object1_mc.alpha =1;
It will not work because it is a string and not a movieclip...

View 1 Replies







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