ActionScript 3.0 :: Referencing Stage Objects From Within Class

Sep 3, 2009

How to access stage elements from within a class.
buttonControls.as

Code:
package {
import flash.display.Sprite;
public class buttonControls extends Sprite {
// Navigation Hover Color
var hover = "0xF1E960";
var normal = "0xFFFFFF";
public function changeColor(object, color){
[Code] .....

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Referencing Class Objects From Class?

Jun 19, 2010

I have an enemy on the stage that reads whether it's being hit by a bullet by a hittest. There's a for loop inside the enemy's class that looks for all the bullets and names the bullet that's hitting it "hitBullet". What I'd like to do have an easy way of seeing what type of bullet is hitting the enemy. I'm basically looking for something like

if (hitBullet == RegBullet) {
//do regular bullet dying
}else if (hitBullet == ClusterBullet) {
//do clusterbullet dying
}

, where RegBullet and ClusterBullet are classes. But I have no idea what hitBullet is equal to when a ClusterBullet or RegBullet hits it. I traced hitBullet to see what it would return and got "[object ClusterBullet]", but I'm not sure what that would be in the actual code.

View 2 Replies

ActionScript 3.0 :: Referencing Stage.stageWidth From A Class

Jan 7, 2009

I created a custom class in a .as file. I then linked this custom class with a symbol from the library in my .fla file. However, I can't reference stage.stageWidth in my custom class file. I get a null object error.

I think this happens because the custom class file is associated with a symbol on the stage and not the stage itself. For example, if I set the fla file's Document Class to the name of my custom class I can reference stage.stageWidth in the custom class. But I don't do this because I am creating multiple instances of the symbol on the stage. In order to do that properly i found I have to set the class in the properties panel of the symbol to the underlying class which then defines how each symbol behaves.

Under this type of linkage, is there a way to reference the stage width from the class? I've tried root.stage.stageWidth and parent.stage.stageWidth to no avail. I also made sure to import flash.display.* in my custom class. Below is the code for my .fla file and my .as file. In the .as file you'll see the line "x = Math.random() * stage.stageWidth;". This is the line giving me problems. I could hard code it, as I do for the y variable on the next line, but I'd prefer not to in order to keep the code flexible.

[Code]....

View 3 Replies

ActionScript 3.0 :: Referencing Stage From External Class

Feb 14, 2009

I'm having problems referencing the stage from an external class. I've tried :
Code:
stage.addEventListener(MouseEvent.MOUSE_UP, onUp, false,0,true);
And also
Code:
MovieClip(parent).addEventListener(MouseEvent.MOUSE_DOWN, onDown, false,0,true);
But no luck. Can I not do this? I'm making a pencil class that I want to be able to reuse. I also tried "this" and while it didn't throw and error, it didn't work either.

View 9 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 Object On Stage From An External Class?

Sep 6, 2011

I have a media player that I am codging together, one that will play either videos or MP3s depending on the variables it is passed. The video player part works fine. The MP3 player controls are all actual physical MCs on the stage; each one has its own AS class file as part of the package, but there is also a lot of AS that is happening in the main FLA as well. Messy, I know, but it mostly works great.

The MC on the stage in the main FLA is properly linked to the class file via Actionscript linkage, and the control itself works. However, I am trying to make some aspects of the control respond to variables that are set within the AS on the timeline of the main FLA, and I cannot seem to pass values to the control no matter what I do.

[Code]....

View 2 Replies

ActionScript 3.0 :: Flash Referencing Object On Stage From An External Class?

Sep 6, 2011

I have a media player that I am codging together, one that will play either videos or MP3s depending on the variables it is passed. The video player part works fine. The MP3 player controls are all actual physical MCs on the stage; each one has its own AS class file as part of the package, but there is also a lot of AS that is happening in the main FLA as well. Messy, I know, but it mostly works great.The MC on the stage in the main FLA is properly linked to the class file via Actionscript linkage, and the control itself worksHowever, I am trying to make some aspects of the control respond to variables that are set within the AS on the timeline of the main FLA, and I cannot seem to pass values to the control no matter what I do.The following variable is set in the main AS:Code:var notPlayedYet:Boolean = true;I also have some flashVars being passed in from the html, and these I can reference with no trouble from the main AS - the relevant one is:

View 1 Replies

ActionScript 3.0 :: Referencing Stage Within Custom "Global" Class

Jan 25, 2010

I haven't gotten a handle on coding classes and the appropriate syntax with all the "public" "private" "static" keywords, etc. Anyway, one thing I miss in AS3.0 is having "out-of-the-box" global variables and functions. I've read a lot of forums and articles about making a simple "MyGlobal" class that could hold variables and functions which could be called from the timeline as "MyGlobal.doSomething()" However, I seem to be running into a problem trying to reference "stage" from within one of the global functions... I imagine this is because "stage" is an instance property. I'm basically trying to add/remove an event listener to the stage whenever the global function "MyFunction" is called.

MyGlobal.as:

[Code].....

View 7 Replies

ActionScript 3.0 :: Access Stage Objects From Class

Feb 24, 2010

I'm trying to access a MovieClip created within the authoring tool from an ActionScript class. Here is my code:

PHP Code:

package {
import flash.display.*;
public class MoreVideos extends Sprite {

[Code].....

I also tried changing that to [stage.moreVideosBox.visible = false;], but I then got "1119: Access of possibly undefined property moreVideosBox through a reference with static type flash.display:Stage."

Is it possible to directly alter items in the authoring tool from a class? If I move 'moreVideosBox.visible = false;' outside of the class, in the main .as file, it works fine.

View 3 Replies

ActionScript 3.0 :: Access Objects On Stage From Within Class?

Mar 3, 2011

i have textfield myTxt on stage, and i have Room.as class file.

Actionscript Code:
package  { public class Room {  public function Room() { // constructor code myTxt.text = "yo!"; }

I need to access objects on stage from within class.

View 3 Replies

Actionscript 3 :: Controlling Objects Of Another Class That Are Already On The Stage

Mar 3, 2011

Let's say that I've a button object (instance of Flip) and a coin object (instance of Coin) on the stage. The coin object has two frames: one showing Heads and one for Tails.

MyCoin class is as following:

package
{
import flash.display.MovieClip;
public class Coin extends MovieClip

[Code]....

Problem: How do I reach the coin object on the screen via onMouseClick function? Let's say that the object on the stage has instance name of myCoin. I suppose that had I not done this with an external class and simply used actions from the frame I could just use the instance name as a variable. I couldn't figure to do the same it in an external class. Do I first create the object which is already on the stage?

View 1 Replies

ActionScript 3.0 :: Retrieve All Objects On Stage From Class?

Sep 22, 2010

Let say I have 3 objects of the MoveObject class. There is 1 symbol in the library linked to the MoveObject class. I dragged the symbol to the stage 3 times. Great.

If I type trace(this.x) in the class files it gives me the x value of all 3 objects.

My question is, how do I go through those x values one at a time?

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

Flash :: Call Stage Objects From A Non Document Class?

Sep 1, 2010

I'm trying to manipulate (in this particular case add eventListeners) objects (in this case some MovieClips) on the stage from a class that isn't the document class.

1120: Access of undefined property trans.

Now I know that it's probably a scope thing and I probably can't access stage objects directly from a non document class (as I'm doing in the code below) but I can't figure out how to access them properly.

Anyway, here's the deal:

I've got 3 dynamic text fields (called "NL", "FR" and "EN") on my stage in a movieclip called "trans". I'm trying to add eventlisteners in a second class to make them do something when clicked on.

Here's my document class:

package {
import flash.display.MovieClip;
// Import custom classes.

[Code].....

View 3 Replies

ActionScript 2.0 :: Using Class To Display Objects From Library To Stage?

Feb 27, 2011

I am using CS3. And this is all about understanding Identifier and Class from the symbol property under Linkage.

I read some articles where all are using class instead of attachMovie() method on TimeLine.

Its confusing to me and couldn't able to make it work.

The article I read says that attachMovie() method will be in class file.

View 9 Replies

ActionScript 3.0 :: Inherited Class Does Not Want To Access The Objects On The Stage?

Mar 24, 2010

I made a document class for a project that is similar to this:

package{
public class test1{
// stage assets : these are all objects that were put on the stage in CS4
public var object1:MovieClip;

[Code].....

It seems the inherited class does not want to access the objects on the stage. Is this correct?

View 8 Replies

ActionScript 3.0 :: Reference Objects On Stage / Frame From Document Class

Jun 8, 2011

I'm trying to reference objects on the stage in the current frame from a document class in Actionscript 3 in Flash CS3. In this example, I'm trying to get at a dynamic text field with the instance name "question_txt", but there are also buttons and other things I'll need to get at to put event listeners on and such.

I have "Automatically Declare Stage Instances" checked in the publish settings, so the references should be there -- in fact, if I try to declare them in the class, I get errors about a conflict with the name -- but when I try to reference these objects (in any of several ways I've now tried!) I always get Null.

package {
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.display.Stage;
import flash.text.TextField;
import flash.net.navigateToURL;
[Code] .....

View 3 Replies

ActionScript 3.0 :: X And Y Objects - WORLD Is The Rival Class Being Repositioned On The Stage?

Jun 28, 2010

I didn't make these, they are just examples...

[Code]....

How in the WORLD is the rival class being repositioned on the stage? It does NOT inherret any other class, yet it still uses the "x" and "y" variables, and it looks like they are used the same way the regular ones are used.

View 1 Replies

ActionScript 3.0 :: Flash - Accessing Stage Objects From Class File?

Mar 11, 2011

i have an issue in accessing stage objects from class files.Here is my code

package
{
import flash.display.MovieClip;

[code].....

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 2.0 :: Referencing Objects Not On Same Layer

Jul 15, 2011

Is it possible to control an object/element on a instance? If so, how is it done through actionscript?

There is an instance "instance140" off of the root, that has an element named img4 that i need to reference... does anyone know how I would go about that?

View 1 Replies

ActionScript 3.0 :: Referencing Objects In Array?

Feb 25, 2010

I've created a for loop to do the following:add instances of button MovieClip from library to stagename the instances via name propertyadd instance names to array for later referenceadd event listenershese 4 steps are working peachy, however, I'm having troubles referencing these instances later on through my code. I'm pretty sure that the problem is in my data types not matching, but I'm not sure how to fix it.

var menuBtn:mc_menuBtn;var menuBtnList:Array = new Array();
for(var b:int = 0; b < numFiles; b++){  //add instances to stage  menuBtn = new mc_menuBtn();  testClip.addChild(menuBtn); //adding button instances to

[code].....

View 5 Replies

ActionScript 3.0 :: Referencing Objects In Captivate?

Jul 6, 2009

I need to be able to dynamically position a component generated in Captivate 4 via ActionScript that in child SWF that is imported into the Captivate project. The problem is that I don't know how to reference the objects in the parent movie. I can set a label on the object and reference the parent itself with:

MovieClip(this.parent)

but this doesn't seem to work:

MovieClip(this.parent).label.y

And I suspect that it is because some how Captivate subclasses the objects but I'm having trouble finding out how the hierarchy is structured.

View 2 Replies

ActionScript 2.0 :: Referencing Objects By Variable Name

Jan 11, 2007

I have a simple function that dynamically creates text fields. My text field name is referenced by var thisTextField. Problem is, when I try to do things with my text field, actionscript shoots back an error as such: There is no property with the name 'text'. How am I supposed to apply properties to my object if my objects name is a variable?

Code:
function showProducts() {
var products:Number = 0;
var thisTextField:String = "product" + products + "_txt";
for (var itemID in _global.rtsData[_global.rtsPos]["products"]) {
[Code] .....

View 2 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 2.0 :: Referencing Objects From Inside A Function?

Jun 18, 2011

I understand this, _parent keywords and its usage but I don't understand the following:

MovieClip.prototype.move = function() {
function toRight() {
this._x=50;

[code].....

View 3 Replies

ActionScript 3.0 :: Referencing Objects That Are Not Present On Frame 1 Of A Movieclip

Apr 20, 2010

I'm working with a movieclip right now that has two frames in it. I want the user to be able to go back and forth between the pages by clicking on tabs on either page. The button that they click on is only present on the frame that it is applicable (so, the button to switch to frame 2 is only present on frame 1, and vice versa).

I want to control when they are able to click back and forth, and be able to turn the buttons on and off whenever I need to, but since the button to switch back to frame 1 is only on frame 2, when I reference it from the main timeline, the button registers as a null object. How do I refrence an object that is not present on the first frame of a clip?

[Code]....

View 3 Replies

ActionScript 3.0 :: Referencing Variables/objects From External FLA Files?

Dec 1, 2010

I am trying to display in 'Reciever.swf' the value a shared object updated in 'TextSO.swf'. The following is my code for the Reciever

Reciever.as-----------------
package {
import flash.events.SyncEvent; import flash.events.NetStatusEvent; import flash.events.MouseEvent; import flash.net.SharedObject; import

[Code]....

I am getting an error that says that 'text_so' is an undefined property and that I can't access it. Yes, I have not declared 'text_so' in 'Reciever.as'. However it is the shared object instance from the 'Text_SO.as' file. How do I reference it from the 'Reciever.as' so that I won't get this error anymore?

View 1 Replies

ActionScript 3.0 :: Referencing Objects In The Level Above The Movie Clip?

Sep 10, 2011

i want to referance objects in the level above the movie clip that i have the AS in.  what i mean is that i have a movie clip on the stage, and that movie clip has some actionscript in it, and that AS needs to refer to an object on the main stage, how would i do that?  i have tried parent and stage 1, but neither seem to work

View 4 Replies

ActionScript 3.0 :: Referencing Variables / Objects From External FLA Files?

Dec 1, 2010

I am trying to display in 'Reciever.swf' the value a shared object updated in 'TextSO.swf' . The following is my code for the Reciever[code].,...

I am getting an error that says that 'text_so' is an undefined property and that I can't access it. Yes, I have not declared 'text_so' in 'Reciever.as'. However it is the shared object instance from the 'Text_SO.as' file. How do I reference it from the 'Reciever.as' so that I won't get this error anymore?

View 4 Replies







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