Actionscript 3 :: Keep Both Object And Reference On Stage?

Jun 16, 2011

I have some object, which extends movie clip:public class MyClass extends MovieClip Now, I want to put two of this in the stage:[code]That would put one, but the other I want it to be exactly the same as the first, so I just need to add a "reference" of obj to the stage, along with obj itself.In the end, I want two objects of type MyClass doing the same thing in the stage. If I try to simply do:[code]only obj2 will appear in the stage.How could I achieve that with references? (in order to save memory and CPU time (it is really important))

View 6 Replies


Similar Posts:


ActionScript 3.0 :: Pass Stage Reference To An Object Placed In Design View?

Nov 28, 2010

In a game me and a friend is creating, the levels are stored in MCs.In the level MCs there are several other MCs that the player should be able to interact with.

This means the objects in the levels need a stage reference.I can place all the objects manually and pass the stage ref in the constructor of the object's class, but this is a pain when the levels are going to be pretty big.

Is it possible to make sure that flash always passes a stage ref to the object even though it's not placed there by code?

View 1 Replies

Flash :: Reference Stage Object In External Actionscript Files?

Oct 14, 2011

I have an external AS3 class file which is loaded up on the first frame of the Flash movie.

How can I reference the stage object in the AS3 file without having to pass it as a parameter?I mean it seems to me like the stage object is in the global realm - or am I incorrect with this assumption?

View 1 Replies

ActionScript 3.0 :: Passing A Stage Reference To An Object Placed In The Design View?

Nov 28, 2010

In a game me and a friend are creating, the levels are stored in MCs. In the level MCs there are several other MCs that the player should be able to interact with.

This means the objects in the levels need a stage reference. I can place all the objects manually and pass the stage ref in the constructor of the object's class, but this is a pain when the levels are going to be pretty big.

Is it possible to make sure that flash always passes a stage ref to the object even though it's not placed there by code?

View 1 Replies

ActionScript 3.0 :: Referencing Stage - Error #1009: Cannot Access A Property Or Method Of A Null Object Reference

Feb 4, 2012

I think my issue is to do with referencing the stage, but not to sure. When I try

[CODE]...

View 3 Replies

ActionScript 3.0 :: OnClick On The Stage - Error #1009: Cannot Access A Property Or Method Of A Null Object Reference

Sep 9, 2009

i got this error Cannot access a property or method of a null object reference. whenever I clicked on my button

[Code]...

View 4 Replies

ActionScript 3.0 :: Getting An Error That They Cannot Reference The Stage/ Stage Is Null?

Jun 9, 2010

I am currently working with a contractor company that is hosting a flex based website. They are putting the swf files that I have developed into their flex site.The issue that I am having is that within my swf file I need to reference the stage.I do this by "MovieClip(parent).stage"... I do not use the keyword "root", I just reference my swf's root through however many "parent"s i need. It works fine when I publish on my own, outside of their flex site. When it is used in the flex site, they are getting an error that they cannot reference the stage/ stage is null. It is vital that I am able to reference the stage of my swf.

View 2 Replies

Flex :: Null Object Reference After Creating The Object?

Aug 22, 2011

I have one MXML File as

<objecthandles:ObjectHandles xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" backgroundAlpha="1" xmlns:mx="library://ns.adobe.com/flex/mx"

[code].....

View 1 Replies

ActionScript 3.0 :: Accessing Object - Error "Cannot Access A Property Or Method Of A Null Object Reference"

May 31, 2009

I have problem with accessing object created by function imported from another package.
I have 2 packages DragDrop and UserInterface. In UserInterface I create methods for buttons and later add them in DragDrop . I make it in two different ways:
One(this one works):

[Code]....

View 6 Replies

ActionScript 3.0 :: Dynamic Reference To MC's On Stage?

Sep 30, 2010

I have 9 MovieClips on stage (p1, p2, p3...), different colors and sizes. I have one AS3 class -Snake- that as an instance is supposed to duplicate one of these MC's as a Shape. The reference to the specific MC is supposed to be on the constructor method. These instances are supposed to be triggered from one global Enter.FRAME event.

My question: How can I refer a distinct MC from within a class? I ask this because this MC will be dynamic and its properties ever-changing (position and color). I know this can be solved by adding distinct Enter.FRAME listeners per instance, but I'd rather avoid bad practices.

[Code].....

View 1 Replies

ActionScript 3.0 :: Unable To Reference The Stage?

Nov 17, 2010

I am currently working with a contractor company that is hosting a flex based website. They are putting the swf files that I have developed into their flex site. The issue that I am having is that within my swf file I need to reference the stage. I do this by "MovieClip(parent).stage"... I do not use the keyword "root", I just reference my swf's root through however many "parent"s i need. It works fine when I publish on my own, outside of their flex site. When it is used in the flex site, they are getting an error that they cannot reference the stage/ stage is null. It is vital that I am able to reference the stage of my swf.

View 2 Replies

ActionScript 3.0 :: Reference To The Stage Not Working?

Sep 22, 2009

In my document class, I am instantiating a class like this:
 
