ActionScript 3.0 :: Accessing A Button With MovieClips?
Jul 20, 2011
I have the following code that loads MovieClips to the stage:
ActionScript Code:
var sp:MovieClip = new MovieClip();
addChild(sp);
for (var i:int=1; i<19; i++) {
[code]....
Let's say I have 18 MovieClips and on the 18th MovieClip I have a button that I need to access. How would I do that? The following doesn't work:
ActionScript Code:
sp.bm.Pag18._homeBtn.addEventListener("mouseUp", goHome);
View 5 Replies
Similar Posts:
Oct 5, 2008
I am still transfering from AS2 to AS3 and right now i am having a very annoying problem. THE STRUCTURE:
Maintimeline contains 2 buttons that i want to use to access children in a bunch of movieclips. rectangle_mc has circle_mc circle_mc contains xx_mc xx_mc contains wtf_mc placed on frame 1 on maintimeline Why can't flash see my nested movieclips? I remember in AS2 you could go down the line:
[Code]...
View 15 Replies
Jul 30, 2010
I am starting with AS3 programming icm with Flash Builder 4.I have created a "Main" class which is the initial stage.On this stage there is a movieclip called mcMain.In this mcMain is 4 other movieclips: mcStats1 mcStats2 mcStats3 mcStats4 .How can I access these mcStats1-4 from the code to make them go to another frame?I tried:
var t:MovieClip = MovieClip(getChildByName("mcMain"));
t.getChildByName("mcStats1").gotoAndPlay(3);
But that just keeps giving me null reference errors:TypeError: Error #1009: Cannot access a property or method of a null object reference.
View 4 Replies
Jun 16, 2008
I have finally started with AS3 and flip-'eck its a different animal that AS2
I have a swf called login.swf and in it have declared the variables var total:uint=0; and loginState:Boolean=false
All my scripts for logging in sending/receiving variable from/to server scripts are all working!
So... when a user supplies a correct password another swf (userLogged.swf) is loaded (note: in AS3 this process is seriously different than in AS2) swf dont seem to be loaded 'into' another movieclip anymore... and this leads me to the puzzle!
How do I access variables declared in the project.swf, from within the userLogged.swf!
the old AS2 way = trace (_root.loginState);
or trace (_root.project.loginState)!
I am stumped by this new approach of AS3 of loading in other swf files. The _root. options is no longer available in AS3 (that much I've descovered, some tuts say use root. but I cannot get that to work)
trace (root.loginState)
or
var userLoggedIn=root.loginState
gives me the error
1119: Access of possibly undefined property loginStatus through a reference with static type flash.displayisplayObject.
when I try to publish the userLogged.swf
View 4 Replies
Mar 14, 2010
I'm having problems making a loop of different movieClips. I've been able to find info about duplicating the same movieClip but I can't seem to get it to apply to this. This is what I am working with: I have 13 different movieClips of an animated character. They are titled montyDog_mc, montyBear_mc, montyCat_mc, etc. I also have a next and a previous button. What I need to happen is for the movieClip animations to cycle through, one at a time, each time the user clicks the next or previous button. I think I should be creating an array of some sort but I am very confused about how I list the movie clips in an array and apply it to the button.
This is what I have:
montyArray = new Array();
montyBear[0] = "montyBear_mc";
montyBee[1] = "montyBee_mc";
montyCow[2] = "montyCow_mc";
montyDog[3] = "montyDog_mc";
[Code] .....
Am I targeting the movieClips properly?
View 4 Replies
Dec 3, 2009
i have a gallery on my root timeline. The gallery is called work_mc. Inside of work_mc I have various buttons. There is a different section on different frames.For example,ALL is on frame one, PRINT is on frame two, motion is on frame three.In the root here is the
Code:
work_mc.urbanthmb_mc.addEventListener(MouseEvent.CLICK, clickHandler);
work_mc.urbanthmb_mc.buttonMode = true;
function clickHandler(event:MouseEvent):void {[code]......
This is targeting the buttons that are on frame 1. How do I get to the buttons that are on frame 3? I tried just using the movieclip names but this doesnt seem to work?
View 0 Replies
Nov 20, 2010
everyone comes across when switching from AS2 to AS3. I have two movieclips (on the same timeline)- character and walls. on the timeline inside walls, I want to access the x and y coordinates of character. How can this be done without the convenience of _root or _parent?
View 1 Replies
Dec 3, 2009
i have a gallery on my root timeline.The gallery is called work_mc. Inside of work_mc I have various buttons. There is a different section on different frames. For example, ALL is on frame one, PRINT is on frame two, motion is on frame three.[code]This is targeting the buttons that are on frame 1. How do I get to the buttons that are on frame 3? I tried just using the movieclip names but this doesnt seem to work?
View 1 Replies
Dec 5, 2009
I have a movie clip (assigned to a class) with several keyframes. Each keyframe consists of another movieclip, which contains an animation and all use the same name. Lastly, several of the animations contain a third movieclip, which is also assigned to a class and also use the same name. I need the first movieclip to speak to the third, unfortunately, it simultaneously tells me that the clips in the second layer (the ones at the keyframes) exist and do not exist. Namely: second layer "does not exist" in that the primary movieclip has only one child: a null. If I add other movieclips to the primary's frames, they also report back as nulls depending on what frame I'm on. I've tested this in several parts of the code, though I suppose it's possible that I managed to pick five equally bad spots. It's just so bizarre I still don't know what to think about it. However, the second layer of named clips are there, but I can only prove it by deliberately breaking the code in hopes of deliberately getting a reference error (by attempting to make the clip private, which isn't allowed given my setup).
View 0 Replies
Mar 14, 2012
I'm having a lot of trouble understanding a certain thing.I'm creating a child of a symbol in my 'main' class.[code]I have no idea how to access 'player' from a seperate class? I would like to change x and y coords from a seperate class. However when I use code like 'player.x = player.x + 2' i get the error message Line 17 1120: Access of undefined property player.I guess in the most simple words, I do not know how to access symbols or their children from a class that is not the document class.[code]Basically I just am curious as to why I can't simply access these items from another class?
View 2 Replies
Nov 21, 2008
I have an application that I am adding movieclips to a container movieclip through a for loop and repeatedly calling myClip.addChild(theNewClip). Now I have a dozen clips in my container and it seems like the only way to access the clip is to use the getChildByName() method and cast it into a temporary clip so I can get at the its properties.
Is this the best and/or only way to do this? Does the old AS2 myContainer["theName"].property not work with dynamically created movieclips? It doesn't seem to work for me anymore.
access a dynamically created movie clip.
View 1 Replies
Nov 21, 2008
I have an application that I am adding movieclips to a container movieclip through a for loop and repeatedly calling myClip.addChild(theNewClip). Now I have a dozen clips in my container and it seems like the only way to access the clip is to use the getChildByName() method and cast it into a temporary clip so I can get at the its properties.
Is this the best and/or only way to do this? Does the old AS2 myContainer["theName"].property not work with dynamically created movieclips? It doesn't seem to work for me anymore.
access a dynamically created movie clip.
View 1 Replies
Sep 26, 2009
I'm trying to dynamicly create movieclips that I can drag and drop. Here's what I'm trying to reproduce dynamically: (I placed 2 movieclips on my stage and named them mandible_mc and vertibral_mc)
mandible_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);mandible_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);vertibral_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);vertibral_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function pickUp(event:MouseEvent):void {
[Code] .....
Here's what's happening:
Unless I have actually placed two movieclips on the stage and named them mandible_mc and vertibral_mc, I get an error. If I DO have those to movieclips on the stage, I get no error and I get my instances of "name_box". But, I can't drag them. I CAN drag and drop instances of mandible_mc and vertibral_mc so I know the addEventListener and buttonMode "thingys" are being created.
View 7 Replies
Feb 17, 2010
I have a movieClip within another MovieClip. I gave the child movieClip the instance name "hSprite" and I added it to the parent movieClip stage. Now I get an error like the following.
[Fault] exception, information=ReferenceError: Error #1056: Cannot create property hSprite on com.objects.Hero. If I remove the instance name from the child movieclip, then the error goes away. but when I add the instance name back, the error reappears again.
Keep in mind that both classes are set for export. The parent class is embeded by a custom class which work perfectly fine. But the minute I give the child movieClip a instance name, the error starts up again.
[Code]...
View 1 Replies
Nov 1, 2011
I am trying to access movieclips within my movieclip using a for statement. To try and make this clear, here is how it looks at the moment:
sections = Holder movieclip where dtf_sections is placed, as well as other clips that are needed.
dtf_sections = Where all the title movieclips are placed that are going to be used when called. Placed in here to make it easier to move, within sections
title = Movieclip that contains the text that needs to be changed, within dtf_sections
Here is my code that works:
sections.dtf_sections.title1.dtf_title.text = "Section 1"
There are upto 10 titles within dtf_sections. So, what I thought would work is this:
for(var i:uint=1; i<10; i++){
sections.dtf_sections.["title"+String(i)].dtf_title.text = "Section" +(i)
}
The reason why they are within the movieclips is masking, and appearing at different times.
View 1 Replies
Aug 10, 2009
I am a newbie to AS 2.0..I only have basic actionscript 2.0 knowledge."I have one main .swf file and several external .swfs which I am loading through this code.[code]Now my problem is that I would like to access one "close_mc movieclip" in ourGroup.swf ...so that clicking that clip, I can exit the externally loaded .swf from the main .swf file."
View 3 Replies
Dec 15, 2009
I am able to dynamically create an object on the stage with a function, but I am at a loss for how to access and manipulate the properties of that object from my Main Class.
in my Main Class I have:
ActionScript Code:
NLP_addChild.addObject(stage)
// NLP_addChild is the other class addObject() is the function
in NLP_addChild Class appears the following:
ActionScript Code:
public static function addObject(stage:Stage)
{
var myCircle:MovieClip = new circle()
[code]....
myCircle displays correctly on the stage, myCircle is correctly assigned an x of 300. But myCircle x property cannot be assigned from my main class.
View 2 Replies
Nov 22, 2004
I'm currently learning OOP through Sen's information here at Kirupa, and I've decided to try out his "creatures" exercise mentioned in his Best of Senocular thread...The situation is a random number of sprites are created, and they move around the stage, interacting. They all have a certain amount of "health," defined as a variable in a MovieClip prototype applied to the MC. When they hit, I want their health to go down a little bit, so how can I access a particular MC's "health" variable while I'm outside of the MC itself?
View 1 Replies
May 9, 2009
Instead of posting my entire files and such, I'll make a brief example of my situation and my desired outcome. My files consist of my document class entitled Engine.as and another class Abilities.as all within the same folder.
On my stage I have a MovieClip with the instance name of item1_mc. On its personal timeline I have 2 frames, one entitled "inactive" and the other "active". Here's a sample of very similar code.
[Code]...
View 1 Replies
Jan 18, 2010
I am having a newbie problem here. I am loading an external SWF with embedded movieclips (all clips are set to export in the original file). However, I can't figure out how to access those embedded clips in my new, parent, flash file. Here is my code:
Code:
var container:MovieClip=new MovieClip()
var house_Loader:Loader = new Loader();
[code].....
View 4 Replies
Nov 22, 2004
I'm currently learning OOP through Sen's information here at Kirupa, and I've decided to try out his "creatures" exercise mentioned in his Best of Senocular thread...I still have a bunch to learn, but I wanted to go ahead and ask a question for a problem I am having right now.The situation is a random number of sprites are created, and they move around the stage,interacting. They all have a certain amount of "health," defined as a variable in a MovieClip prototype applied to the MC. When they hit, I want their health to go down a little bit, so how can I access a particular MC's "health" variable while I'm outside of the MC itself?
View 1 Replies
Nov 4, 2010
I have a bunch of movieclips which were created by "addChild" method. These movieclips are added to "gamecontainer". There was a dynamic textfield in each movieclip. Now the problem is how can I change the text in the dynamic textfield inside each movieclip outside this function.
Here is the code:
private function arrangeClips():void {
for (var i:uint=0; i<7; i++) {
var tile_mc:whiteTail=new whiteTail();
[Code].....
View 2 Replies
Sep 11, 2009
So for my main timeline:
var lightBox:mc_lightbox = new mc_lightbox();
lightBox.x = 300;
lightBox.y = 200;
addChild(lightBox);
I get a lightbox up on the screen, within the lightbox is some more script, there are three menu options for that new window. So far when you click on it the loading part comes up just fine but whenever I have it go to another scene it leaves behind the lightbox above. I'm able to removeChild(loading) because its right there just a function above but I'm unable to removeChild(lightBox) because it's one up. How can I access that child? I tried many variations of parent, MovieClip, and root relationships but still couldn't get flash to find it.
View 1 Replies
Oct 1, 2009
After resolving one issue, another error has surfaced in my custom class. This class displays a dialogBox and the dialogBox has some interactive MovieClips like btnOK_mc Button.On creating an object of the said class, it reports errors like "Access of undefined property btnOK_mc".[code]I understand that it is an issue of the Scope of these controls; but don't know, how to define these MCs; so that they look like Public. I may be just out of track on the issue.
View 8 Replies
Jun 17, 2010
I have a couple of Text input fields sitting inside a MovieClip and i am wanting to know how do i go about accessing them from outside the MovieClip and obtaining the value of each input text field?the movieclip is called myinstance the movieclip code is in a value like this public var myinstance: MovieClip = new Ccontrol(); that is for the MovieClip the actual [code]When i do that i get the message the left control is now.when it shud be the left control is A or what ever the user entered in the input field b4 they click on the button savedcontrols.
View 1 Replies
Jun 3, 2009
I was trying to access some nested movieClips from the main time line but it was giving an error. What I have is a movieClip on the stage called "dog" and inside this movieClip I have two nested movieClips called "dogLH" and "dogRH". The movieClip "dog" was brought to the stage using actionscript 3.0 and when I tried to move the moveClips inside "dog" it gave me an error.
This is the code I have:
var dogog = new Dog();
dog.x =200;
dog.y =150;
[Code]....
What is strange is that if I add the movieClip "dog" to the stage manually and try the same thing it works. Any idea why it doesn't work when it is brought to stage with actionscript, but it works if I bring this manually?
View 2 Replies
Aug 13, 2009
I made a ship in flash, composed of different movieclips exported for actionscipt, then I converted the whole ship in a movieclip. I wanna access a wing to make it rotate but I don't know how. I tried this:
Code:
package{
import flash.display.MovieClip;
public class Prueba extends MovieClip{
[Code].....
View 8 Replies
Feb 16, 2011
I have a MovieClip, that I'm going to add to the display list with my document class at runtime beacuase there will be many instances of it. The MoviClip "box" has 3 more MovieClip instances inside it,and each of those three have two more.It looks like this:
box
circle 0
oval0
oval1
[code]....
View 2 Replies
Aug 19, 2009
I am trying to implement a "card shuffle" animation using MovieClip instances on the stage. The instances are linked to the same class. From the class I am able to look at the numChildren of the parent:
trace(this.parent.numChildren);
Let's say I have three cards on the stage with these instance names: "orange_mc", "green_mc" and "blue_mc". They are all linked to a custom class I created. On a MouseEvent I would like to bring the selected card to the top depth. I know that this would do the trick:
this.parent.addChild(this);
I would like to animate the effect and it seems that to be able to do this I would need to know the depths of all the MovieClips on the stage (or at least to determine if the selected is at the top - for this, no animation would be required). I tried the following, only to get an error:
this.parent.getChildIndex(orange_mc);
and
MovieClip(this.parent).getChildIndex(orange_mc);
View 1 Replies
Feb 1, 2010
I have a movie clip menu on a main timeline and inside that movie clip I have created four buttons dynamically. How to access those nested buttons/movieClips (add event listeners etc) from main timeline? Here I am adding menu to the display list on main timeline:
[Code]...
View 2 Replies