ActionScript 3.0 :: AddChild With Variable Name And Access It Afterwards
Mar 29, 2009
I want to loop and put on several movieclips which are named Node1 to Node15. How do i add them and access them afterwards? Tried to give it a name and access it afterwards, but had no luck.
Code:
i++;
var newnode:Node[i] = new Node[i]();
newnode.name=i;
addChildAt(newnode,i);
newnode.1.x=10;
newnode.2.x=40;
....
newnode.15.x=440;
I still have lots of troubles with the syntax.
View 7 Replies
Similar Posts:
Aug 27, 2010
however, with attachMovie you had both "id" and "new id", the id through which the object can be accessed via actionscript. now i can do
Code:
something.addChild(new libraryId());
but how am i supposed to access the new movieclip afterwards? how can i define it's name?
View 9 Replies
Jan 24, 2009
I am trying to use addChild on a current project I am working on, the only problem is that I have to add movieclips to the stage based on an array of movieclips given to me and a number (index).
At this point I am trying it like so:
Code:
var array:Array = new Array('Mc1', 'Mc2', 'MC3'); // etc.
var num:Number = 1;
addChild(array[num]);
[Code].....
View 2 Replies
Nov 30, 2009
Here's my (simplified) code:
Code:
var doorType:String = "DT0";
var openType:String = "OT0";
var imagePositioner:Sprite = new Sprite(); //Places a Sprite that will "contain"
[Code]....
openType is defined on a previous screen, it will be equal to OT1 or OT2. I have two sets of images (movie clips) that each have a prefix of "ot1_" or "ot2_" (in their class name). Other than those prefixes the two sets of image names are the same. I think I could cut the amount of code in half if I could use a variable when I use addChild.
I am not very knowledgeable of AS3 and everything I've tried has failed. My theory is that addChild() needs to contain a movieclip, so putting a variable name in addChild() doesn't work.
View 6 Replies
Mar 16, 2010
First off I want to say that the resources on this site have been excellent
how to reference a variable when adding a new Movieclip?
Currently I am using this method:
Code:
var myVariable:String = "one"
if(myVariable == "one"){
var myMovieClip = this.addChild(new one())
[Cde]....
View 2 Replies
Apr 10, 2012
I want to addChild to stage dynamically using a variable. In AS2, i would have done it using eval().
In the attached page1.as file, I want to be able to use the for() loop instead of the commented out code.
View 5 Replies
May 24, 2011
I have this code:
[Code]..
In which I am trying to create a variable to reference another class I have already created, but when I try to use the addChild method, i get an error that says it is an undefined property. Looking through other posts, I saw that maybe adding "stage." in front of addChild(blueTarget).
View 0 Replies
Oct 20, 2010
It's too complicate to explain but I'll give you an example
I have an AS3 ResultEvent Object and this object has several propeties which can be accessed by this like:event.result.name or event.result.age and, I have this String variable: eventProperty:String that contains "name" or "age" How do I access to event.result. with the variable?
View 2 Replies
Nov 24, 2009
I am working on a project where we are making a "wizard" where you answer a series of questions and in the end you are presented with a "parts list" based on your answers.There is also logic which decides which questions you are asked based on how you have answered certain questions so far. The outcome is a list of door control hardware (locks, mounting plates, handles etc. etc.). show a "live image" of the parts list as it builds. For example one of the questions is this: Door Type?
A) Aluminum
B) All Glass
C) Wood
Depending on which you choose I need to show an image of an aluminum, glass or wooden door.Then if the next question is about lock types then your new lock shows up and so on and so forth until you reach the end.The questions all relate to their own variable which are each defined at the beginning of the movie like this:
Code:
var doorType:String = "DT0";
The questions use radio buttons and each question (re)defines it's variable like this
Code:
DT1.addEventListener(MouseEvent.CLICK, doorTypeHandler);[code]....
Now the tricky part (for me at least) is figuring how in the world to use this in conjunction with the questions (more accurately, the variables they define) to produce this live image.Another thing to add complication to this whole mess is that there are basically two entire sets of images. Single doors or Double doors, they both have (nearly) all the same hardware but they are two different sets of images. They are differentiated by the ot1 or ot2 in front of the class name. The variable openType defines OT1 or OT2 in a previous question. I would like to be able to use the variable openType in the call for the image
Code:
//This is how I tested it
currImage = new ot2_wood_exit();
//I would like to use openType instead of hard coding ot1 or ot2
currImage = new openType_wood_exit(); //I KNOW this is wrong, but I don't know what is right!So that is my basic dilemma. I need to show or hide specific images based on the answers to previously answered questions AND questions currently being answered (live update).
View 3 Replies
Aug 17, 2009
How can I access the member variable of an object by using a variable in the name.Example:
Entries Object has properties 1, 2, 3, 4, 5.
Normally I would access them by
var i : int = Entries.1;
[code].....
View 1 Replies
Jun 15, 2011
I'm trying to have a class file which can add objects to the stage via addChild; however, when I call addChild from within the class file, I get the error "1180: Call to a possibly undefined method addChild." I've tried importing flash.display.* and that doesn't fix the problem. Does the class file have to extend Sprite or MovieClip to be able to add objects to the stage?
View 8 Replies
Jan 16, 2012
I have downloaded Box2d ([URL]) and created a project that looks like this: [URL]. catalyst is the green cube and it has the base class "shapes.box", it is inside "world" which has the base class "wck.World". What i want to do is to add another "catalyst" from the library inside "world" when i click on add_btn. I tried to accomplish this by this code:
[Code]...
Symbol 'buttons', Layer 'Actions', Frame 1, Line 41061: Call to a possibly undefined method addChild through a reference with static type Class.
View 9 Replies
Jan 20, 2011
I have the followings:
_p:Player (which is a MC)
a1:Animation1 (which is a MC)
_p.addChild(a1); //doesn't display anything
_p.stage.addChild(a1); //displays a1
Why won't the MC display a child without using his stage?
View 1 Replies
Aug 11, 2009
I'm trying to resolve an issue that reared it's ugly head yesterday.Frame one of main timeline I have the following code:
Code:
import flash.display.MovieClip;
import flash.events.MouseEvent;
[code]....
The newMC doesn't show up.If I add 'parent.' in front of the addChild then it appears.mc_LibItem has a base class of "flash.display.MovieClip" and is exporting for ActionScript and on frame one.For grins I created a new .fla and began messing around with the same addChild idea and it worked.
View 14 Replies
Mar 30, 2009
This is something I'm experimenting with, but haven't seemed to figure out... I have several MovieClips, basically the same, only different colors. As each one plays, I'd like it to "overlap" whichever one is already there. Right now I have each button linked to a gotoAndPlay function, but I don't think that will ever get me what I want. You can see how I have it now here: [URL]
Instead of having the content MovieClip go back to all white when a button is clicked, I'd like the preivious one to remain, and get "covered up" by the new one. You continue to see the old color, and the new color overlaps it. I have a feeling I need to use a variable and then addChild, with a removeChild for the old MovieClip after the new MovieClip has loaded, but I'm not getting any good results yet.
View 1 Replies
Oct 30, 2005
somewhat understood the basics of adding and removing children, however, I am facing another problem. After using the removeChild Function, I can't seem to add another child.For example:
ActionScript Code:
var attachedMC = new (getDefinitionByName("Content1") as Class)()
Page.addChild(attachedMC);
[code].....
View 3 Replies
Jul 29, 2009
I have a main "shell" swf which, by clicking several buttons, will load/unload various external swfs into a Placeholder_mc which resides on the main timeline in Shell.swf In the documentation and tutorials I've seen a couple different methods, and I'm not sure I quite understand the difference, or at least the reason you would use one over the other...In the 1st method, you can just add the Loader object using the addChild() method:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
Placeholder_mc.addChild(myLoader);
This will apparently add myLoader to the display list once it has completely loaded.The 2nd method, you supposedly can add the Loader.content; however, it appears you can only do this once the content has completed loading, so you need to incorporate an event handler with the contentLoaderInfo object:
Code:
var myLoader:Loader = new Loader();
var myURLRequest:URLRequest = new URLRequest("ExternalFileA.swf");
myLoader.load(myURLRequest);
[code]....
What are the pros/cons of adding the entire Loader object, as opposed to the Loader.content and vice versa?
View 7 Replies
Jul 18, 2009
i'd like to access a variable in an associated class from my Document class [code]in my document class im trying to see if the class has changed the variable... if it has changed i'd like to obviously do something.if this isn't possible what's the simplest way to check a variable in another class?
View 3 Replies
Feb 3, 2010
I have a button inside a MovieClip (instance name: bt_fechar) and I want to refer to it from the main timeline (that's where I want to keep most of the code). It returns the following output error message: "Error #1065: Variable bt_fechar is not defined"
Heres the code:
function retirarCiclo(event:MouseEvent):void
{
[code].....
View 1 Replies
Dec 8, 2009
ActionScript Code:
package {
import flash.display.Sprite;
[code]......
View 7 Replies
Aug 24, 2009
I have an SWF file that loads another SWF file dynamically.
I've managed to make the parent SWF receive a variable from the php page that loads it, via javascript, it works well [code]...
View 1 Replies
Mar 2, 2010
I have an xml parser that i tried to code into an external class/package.I have no experience with packages so its been difficult but i got most of the way there.The code works, the problem is that i dont know how to access the output variable from the package in my fla file.How can i use the variable allText in my fla?
package
Code:
package {
import flash.events.*;
import flash.display.Sprite;
import flash.net.URLRequest;
[code]...
View 4 Replies
Apr 11, 2010
How to access a local variable from another class? I have this powerup class that changes the speed value of the enemy in enemy class(it's a game). For instance, if player hits the powerup it changes the local variable 'speed's value inside enemy class.
View 3 Replies
Sep 14, 2010
On the first frame I have a string variable called "nextSection". When the user clicks on a menu item on the site then "nextSection" is populated with the name of that section. Later on in the fla I have a movieclip containing various sections for the site. The swf compiles without any problems.
I'm now attempting to make the file smaller and easier to update. Rather than have 8 different movieclips that load images, I thought I would just have the one. I changed the following lines in my fla
PHP Code:
// nested within 2 movie clips (sections.aboutUs)loadImage("aboutUs/mainImage.jpg");//nested within 2 movie clips (sections.outdoorAdvertising)loadImage("outdoorAdvertising/mainImage.jpg");// there are 8 of these in total.
[code]...
I'm now getting the error "1120: access of undefined property nextSection". The variable does not contain anything when the file compiles. Only when the user clicks on a menu item does the variable get filled (ie: if user clicks on the OutDoor Advertising button, the variable contains the string "outdoorAdvertising" which is also a folder in the site directory). I tried to populate it with the name of one of the sections on the first frame ( ie: nextSection:String="aboutUs"; ) just to see if it worked but still got the error.
View 8 Replies
Jan 17, 2009
i have variable a=0 and i want a movieclip that runs to change it to 2, what do i write in the movieclip code ? i tried parent.a=2 but it's error.
View 4 Replies
Apr 17, 2010
I have a MovieClip who's added on stage by code.I would like to access to rond2(which are an instance of rond on frame 10) but one error appeared like you can see.This the code that i've maked on first frame on the scene:
var monCarre:MovieClip = new mv_carres();monCarre.addEventListener(Event.ADDED_TO_STAGE, leDire);
addChild(monCarre);monCarre.x=275;monCarre.y=200;//monCarre.rond2.alpha=0; <<<<L'éxécution de cette ligne provoque une erreur
function leDire(e:Event):void{ trace("monCarre est ajouté");}
View 3 Replies
Nov 27, 2011
Normally, I declare a variable at the very top of all my code like, var myObj: Myobj = new Myobj();...
but for some reason the the new variable being declared is necessary to present within the function, like displaying same objects in the library using for loop.
I notice that variable declare within a function will not be accessible outside the function or from another event handler or from another function....
I have seen code that make it possible my declaring a new variable?
View 4 Replies
Dec 9, 2010
I have a class with a var textFieldObjets:Textfield in my class environment. What I'd like to do, is access this var from another class and change the text. I tried things like
environment.textFieldObjets.text = ".....";
Got error 1119, Access of a possible undefined property textFieldObjets trough a reference with static type Class.
I can't even access my environment class...
View 2 Replies
Apr 19, 2011
I have to access jsp variable in mxml file... or how to access jsp variable in java file...
View 1 Replies
Jun 17, 2009
I have 2 classes: A Main.as and XmlLoader.as. In Main.as I now want to access a variable of a XmlLoader-instance, which has been changed in run-time by a Event.COMPLETE EventListener.To make things clearer here some code:
Code:
Main.as:
package {
import flash.display.*;
[code]....
in Main.as I want to trace (trace(_xmlData._xml)) the xml file which is loaded.
View 0 Replies