Actionscript 3 :: Referencing A Document Class From A Child MovieClip?

Apr 13, 2010

I have a document class with a child MovieClip on the stage. I have the clip already on the stage because it's part of an complex layout provided by the designer and it seems easier to leave it on the stage than to use addChild (since I would have to add about 60 objects).What is the best way to reference the document class from inside the child MovieClip class?

View 1 Replies


Similar Posts:


ActionScript 3.0 :: Referencing A Textfield Inside A Movieclip Class From Document Class

Feb 3, 2009

Ok, this is one of those walls that I know once I can jump over it, I will be a much happier developer again.

I've done tons of reading, and think I have a firm understanding that the general consensus is that if you want to reference something, it needs to be added to the display list, using addChild().

I hate to be defiant, but what if I don't want to?

Or at the very least, what if I want to add a movieclip class to the stage using addChild, and then reference objects inside it?

It is much easier this way than what most people recommend - adding 15 objects via addChild, then setting the x and y for the, etc.

That said, I'm all about using classes and using as3 the way it was meant to be used. So what this is, is a best practices question I guess.

HERE ARE THE STEPS I'M TRYING:

- Create new flash document

- Draw graphic symbol bg, with text field over it, select them, convert to movieclip symbol, and export class name "box", then delete it from stage

- Add document class .as file, which simply adds that class "box" from the library, to the display list using a simple addChild()

- Set a name for that box using box.name = "test" let's say

- Do a simple trace like the following - "getChildByName('test').textFieldName" - it shows up great

- So then, I'll now try to set the text by doing this - getChildByName('test').textFieldName.text = "yo";

That last line above, is what doesn't work. I know I'm referencing wrong, but how would a pro as3 developer, reference something on the stage within a movieclip class, from the document class?

View 1 Replies

Actionscript 3 :: Referencing Variable In Document Class From Another Class?

Mar 11, 2011

I need to increment an integer variable in a function within the document class upon transpiring event in another class. I can't seem to figure out how to call the function and reference the variable.

View 2 Replies

ActionScript 3.0 :: Referencing The Stage From A Child MovieClip

Dec 15, 2009

I feel like I should know this by now, but I'm having trouble. I want a function in one of my child functions to increment an integer in its parent function.

[Code]....

View 9 Replies

Flash :: Adding Child To Document Class Vs Adding Child To Stage?

Nov 24, 2011

The name of my DocumentClass is Main. So, what's the difference between :

var myClass:Main = new Main();
var mcInLibrary:MovieClip ;
/////////////////////////////////////////[code]............

View 1 Replies

ActionScript 3.0 :: Where Is Document Class In Parent/child Hierarchy

Jan 19, 2011

I have a class linked with a movie clip, and in this movie clip I want to be able to add an event listener that calls a function in the Document class (the class you link with the fla as a whole). How can I do that? Say the name of my document class is KPScript.as. In my GameController.as class, I want to listen for key input and call pageChange() in KPScript.as when it gets called. Would I have to import KPScript.as into the GameController.as? If so, I wouldn't want to create another instance of the KPScript object.

View 1 Replies

Actionscript 3.0 :: Access Child Swf Document Class Using ApplicationDomain

Jun 22, 2009

i m getting an error, i am loading an external child swf file to main parent swf, and want to access the document class of the child swf through parent swf document class using application domain. Now when both child and parent swf resides in same directory it's works properly with application domain means we can access the document class of the child swf see the attachment samedirectory.zip and when we move child swf and it's document class to sub directory that time we are unable to access the document class of the child swf see the second attachment subdirectory.zip

View 1 Replies

Actionscript 3.0 :: Access Child Swf Document Class Using ApplicationDomain?

Jan 17, 2010

i m getting an error, i m new to as3, actually i am loading an external child swf file to main parent swf, and want to access the document class of the child swf through parent swf document class using application domain. Now when both child and parent swf resides in same directory it's works properly with application domain means we can access the document class of the child swf see the attachment samedirectory.zip and when we move child swf and it's document class to sub directory that time we are unable to access the document class of the child swf see the second attachment subdirectory.zip and give me right direction

