ActionScript 3.0 :: Use A Variable Inside AddChild()?

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


Similar Posts:


ActionScript 3.0 :: AddChild Inside Another MC?

Aug 12, 2009

here is my code that is on the frame:

PHP Code:
//Variables
var user:MovieClip = new user_lib();

[code].....

View 9 Replies

ActionScript 3.0 :: How To Target A MC Inside AddChild()

Feb 11, 2011

I haven't found my answer with a search of the forum, sorry if this is a redundant question. I am having problems with targeting a MovieClip that is inside another Movie Clip that is placed on stage from the Library using the addChild(); method. This is my code for creating the MC instance on stage:

var pMenuSlide:plusMenuSlide = new plusMenuSlide();
addChild(pMenuSlide);

Now, inside of pMenuSlide there is a MC called cloze, how do I target this MC? This does not work: var pMenuCloze:MovieClip = Object(root).pMenuSlide.cloze

View 5 Replies

ActionScript 3.0 :: Add Link Inside Addchild?

Jul 6, 2009

I have an MC that I want to add to Stage dynamically. Until here everything seems fine:

for (var j:int = 0; j < nomePostosArray.length; j++) {
var MC:MovieClip = new mc();
namelistscroller.text.addChild(MC);

[Code].....

the variable mapLink is inside the MC. This should be a link that should follow when someone press the link button inside MC. This is the only part that is not working.

View 4 Replies

ActionScript 3.0 :: Buttons Inside MC Added With AddChild

Feb 22, 2011

I have my Stage. On this I have an empty MovieClip (MC). To begin with I do:

MCContent = new TestMC();
MC.addChild(MCContent);

This works. But in my TestMC, I have another MovieClip Button01, which is named Button01, where I have the code:

Button01.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
function handleMouseUp(event:MouseEvent):void {
trace('Hello World);
}

But when I click on Button01 nothing happens... What am I doing wrong?

View 10 Replies

ActionScript 3.0 :: AddChild() Does Not Work Inside Package{}

Sep 24, 2009

My Question: AddChild() in Main class work as expected, but not in GoBall class. (Main class refers to GoBall: var go = new GoBall()

[Code]...

View 2 Replies

ActionScript 3.0 :: AddChild Does Not Get The Child Sit Inside Parent Object

Oct 23, 2009

I am trying to get a circle shape and a text-field sit inside a square sprite, using addChild() method. Both the children seem not to agree sitting in the lap of their parent; and are sitting at a distance, instead. If I create a square symbol on the stage and run the application, everything is fine.

[Code].....

View 3 Replies

Actionscript 3.0 :: Add Graphics To Stage Using AddChild Inside Class

Feb 6, 2009

I'm have trouble attaching graphics to the stage from a class. I can do it on the timeline but the code doesn't work in a package.[code]this doesn't seem to work even if I import the picture in the package.[code]

View 1 Replies

IDE :: Accessing Dynamic Text From Inside An AddChild Object?

Aug 27, 2008

Can't figure this out for the life of me. Its probably something simple, but I can't find any solutions online. Can anyone help a brother out here? All I'm trying to do is assign text to a dynamic text box that is inside a movieclip (loaded from the library using addChild()

[Code]...

View 8 Replies

ActionScript 3.0 :: Flash AddChild Does Not Work Inside Package

May 13, 2011

I would like to create a class displaying a button:
Code:
package {
import flash.display.Sprite;
import flash.display.SimpleButton;
import flash.display.MovieClip;
import flash.text.TextField;
[Code] .....

But when I call this from my fla file:
Code:
import AutoHideButton;
var button:AutoHideButton = new AutoHideButton();
no errors are given but nothing is displayed (the same code pasted directly into the timeline works).

View 2 Replies

ActionScript 3.0 :: Using AddChild With A Variable

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

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

ActionScript 3.0 :: Referencing Variable In AddChild?

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

ActionScript 3.0 :: Flash - AddChild Dynamically Using A Variable?

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

ActionScript 3.0 :: Switching AddChild() Parents - Pictures To Appear As Popups However To Add The Child From Inside The Movieclip

Aug 21, 2009

in my last flash website i built, i created a gallery, my way of creating pages in flash are to have a movieclip as a page, so to make it easier to switch between the paged (page switching functionality is purely done in AS3). the gallery was a problem however, i needed the pictures to appear as popups, however to add the child from inside the movieclip, any masks i use would prevent the popup from leaving the immediate area of the page. so to get around this problem i basically used: MovieClip(root).addChild()

in my opinion this was a mistake, because it created other problems. the problem was that the popups are still connected to the page, even though they are outside of it, which meant that using removeChild() to switch from the gallery, meant that any popup that were still active, 'DIDNT' dissapear, and worse than that, because the page was removed, the popups lost any AS connected to them, which meant the couldnt be removed at all.

[Code]...

View 2 Replies

ActionScript 3.0 :: DisplayObject And AddChild - Use The Variable OpenType In The Call For The Image??

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

ActionScript 3.0 :: AddChild For Loop - Display Items On The Stage Nested Inside A Movieclip Called MainItem

Mar 31, 2011

I have a MovieClip called item with the same linkage set and my first task is to display 10 of these items on the stage nested inside a movieclip called MainItem. I have dragged MainItem to the stage and have the following for loop:

[Code]....

View 5 Replies

ActionScript 3.0 :: AddChild From A Class - Get The Error "1180 : Call To A Possibly Undefined Method AddChild?

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

ActionScript 3.0 :: Box2d Addchild - 41061: Call To A Possibly Undefined Method AddChild Through A Reference With Static Type Class

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

ActionScript 3.0 :: Can't AddChild To Movieclip Inside Movieclip

Jul 13, 2010

my_mediafile.load(new URLRequest("PMP2.jpg"));
//trace ("my_mediafile "+my_mediafile);
trace(mc_pmp.gfx_pmp)
mc_pmp.addChild(my_mediafile);

i have a movie clip(called gfx_pmp) inside of my movieclip (called mc_pmp) and i wanted to add a child to that movieclip gfx_pmp

thought i could use this code

mc_pmp.gfx_pmp.addChild(my_mediafile)

but it doesn't seem to work. when i ran a trace on mc_pmp.gfx_pmp it returned null as a value

trace(mc_pmp.gfx_pmp)
//returns null

i dont see what the issue is here, or why the trace on that is returning null

[object mc_pmp_43]
1st trace gfx_pmp [object MovieClip]
2ndtrace gfx_pmp [object MovieClip]

[Code]....

View 2 Replies

ActionScript 3.0 :: Difference Between Mc.stage.addChild And Mc.addChild?

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

ActionScript 3.0 :: Difference Between AddChild And Parent.addChild?

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

Use A Variable And Then AddChild With A RemoveChild For The Old MovieClip After The New MovieClip Has Loaded

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

ActionScript 3.0 :: AddChild, RemoveChild And AddChild?

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

How To Use Variable Inside Of Timer

Jun 18, 2010

I'm working on a simple catching game where you have monsters coming out from the corner of the screen and you need to get them with the mouse.What I want to do is change the rate at which the monsters come out depending on the score. The higher the score, the more monsters should come out.The code for creating new monsters is a simple timer event:[code]it works when I declare the variable locally within the function. But then I can't access it outside of it, so it's no good!

View 2 Replies

ActionScript 3.0 :: Load External SWFs, AddChild(Loader) Versus AddChild(Loader.content), Etc?

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

ActionScript 3.0 :: Use A Variable Inside A GotoAndStop?

Mar 23, 2011

I saw a few examples when googling but couldn't get it to work. I want to use a variable inside a gotoAndStop. Is this possible?
 
[AS]
var vRandomNumber:Number = 1;
gotoAndStop(vRandomNumber);
[/AS]

View 3 Replies

Flex :: CDATA Inside XML Variable?

Oct 23, 2009

In Flex I want to create XML variable like this but parser complains about CDATA in publisher tag:

<mx:Script>
<![CDATA[
private var myXML:XML = <book>[code].....

How do I pass xml text with CDATA into XML variable being in MXML Script?

View 1 Replies

How To Pass Variable From Inside MovieClip Into Another One

Sep 29, 2011

I am creating a quiz and I set one quiz block with questions into a movieclip. When the person answers the correct answer I want it to add to a counter and pass that value onto the next movieclip. So movieclip one is added to the stage it does something then adds a counter. Then moves to the next frame and movieclip2 is added to the stage. It does something and add to the same counter variable from movieclip1. And so on and so on until no more movieclips.

View 1 Replies

ActionScript 3.0 :: Get Variable Name Inside An Array?

Jan 11, 2012

Is there a way to obtain the variable name that is inside an array?[code]...

View 2 Replies







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