cues = new CuePoints();
cues.addEventListener(CuePoints.CUE_POINTS_CLASS_ADDED, setCuePoints);
addChild(cues);

[Code]....
 
If I try to reference a MC that sits on the stage called videoPlayer_main like so: stage.videoPlayer_main I get the following error: 1119: Access of possibly undefined property videoPlayer_main through a reference with static type flash.display:Stage.

View 1 Replies

ActionScript 3.0 :: Reference To The Stage Not Working There?

Sep 22, 2009

In my document class, I am instantiating a class like this:

cues = new CuePoints();
cues.addEventListener(CuePoints.CUE_POINTS_CLASS_ADDED, setCuePoints);
addChild(cues);

[code].....

View 3 Replies

ActionScript 1/2 :: Reference The Stage From Within A Class?

May 25, 2010

I'm trying to get a small popup (a volume bar) to work from within a class.I made a piece of actionscript code that creates an empty movieClip and draws the bar into it and made it onto a class. The only thing I now have to do to add the bar to a programm, is create an instance of that class. Nothing needs to be added to the stage.The problem I encounter is that I need the bar to stay on top. New movieclips always get higher depths (using getNextHighestDepth()), so that's a problem.Calling swapDepths() for every new movieclip is far too complex and afaik there is no such thing as "bring to front" in actionscript, it only exists at design time, not at runtime.

So I though I'd use 2 layers/movieclips in the timeline, one for the volume bar and one for the rest, and add an empty movieclip to both.This way I know that all children I add to one movieclip will alway lay below anything I add to the second movieclip. (or is there an easier way to accomplish what I need? Levels maybe? I've never looked into levels, I only know they exist when loading a clip)This means I need to add a some extra stuff to the stage at design time, but if this fixes the issue.. ah well.But how can I access that movieclip from within a class? The reference "_root.volumeBarPlaceholder" works from within the main actionscript, but not from within a class because I get the compiler error "There is no property with the name '_root.volumeBarPlaceholder'";

View 2 Replies

ActionScript 3.0 :: Reference The Stage From A Class?

Sep 13, 2010

How do I reference the stage from a class? I need to add eventlisteners to the stage for mouse movement. I also need to add custom cursors. I always get an error when I try to reference stage. anything. Or event if I do this:

[Code]...

View 20 Replies

ActionScript 3.0 :: Reference Objects On Stage?

Oct 9, 2010

How can i reference objects on stage so i can push them into an array using a loop?[code]...

View 2 Replies

ActionScript 3.0 :: Reference Stage From Within A Subclass?

Aug 9, 2011

I'm playing around with some classes from my Learning AS 3.0 book in an attempt to understand them. I have a main (document) class, and a class called NavigationBarXML.

Because the buttons for the nav bar are all set up in the subclass NavigationBarXML, I would like to position the nav bar relative to the stage (think btn1.x = stage.stagewidth - 50) from within this class. I understand that you cannot deal directly with the stage from a subclass and that you must add it to the display list before you can reference the stage from within this class.

How would I set up the main class so that I can reference the stage from my subclass so that on browser resize, my nav bar is positioned relative to the stage?

View 9 Replies

Reference An Object Itself?

May 5, 2010

I want to print the content of the label property in the Alert window.[code]...

But the Alert window is completely empty. What am I doing wrong ?

I guess the keyword "this" is referencing the application instead of the LinkButton, right ?How can I reference the LinkButton itself, without having to add an ID to all my linkButtons?

View 1 Replies

ActionScript 3.0 :: Stage Reference In Static Class?

Feb 17, 2009

I have a static utility class that must have a reference to the stage, and I'm not sure what is the best option for me to get the stage inside my class...

I've thought of these options:Pass in as a parameter of the function Have a static variable I can set to the stage I don't like either of these because they are ugly.

What methods can you suggest for me to get a reference to the stage in my static class?

View 8 Replies

ActionScript 3.0 :: Error - Stage Is Null Reference

Jul 4, 2009

from my documentclass  i got a isntance of the my view class in there i got a instance of navigation class extends Sprite I got a utilz.as file with all static public functions like this one
 