View 2 Replies

ActionScript 3.0 :: Root And Document Class For Child SWF Loaded By Parent SWF?

Feb 12, 2011

I'm using a PreLoader as a parent SWF that loads the actual website as a child SWF. In the website SWF, the child SWF, will MovieClip(root) still work and refer to it's own root, or the PreLoader's root? And would I still access the websitite's document class (the child's document class), through MovieClip(root)? What if both files have a document class?So my main question is how do document classes and MovieClip(root) behave in the scenario when you have:

Parent SWF - document class, MovieClip(root)
|
Child SWF (loaded by parent) - document class, MovieClip(root)

View 2 Replies

ActionScript 3.0 :: Two Child Swf's With Same Document Class - Constructor Gets Overwritten - Flash Bug?

Jul 22, 2009

here is the scenario we ran across while working on our Flash AS3 project today.

/main/root.fla
/main/root.as
/main/sub1/sub.fla

[code]....

We have many sub swf's that are loaded by the main root swf. The root swf shows the art on the stage of the sub swf, and also runs some code from the sub swf's document class. However, we noticed the constructor was not getting called on the second sub swf if the document class is the same name- even if they are in different folders. Note that we publish our swf files to a separate directory (with the same structure as above) so it is easily copied to the web server.

-root.swf loads sub1/sub.swf
-the constructor of the document class sub.as in subfolder sub1 gets called
-root.swf shows sub1/sub.swf assets with the correctly constructed sub1/sub.as document class
-user chooses to switch to sub2

[code]...

We decided to use a workaround where we basically changed the two document class .as files to be different names (e.g. renamed sub1/sub.as -> sub1/sub1.as and sub2/sub.as -> sub2/sub2.as, and updated the .fla's to point to the renamed document classes), and it works as expected. Hopefully that workaround is useful for someone.I realize most people just name every single file differently and keep everything in one folder, but when you have a sufficiently complicated project, things like this come up.

View 2 Replies

ActionScript 3.0 :: Flash - Access Child Created By Document Class?

Apr 14, 2011

I am new to AS 3 and I tried to solve this (probably really simple) problem, but I couldn't, so I gotta ask here. All I did was create a child through a function in my document class.It is in fact an altered version of the rotate circles tutorial from kirupa.

Code:
function makeCircle (e:Event):void {
var circle:BlueCircle=new BlueCircle ;

[code]......

View 4 Replies

ActionScript 3.0 :: Access The Document Class From A Child Movie Clip On The Stage?

Jul 22, 2010

i know this may seem kind of dumb, but how does one access the document class from a child movie clip on the stage?

i have a property in my class. Just a string for testing:

Code:
public var s:String = 'can you see me';

it traces on the root time line, but it errors out if tracing it from a movieclip on the root time line.

View 1 Replies

ActionScript 3.0 :: Referencing Stage From Within MovieClip Or Class

Dec 9, 2009

I'd like to know how I can reference root stage values from within a movieclip, or even worse, from a class. For example, I have a class called Bground.as. It does stuff, according to current stage size - so if someone were to resize the window/browser, Background updates in real time and does something fancy while it's at it. To do this "fancyness", I need stageheight and stagewidth. However, simply pointing to them does not work.

Here's the simplified ActionScript Code:
package klaseFP{
// imports
import flash.events.*;
import flash.display.*;
public class Bground extends MovieClip{
[Code] .....

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at klaseFP::Bground()
at FullScreen_03_fla::MainTimeline/frame1()

Background works as a document class, works perfectly in fact. However, if I use it as the class of a library object, error 1009 shows up. Same thing happens if I simply put the code into the timeline of the library object - stage referencing simply causes it to break. So, how do I dynamically change the values of variables in Background, according to values in the main movie/app?

View 2 Replies

ActionScript 3.0 :: Referencing Class Variables For A Movieclip?

Dec 5, 2011

Hey guys. It's been a while since I've used Flash and I am still trying to wrap my head around Actionscript 3.0 and the way it works; I am so used to the way AS2 works.I have provided the code below, it's very simple, so you might be able to skip this explanation and just take a look at the error and the code:

- I have made a movieclip called HeroMC in my FLA.

- The HeroMC movieclip has the AS Class linkage of exactly the same name, "HeroMC".

- I have made an actionscript class file, HeroMC.as, to house specific variables for my hero; such as Name, Age, xPos and yPos.

- I have also made an actionscript class file, Main.as, the document class for this FLA.

- In Main.as I instantiate HeroMC using the variable hero, and then run the function addHero() from my constructor.

- addHero() is a simple stage.addChild(hero);

This all works perfectly fine and it adds my hero to the stage. However, the problem arises whenever I try to reference one of the variables from HeroMC.as. I am met with this error - I will use the variable xPos as an example.

Here is the error:

1119: Access of possibly undefined property xPos through a reference with static type HeroMC.

Here is the code for Main.as:

Code:
package {
import flash.display.*;
import flash.events.*;

[code]....

It is obvious this is a very simple problem, but I have searched Google, Kirupa and Flashkit for an answer, but none of the threads I find discuss my specific circumstances and I am unable to find the specific information I need to.

View 3 Replies

Actionscript 3 :: Can A Document Class Extend Another Custom Class That Extends MovieClip?

Aug 16, 2011

If I have a Document class that extends MovieClip, and I want to use it as the basis for another Document class, is it possible to create a subclass that extends the main document class and use that for a different FLA?

For example,

fla1.fla has a document class of MyMainClass:
public class MyMainClass extends MovieClip
fla2.fla has a document class of MySubClass:
public class MySubClass extends MyMainClass

I've tried, but now I'm getting errors that all of my variables that reference stage instances aren't being found.

View 1 Replies

ActionScript 3.0 :: Reference Movieclip On Stage From Custom Class Of Document Class

Dec 7, 2009

Is there a way I can reference a Movie clip I have on the main stage from a custom class of a document class?[code]

View 1 Replies

ActionScript 3.0 :: Call Function Of Document Class From MovieClip Class

Aug 8, 2008

How can I run function of the main document class from a class of a MovieClip? I usually just used MovieClip(parent).function(), but now my MovieClip has another parent. Or what do I have to pass to the MovieClip class when creating the MovieClip to acess the main document class?

View 9 Replies

ActionScript 3.0 :: Reference Movieclip On The Stage From A Class Of The Document Class?

Dec 8, 2009

Is there a way to refer to a Movieclip on the stage from a class file of the document class

Lets say I have 3 MovieClips on the stage(a Circle, a Square and a Triangle)

I have the document class which calls another class that controls the MC on the stage

Example

ActionScript Code:
package {
public class Example extends Sprite {
//Create the instance of the class being called

[Code]....

View 1 Replies

ActionScript 3.0 :: Access A Movieclip On Document Class From Another Class?

Mar 3, 2011

Going further on my app, I felt in another problem. Despite having lots of posts on the web regarding this, none of the solutions worked for me In my document class (Main.as) ve two containers. One empty and another with a star that is being imported from the library. Here´s the main class:

package
{
import flash.display.*;

[code]......

View 4 Replies

ActionScript 3.0 :: Flash - Dispatching An Event From One Document Class And Listening For It Via Another Document Class?

Dec 14, 2010

I am dispatching an event from one document class and listening for it via another document class.My code in class A.

Code:
this.dispatchEvent(new MYEvent(MyEvent.APERTURE_DONE));
trace("Dispatching APERTURE_DONE");

my code in class B.

Code:
addEventListener(MyEvent.APERTURE_DONE, onDoorsOpen,true);
trace("Lisetning for APERTURE_DONE");

[code]....

My listener is registering before the event is dispatched, based on my output window, however I never get the "Open Doors" trace statement to fire.

View 2 Replies

ActionScript 3.0 :: Document Class Wants Movieclip?

Oct 20, 2009

I have a document class but if i extend sprite i get an error:

Code:
package {
import flash.display.Sprite;

[code]......

View 5 Replies

ActionScript 3.0 :: Reference Main Document Class From Document Class Of Loaded Swf

May 7, 2011

I have a FLA (say Main.FLA) document class with a child MovieClip on the stage: into the child MovieClip I load other swf files: each of the files contains its own Document Class (every swf is a somewhat independent application, say quizzes and so on).For some reason I must use the Main document class to store data (scores or so) from the child swfs loaded into the Main swf. HOW do I reference the Main class? I can't find a way.[code]and dispatch an Event this way from the loaded swf document class to the Main class:[code]Now, first of all I don't know if this could even work. Secondly, I tried to make it work by adding an event listener to my Main class but id did not work.

View 9 Replies

ActionScript 3.0 :: Target Movieclip From Document Class?

Dec 17, 2010

i am making a drag drop game. i created a doc class for the dragged items . i want to make the hit test with some movie clips on the stage but inside the class they are not seen by there names. how to perform my hit test

this is my code,and target1_mc &target2_mc are movie clips on the stage

package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;

[Code].....

View 5 Replies

Falsh :: Target MovieClip From Non-Document Class?

May 11, 2010

is there any way to target a MovieClip from an external class that's NOT the Document Class?

Is it correct to have the Document Class as Main AND View?

View 1 Replies

ActionScript 3.0 :: Access Document Class From Within Movieclip?

Jan 30, 2009

I was wondering if it was possible to access the document class from within a movieclip.

I am creating a slideshow type project, and I'm using a document class to switch between the frames using the arrow keys. However, in one of the "slideshow screen" movieclips, I want to have it stop, and then play another part when the arrow key is pressed again.

I tried to access my nextScreenToPlay method within the document class, but whenever I try to do it within a movie clip, I get this error: Call to a possibly undefined method nextScreenToPlay through a reference with static type class.

If I do a trace(Main), within a movieclip, it shows the class.

View 1 Replies

ActionScript 3.0 :: Access Document Class Var From Movieclip?

Sep 18, 2009

trace(MovieClip(root).TRACE);

so at pesent I am using this to try and access

Code:
public var TRACE:String

in the the document class.

however I am getting this

"1180: Call to a possibly undefined method addFrameScript.�"

my document class extends to Sprite as I have some stage resizing that occurs on Initialise

Code:
StaticInheritance extends Sprite

Im sure it has something to do with the way the document class extends.

View 1 Replies

ActionScript 3.0 :: Accessing A MovieClip From An External As That Is Not The Document Class?

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 4 Replies

ActionScript 3.0 :: Reference Sprite Or Movieclip In Document Class

Dec 9, 2009

How do I reference MovieClips or Sprites created in the Document class from a custom class?[code]But I have a lot objects I want to reference so using the above method would take to long.I know I can do this to reference a MovieClip on the main stage from a custom class.[code]Would referencing the sprite created in the document class be similar?

View 1 Replies

ActionScript 3.0 :: Calling Document Class Variables In A Movieclip

Feb 25, 2010

I have a variable, we'll call it helloNurse, defined in the document class, we'll call it Joy, as a public variable. Meanwhile, I have a movieclip within the FLA that uses that class as its document class that, simply put, needs to access that variable. I had read up that the following SHOULD work:

[Code]...

View 12 Replies

Flash :: Access A MovieClip On The Stage From The Document Class?

Jan 7, 2010

I have a "box_mc" movieclip on the root of my stage and I need to select it from within my Document Class. I thought Stage.getChildByName("box_mc") would work, but it just returns null.

View 2 Replies







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