ActionScript 3.0 :: Controlling MovieClip Instances Via Array In The Document Class

Jun 25, 2009

I tried to take similar code from this same forum, but I was either getting an error 1118 or an 1009 (null object reference).

Basically I have a series of movie clip instances on the stage with instance names of:

number_1
number_2
number_3

[Code]....

I tried but I kept getting an error...I think I am a little confused as to how to make it work properly.

View 4 Replies


Similar Posts:


Flash :: Access MovieClip Instances That Are Already On The Stage In Document Class?

Dec 15, 2011

I have created a game in flash, and due to the nature of the game, I have many movieclips placed on the stage manually in Flash CS4. They are not programmatically added as children to the stage, and so I am having difficulty getting access to them in the document class. So far the only method I have been able to use is to do stage.addChild(active_area); (for example), but there are many movie clips, all very differently named, so this method seems incorrect.I've discovered that my MovieClips are not children of the stage, but in fact MainTimeline, as when I for loop through stage.getChildAt(i);, only one child, root1, is traced out. How can I access movieclips that were placed on the stage in the timeline from the document class, without having to manually add them as children to the stage? So it looks like my problem wasn't that I couldn't access the MovieClips, it was that I wasn't modifying the MovieClips' values, so I wasn't registering any change in them.

Here is the code after I fixed it:
function manage_cursor(e:Event):void {
prevX=currX;

[code].....

View 2 Replies

ActionScript 3.0 :: Controlling Class Instances?

Aug 30, 2009

I have a class the extends a movie clip with some dynamic content in it.I need 15 instances of this class so i created a for loop for that.Im using the same variable name but im just initializing it again and again.

var thumb:MovieClip = new ThumbClass();
addChild(thumb)
my probem is that i need to find a way to control them after i created them.

[code]....

View 3 Replies

ActionScript 3.0 :: Access Stage Instances Outside Of Document Class?

Nov 20, 2010

I can access the targetObj instance inside the document class, but when I try to access it in another .as class,get this error:
 
Access of undefined property targetObj. 

View 9 Replies

Flash - How To Access Stage Instances Outside Of Document Class

Nov 20, 2010

I can access the targetObj instance inside the document class, but when I try to access it in another .as class,get this error:
Access of undefined property targetObj.

View 2 Replies

ActionScript 3 :: Accessing All Instances Placed In Different Frames From Document Class?

Aug 11, 2011

I have programmed a game using the Flash authoring tool and a document class. I'm trying to graphically add instances and add functionality in the document class. Suppose I have a main timeline with 3 frames, each frame reperesents a different level of the game. In frame 1 I have an instance of the MovieClip class named tree1 on the stage and in frame 3 I have an instance of the MovieClip class named tree3 on the stage. In my document class, after an initial stop() command, I want some logic like:
tree3.scaleX = tree1.scaleX;
But tree3 is unknown to the runtime since we are not of frame 3 yet. Any way to access all the instances on all frames declared in the authoring tool from the document class?

View 1 Replies

ActionScript 3.0 :: Controlling Movieclip From Array - Goto Inside Movieclip?

Oct 27, 2011

i have dynamic buttons in movieclip and i want the movieclip goto 2nd frame once some one click single movieclip while rest remains in 1st frame.the movieclips can be in arrayi have some code here:

Actionscript Code:
var mc:MovieClip = new MovieClip();for(var i:int = 0 ; i < numberOfButtons;i++){  var btn:MovieClip = new button(); 

[code]....

View 5 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 :: 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.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 :: Get An Array Of All Instances Of A Class On A Stage?

May 22, 2011

Assume I have the myCircle class all defined and all that. If my code is as follows:

[Code]...

How would I write a function to return an array of [circle1, circle 2, circle3, circle4] automatically?

View 2 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 :: Force Array's Elements To Only Be Instances Of A Specific Class?

Feb 18, 2009

I have been looking to see if it is possible to force an array's elements to only be instances of a specific class. Is it possible in AS? If not could the same result be achived with my own custom object?

View 3 Replies

ActionScript 2.0 :: Array In Multiple Class Instances Aren't Individual?

Jul 7, 2009

The code works fine, but I am getting unexpected results; the array seems to be shared across multiple instances of the same class? I've coded an example to highlight what is happening:

Code:
import myClass;
var instance:Array = new Array();
instance[0] = new myClass;

[Code].....

keep all objects/arrays separate across multiple instances of the class.

View 5 Replies

ActionScript 2.0 :: Create Array To Hold Some Movieclip Instances?

Feb 3, 2009

I wanted to do something like:

ActionScript Code:
arrayTucano = (tucano1, tucano2, tucano3); // movieclips instances
// Function to drag

[Code]....

But it drags only the last movieclip, tucano3.

Why? How could I make to drag all of them?

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 :: Retrieve Values From An Array To Create Instances Of A MovieClip

May 16, 2011

I am currently trying to create a piece of code that will retrieve values from a 2D array and use them as x and y values to position instances of a MovieClip called mcMain. The code for the array will look something like this...

Code:
var lvlMain:Array = new Array();
lvlMain.push(new Array());
var xAxis:Array = new Array([150,400,200,300,100]);

[Code]....

how to create a piece of code that would retrieve the x and y coordinates listed in the arrays and use them to create instances of mcMain. So going from the code above it would create the first instance at x=150 and y=100, second instance........fifth instance at x=100 and y=500.

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 :: Flash Create New Instances Of Sprites From Linkage Class Names Inside An Array

May 17, 2010

i have sprites in the library with linkages in them.. how would i create new instances of them if they are stored inside an array?

[Code]...

View 2 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