ActionScript 3.0 :: Accessing Properties Of The Stage From A Class?

Aug 29, 2009

I am trying to access the x and y properties of the stage so I can set an objects' x and y properties to place it on the center of the stage:

this.x=stage.stageWidth/2;
this.y=stage.stageHeight/2;
The call to instantiate the object(*.fla):

[code]......

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Accessing Properties From Stage In A Class?

Feb 28, 2012

I am trying to access a property that belongs to the stage, from a class. For example, let's say I add a textfield with an instance name of "magic_txt" on the stage. In the Document Class, I am able to access magic_txt and update the field like so:

magic_txt.text = "Magic Text"

However, since I would like to work in classes, I am having a difficult time figuring out how to access the property "magic_txt.text" from a class. I know I need a reference, but I am unsure how to set this reference.

I am coming from a strong background in Visual Basic, and in Visual Basic, the way to access a form property is to call the form name (dot) object. In actionscript, it doesn't seem to be as simple.

View 9 Replies

ActionScript 3.0 :: Accessing Properties Of A Member Of A Class From Within The Class?

Jun 9, 2011

I have a class, call it MyClass, and there are several variables that I need to be able to access each instance of from within the class.So for instance, I need the object myObject1, a member of MyClass, to store the variable myNumber.From the main timeline, if I trace myObject1.myNumber, I get whatever number I've stored.
 
However, I need to check the numbers against another parameter, so I need to be able to test if myObject.myNumber == myOtherNumber. But from within the class, if I trace this.myNumber or myNumber I get null.What is the proper syntax for accessing a variable within a class?

View 5 Replies

ActionScript 3.0 :: Inheritance - Accessing The Properties Of A Class From Another Class

Oct 12, 2011