alignToCenter(obj:DisplayObject):vid
{
obj.x = obj.stage.stageWidth/2;

Utilz.alignToCenter(instance of navigation class)
 
I get a error stage is null reference..

View 7 Replies

ActionScript 3.0 :: Reference An Array From A Stage In Class?

Nov 4, 2009

Ive got two classes and my stage. I'm trying to use an array to keep control of my enemy class's number for collision purposes and I managed to get the enemies to populate the array.

View 3 Replies

ActionScript 3.0 :: Reference To Stage Inside Class?

Nov 5, 2009

In simple example, I have a class called RedSquare that extends a Sprite. I need to have it in a central position of the stage. I do not know if importing definition of Stage class to RedSquare changes anything, but in the constructor of the class i could write [code]...

View 2 Replies

ActionScript 3.0 :: Dynamic Reference To On Stage MovieClip

Sep 30, 2010

I have 9 MovieClips on stage (p1, p2, p3...), different colors and sizes. I have one AS3 class "Snake" that as an instance is supposed to duplicate one of these MC's as a Shape. The reference to the specific MC is supposed to be on the constructor method. These instances are supposed to be triggered from one global Enter.FRAME event. How can I refer a distinct MC from within a class? I ask this because this MC will be dynamic and its properties ever-changing (position and color). I know this can be solved by adding distinct Enter.FRAME listeners per instance, but I'd rather avoid bad practices.

ActionScript Code:
public function Snake(id:MovieClip) {
body = new Array();
head=new Point(id.x, id.y);
size = id.width;
color = getColor(); // need to have a class variable that refers to the index
[Code] .....

View 1 Replies

Actionscript 3.0 :: Reference Movieclip Instance On Stage?

Nov 21, 2010

1) I have a movieclip instance on stage (simple graphical element that represents platforms for a hero to run and jump along). I have placed it on the stage with an external class engine.as and in this class it is called myPlatform and is an object of Platforms.as. The movieClip is called platforms and from a trace(myPlatform.name) the instance name is instance3.

2) I am attempting to access the properties of myPlatform in an Enterframe event loop in my character control and collision class (called hero.as)Basically here is the bit of code I am trying implement within Hero.as :

if (myPlatform.hitTestPoint(x,y,true)) { // if a platform is hit
trace("hitME");
y--;
tGravity = 0; // reset
break;
}

Here's the error that I get:

1120: Access of undefined property myPlatform

This all worked when I was writing actionscipt within the FLA file, on the timeline frame 1.I simply don't know how to access myPlatform from within the external Hero.as class! Do I need to create a variable?

View 1 Replies

ActionScript 2.0 :: RemoveMovieClip - Reference Still Visible On Stage

Aug 22, 2008

I have an array of MovieClips, when I try and use .removeMovieClip on one of the array items it removes reference to the MovieClip Object but it is still visible on the stage. When I address the MovieClip directly and use removeMovieClip on that it removes references and deletes from the stage.

i.e.
Scenario 1:
myArray = new Array();
myArray.push(myMovieClip);
myArray[0].removeMovieClip();
trace(myArray[0]);
trace(myMovieClip);
Traces out undefined, undefined but the movieClip is still visible on stage (and can still interact with).

Scenario2:
myArray = new Array();
myArray.push(myMovieClip);
myMovieClip.removeMovieClip();
trace(myArray[0]);
trace(myMovieClip);
Trace out undefined, undefined and the movieClip is removed from stage

View 3 Replies

ActionScript 3.0 :: Reference The Stage From A Custom Class

Feb 6, 2009

I have created a custom class that extends the movie clip on frame 1 of the main timeline I create it var mainBox2:mainBox = new mainBox(); addChild(mainBox2); Now as I understand it you have to cast the parent as a MC so in the constructor of my external class I try this var myStage:MovieClip = MovieClip(this.parent); trace (myStage); I get null. What am I doing wrong?

View 1 Replies

ActionScript 3.0 :: Cannot Visit Stage Attribute Before Display Object Added To Stage

Oct 22, 2009

I have a library swf (asset.swf), it's document class binded to Asset.as, and in the Constructor function of Asset,[code]as known to all, we cannot visit the stage attribute before the display object added to the stage.so, when my loader.swf try to load asset.swf, it throws exception and the loading come to failure is there some one tell me how to load the asset.swf? I cannot modify the asset.swf.

View 0 Replies

Actionscript 3 :: Get An XML Object Reference Instead Of Value In It?

Nov 4, 2010

I need to get a pointer to a piece of XML. I can get a pointer to the parent node and everything works but trying to get a pointer to a node that has no children just returns the value of that node.[code]...

Tracing subNode would be just the value and there is no pointer to the original xml object, so editing the subNode var would only change its value, not the one in the original XML object.

How do I get a pointer to the subNode so it can be edited to change the original xml object?

View 2 Replies

Flash :: Loading External SWF W/ Stage Reference In Class

Nov 17, 2011

I'm unable to load forces.swf (assume I can't edit it, as I don't have the source code) through an external swf, due to Stage reference in the base class how would I go about loading it (and any other possible SWF) without errors being thrown?

Here is a link to the problem I am trying to fix:[URL]..

View 1 Replies

Actionscript 3 :: Reference MovieClip After It Is Added To Stage As A Child

Nov 22, 2011

I am currently having problems referencing a MovieClip child which I add to the Stage from the Document Class. Basically when the MovieClip child is added to the Stage from the Document Class, I want a certain MovieClip already on the Stage to reference it once it is on the Stage.

Also, if it is possible, I don't want the MovieClip referencing the child being added to the Stage to have parameters linking it with the Document Class, because I plan on nesting this MovieClip within another MovieClip later on in the future.

Here is the code for the MovieClip class which is referencing the child once it is added to the Stage:

package com.gameEngine.assetHolders
{
import com.gameEngine.documentClass.*;
import com.gameEngine.assetHolders.*;

[Code].....

View 2 Replies







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