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)
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...
I found this code to turn strings into a movieClipInstanceName that exists within a known movieclip. Code: // CREATE THE STRING var newString:String = "movieClipInstanceName"; //CHANGE THE ALPHA OF THE MOVIECLIP TO 0 this[newString].alpha = 0;
However, when using this code for a movieclip within a known movieclip... Code: mc1.this[newString].alpha = 0; ...or... Code: this["mc1"].this[newString].alpha = 0; I get this error... 1084: Syntax error: expecting identifier before this.
Code: this["mc1." + newString].alpha = 0; ...throws this error... Error #1010: A term is undefined and has no properties.
I just want to ask if is it possible to call a movieclip using the String Class together with it's instance name to use gotoAndPlay() method. I know how to use the instance name and the method but then what if I want to use a string together with the instance name and the gotoAndPlay.
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.
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;
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?
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?
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 {
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()
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]...
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)
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'); }
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)
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)
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++){
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]...
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;
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.
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:
In as simple an example as I can think of, I have two classes: Dog and Cat. Both are subclasses of Animal, in this stupid example... I know how to create instances of both, however I don't know how to dynamically create them by name from a string. It would be something like...
I thought this would be a simple one, but i am stumped. So I resulted to using this less than optimal solution, just to get it working...
if (lobby.gamemap.selectedItem.label == "Map1") map.AddMap(new Map1) else if (lobby.gamemap.selectedItem.label == "Map2") map.AddMap(new Map2) //Map1 and Map2 are movie clips in my fla library, with linkage Map1 and Map2