ActionScript 3.0 :: Accessing MovieClips On The Stage From An External?
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
Similar Posts:
May 7, 2009
OK, I load an external SWF on stage.
I have a mc on there already, it's called 'darkOverlay' (instance name).
This is the code I'm trying to use to access it:
Code:
trace(stage.getChildByName("darkOverlay"));
if(stage.getChildByName("darkOverlay"))
{
MovieClip(stage.getChildByName("darkOverlay")).gotoAndPlay(21);
}
It returns null even when it's loaded in the main swf. What am I overlooking here?
View 9 Replies
Aug 3, 2009
im still trying to get into the whole oop thing but I still have some things that i dont understand.I have a movieclip on stage that i want to access using an external class that lives in a different folder.Is there a way to access movieclips on stage from external classes or that i have to create a connection between the document class and then send the movieclip instance using a class method ?
View 1 Replies
Feb 5, 2010
When I debug this, it gives me an error saying that it cannot access the stage because it's a null property.
ActionScript Code:
package {
import flash.display.MovieClip;
import flash.display.Stage;
import flash.text.TextField;
import flash.events.Event;
[Code] .....
View 2 Replies
Apr 23, 2010
How can I access objects and modify their property that is ALREADY placed on the stage using external classes (AS file)? I 'm a newbie of AS3 and followed some tutorials about AS3 not long ago. For I learned scripting in AS3 can be done using AS file rather than script on Timeline. But I have a question. How can I "find" and "modify"the objects on the stage, or inside a MovieClip , in AS3?
For example, I have a file call Stage004.fla which have no document class linkage. I place the MovieClip "StageMain" which links the Stage004.as on the stage. StageMain has a textfield in it named "textFieldStage001". The Stage004.as is ran using "Event.ADDED_TO_STAGE" since StageMain is on the stage. I create another AS file WindowRename , to test can I modify the text in "textFieldStage001".
Then the famous error #1109 occurred.
"1119: Access of possibly undefined property textFieldStage001 through a reference with static type Class."
ActionScript Code:
package {
import flash.display.Stage;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.MovieClip;
public class Stage004 extends MovieClip{
[Code] .....
View 9 Replies
Oct 7, 2008
Im trying to downgrade an AS3 project i have and i've run into a bit of an issue. Specifically... when loading an external movieclip using MovieClipLoader i want to access the stage height and width of the movie. I have tried using:
[Code]...
View 2 Replies
Jan 13, 2009
Still trying to wrap my brain about using classes in as3. I have my document class that calls another class that sets up buttons. I have the buttons working but I want them to play a movieclip on the stage when they are clicked. In AS2 I could just reference _root.mymc.play(); I am also having trouble setting up global variables which I think will have a similar solution. I think I read somewhere that I need to make a 'Globals' class inside my document class. Is this correct? I have tried doing that a few times but keep getting errors.
View 4 Replies
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 4, 2009
is it possible with AS3 to see the list of the movieclips that are on stage?
View 13 Replies
May 14, 2011
- I have A.fla.
- A.fla includes buttons, movie clips and also B.swf is loaded in A.fla using a LOADER
- i want to access elements in A.fla, from the actionscript codes inside B.fla to modify those movie clips and buttons based on actions going on in B.swf
for instance, lets say there is a button X in A.fla, and there is a button Y in B.fla, B.swf is loaded into A.fla, and I want the button Y to erase button X when clicked.
general question: accessing elements in a stage, through a SWF file loaded into that stage.
View 2 Replies
Sep 9, 2011
Looking for a way to stop all movieclips both are the stage and that are children of the ones on the stage.
I toyed with looping thru stage's children so I can first target clips on the stage. But I am getting error.
for (var i:int = 0; i < this.numChildren; i++) if (this.getChildAt(i) is MovieClip)
{
this.getChildAt(i).stop
}}
View 5 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
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
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
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