I'm pretty new to fully using class's for my programming (in-frame scripting satisfied me for a while). I am having a problem accessing the properties of a class from another class. The first class (I'll call it controller) receives a reference to an object of another class (I'll call it display). Display have several specialized subclass (I'll call one SequencedDisplay). SequencedDisplay has a timer in it that I need to access:

[Code]...

View 2 Replies

ActionScript 3.0 :: Accessing Another Class's Properties From A Different One?

Jul 1, 2009

I have two movie clips on the stage at frame 1 and frame 2. Both are instances of seperate classes. (They are not dynamically created, just their linkage is set to their class names)I have created soundChannel and Sound Objects in Class 1 and I want to access them from Class 2. (I want to stop the sound channel that was started in class 1)Is there any way to do this? If yes, will this be true for other properties also?

View 7 Replies

ActionScript 3.0 :: Accessing Properties Of The Document Class?

Nov 14, 2009

when I try to access a property of the document class from another class, I get an error:

Quote:

1119: Access of possibly undefined property _left through a reference with static type flash.displayisplayObject.

Maybe I'm not doing it correctly? This is how I've been accessing document class properties so far. Does the fact that they're private make a difference?

Quote:

root.property

View 1 Replies

ActionScript 3.0 :: Document Class, And Accessing Properties?

May 25, 2009

I'm currently working on an interactive app, (site) which requires me to modify a few textfields, and change images dependant on the user choice (using mouseevent). This is a separate module, thus I'm posting the question in here instead:there are three images, that are lined up, with a textbox next to them. When a image is chosen, and enlarges, the text changes with the chosen image, according to XML.The textFields, 'text_title', 'text_description' are contained in a movieclip, called 'textbox'.This has been built in the Flash IDE (CS3) named info.fla/swf, which refers to a Document class 'com.info', made in Flex Builder 3...I attempted to modify the textfields using this:textbox.txt_title.text = "Loading";textbox.txt_desc.text = "test";But, I was unable to at first to change the text using the document class, as it gives "1120: Access of undefined property <variable>".

View 3 Replies

ActionScript 2.0 :: Accessing (Nested) Component Properties From Class

Jul 29, 2009

(Actionscript 2 btw - and actually cs4, not that it really makes any difference?) I have a class that instantiates a movieclip from the library, e.g.:
Code:
debugbar:MovieClip = thing.AttachMovie("debugbar", "debugbar_mc", 999);
So attaching it to the where ever "thing" is - could be movie clip or level0 or whatever, doesn't matter as "debugbar" is a private variable of the class. Now the important part - debugbar in the library is a movieclip that contains some components - buttons and textInputs. The problem comes when trying to access these components.

I would have thought that this would work:
Code:
debugbar.input_txt.text = "hello";
In order to set the text of "input_txt", the instance name of a TextInput component on the timeline of the movie clip (put there in author time). However, this does not work. Infact, I cannot access any specific "component" properties - they come back undefined. I can however set and retrieve MovieClip properties for the "input_txt", such as _x. However there is one added strange thing with this too - setting _visible to false doesn't seem to work (however perhaps a component by default overrides this).

I also appear not to be able to add event handlers to the component - at least for the usual component events. I tried casting it to a component, such as:
Code:
var temp:TextInput = TextInput(debugbar.input_txt);
trace(temp);
which gave "temp" as null.
However if you trace the thing itself without casting to what it is, it gives the path to correctly. It almost seems like the components are somehow broken when trying to access them this way - or that they cannot be accessed this way?

The thing is, I was able to access all of this before, when the code to do it was placed on the timeline (frame 1, the only frame) of the debugbar itself, where the components were child instances. This meant I could just reference them directly too - so input_txt rather than debugbar.input_txt , although that is probably largely irrelevant. I need to have it in a class though, as I need to pass in certain objects that need to be accessed by the mc.

View 2 Replies

Actionscript 3 :: Stage Properties In Custom Class, Not Document Class?

Oct 14, 2011

I need to use stage.width/height in my CustomClass so I found some topics about it.

if (stage)
{
init(ar,firma,kontakt,oferta,naglowek,tekst,dane);

[code]......

View 1 Replies

ActionScript 3.0 :: Accessing An Object Drawn On The Stage In One Class From Another Class

Jan 6, 2011

I have created a class, call it Class1, that has various objects drawn on the stage (drawn in the IDE). It also has a function, called setColour, for changing the colour of those objects. The function works fine if I call it from within Class1.

Now I have another class, call it testClass1, that imports Class1 and calls the setColour function. First of all, none of the stage objects from Class1 are visible. Secondly, when setColour tries to modify the colour of an object, I get the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.

This is the code for testClass1:

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

[Code].....

So, what is the problem? Is it possible to change objects that are drawn on the stage of an imported class?

View 3 Replies

ActionScript 3.0 :: Accessing The Stage From A Class Which Isn't The Document Class?

Jul 3, 2009

I'm being really dumb today and I know this should be simple.....How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width? So I've written.....

ActionScript Code:
var myTweenX:Tween = new Tween(this, "x", Regular.easeOut, this.x, stage.stageWidth, 60, true);

[code].....

View 4 Replies

Accessing Stage From A Class Which Isn't The Document Class?

Jul 3, 2009

How do i access the stage from a class which isn't the Document Class? For instance, I want to create a tween which takes in the parameters of the stage's width?[code]

View 8 Replies

ActionScript 3 :: How To Access Stage Properties In Custom Class

Jul 26, 2009

How do I access Stage Class properties in Custom Class?
Class:
package {
import Main;
import flash.events.*;
import flash.display.Sprite;
import flash.display.Stage;
public class Run extends Sprite {
[Code] ....

Output:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

View 3 Replies

ActionScript 3.0 :: Accessing MC On Stage From A Class?

Apr 8, 2009

I seem to have a problem with accessing MC on stage. For example, if in my class I try to do something like this:
 
back_next_nav.alpha = .3;
 
I get the error: 1120: Access of undefined property back_next_nav.

View 1 Replies

Accessing A Stage Instance From A Class Other The Document?

Dec 19, 2010

I have a main document class with another class instanciated (mouse follower.as) within it. I want the mouse follower class to access a stage instance. How is this done?

View 1 Replies

ActionScript 3.0 :: Accessing A Stage MC From An External Class?

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

Flash :: Accessing Buttons On Stage From Class?

Feb 7, 2012

I need to set properties of buttons on the main stage from the current class. How would I do this?

I have multiple buttons on my stage. Each representing a chapter in a movie (from frame x to frame y of the movie).

When I push one of them, the movie plays. When it gets to the end, it should continue to the next segment/chapter. This works, but now I need to highlight the current button, not let the button I pressed be highlighted forever..

View 1 Replies

ActionScript 3.0 :: Accessing An Instance On Stage From Within Another Class?

Jun 14, 2007

access one instance of a MovieClip on the stage (blue_mc) from within the class file of another MovieClip (red_mc).e.g. One instance of "Blue" on the stage called "blue_mc", and one instance of "Red" on the stage called "red_mc". Both symbols are linked to class files (Blue.as and Red.as).In Red.as, I set up a function to listen for a mouse down event. When this is triggered, I want to move the instance blue_mc. At the moment, though, I can't seem to get a reference to blue_mc.I've looked into the new stage and root properties, but even though blue_mc is on the stage, it cannot be accessed using stage.getChildByName( "blue_mc" ) either.

Code for Red.as:

Code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;

[code]....

View 6 Replies

ActionScript 3.0 :: Accessing Stage From External Class

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

ActionScript 3.0 :: Accessing A Stage Resize Within A Class

Mar 3, 2009

I have a class and the class must adapt itself whenever the stage resizes.

Now something could look like this, but it won't work:

Code:
package {
import flash.events.Event;
public class ResizeClass {

[Code]....

View 3 Replies

ActionScript 3.0 :: Accessing MovieClip On Stage From Class

Apr 11, 2009

1.I have a MovieClip in the Library. There is a named and dynamic text box in the MovieClip. In Frame 1 of the .fla, I construct the MovieClip from the class StatusBoard and add it to the stage. There is one setStatus method in the class to set the text. This works fine.[code]

2.I have a bunch of buttons that I created from a class called LinkButton.as (they are MovieClips, not _btn buttons). FWIW, they are attached to other MovieClips, but they work fine. The trace output is fine. What I am trying to do is have the rollover change the text in the billboard.[code]

3. In lay terms, I used addChild to add a MovieClip with a dynamic TextField to the stagw and I want MovieClip buttons created from an .as class to be able to change the text on a rollover.What I can't seem to do is actually reference the billboard that I added using addChild from the .fla.The buttons work and trace the desired text, I can't seem to send that text to the billboard.

View 2 Replies

ActionScript 3.0 :: Accessing Stage Objects With In A Class

Aug 20, 2009

I am trying to learn how classes can interact with each other and I came across a problem I can't solve. On my stage I have a MovieClip called "myMovieClip".

[Code]...

View 14 Replies

ActionScript 3.0 :: Accessing A Checkbox On Stage From A Class

Apr 30, 2010

I have drawn a box on stage and turned it into a movieclip called sidePanel, within it I place a checkbox. My document class 'Main.as', ie the class called upon by the flash file, creates a class of name Class1. So we have .FLA (The Stage) -> Main.as -> Class1.as Now from the Class1.as How to get the checkbox status, ie checked or not, from within my class1.as ?

View 3 Replies

ActionScript 3.0 :: Accessing Movie Clip In Stage From Class

Nov 14, 2010

I have a movieclip in stage with instance name 'ts'.

I have a class Test.as

How should i refer to MovieClip 'ts' in stage from my Test class. Say for example I want 'ts' to gotoandstop at frame2.I tried root.ts but received a error.

View 4 Replies

ActionScript 3.0 :: Accessing MovieClip From Flash Stage In Class

Jan 10, 2011

What is the best way to accessing movieClip from a flash stage in AS3 Class? And what if the as3 class it's in a package, outside the Document Class?

View 4 Replies

ActionScript 3.0 :: Accessing Display Object On Stage From Another Class

Jun 8, 2011

I've googled this to no avail, I've only found how to manipulate the stage itself and not a display object on it,I have a movie clip on the main timeline with instance name displayName. I created a button that should change what frame displayName goes to (in order to...did you guess it?! diplay the Name of the button.So I am trying to write the code in a reusable fashion and have the buttons all linked to a class called GeoPuzzle. Inside GeoPuzzle I instantiate a touch event and run the code. However, the function has to be able to change displayName in the main part of the timeline and, of course, the compiler says displayName doesn't exist because I'm in a class and I'm talking about the stage.[code]How can I tell displayName to change it's current frame from within display object class?

View 9 Replies

ActionScript 3.0 :: Accessing Property Placed On Stage Using External Class?

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

ActionScript 3.0 :: Accessing Movie Clip In Stage From Class?

Nov 14, 2010

Iam new to actionscript 3.0. I have a movieclip in stage with instance name 'ts'.

I have a class Test.as How should i refer to MovieClip 'ts' in stage from my Test class. Say for example I want 'ts' to gotoandstop at frame2.I tried root.ts but received a error.

View 1 Replies

ActionScript 3.0 :: Accessing Stage From Function In Document Class

Dec 10, 2010

How do you access the stage from a function in a document class file? I tried a fairly simple:
ActionScript Code:
var main:MovieClip = new MovieClip();
addChild(main)
var _stage:Stage = main.stage;
trace(_stage);
The result was null.

View 5 Replies

ActionScript 2.0 :: Accessing Elements On The Stage From A Linked Class

Nov 28, 2007

I'm trying to link a clip to a class, and it goes well until I try to access MovieClips or TextFields placed on the stage within that clip from code in the class. My code is below; there is a TextField called output_txt on the stage within this clip.

class Main extends MovieClip{
public function Main() {
//trace("123"); <--if I replace the line below with this, it traces nicely
output_txt.text = "123";
stop();
}
}

View 3 Replies







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