ActionScript 3.0 :: Accessing Variables From Other Classes
May 3, 2011
I am having this issue were I can not access any variables from any other class![code]Now, from my other variables, that is what I do, I don't understand what I am doing wrong?
View 5 Replies
Similar Posts:
May 25, 2009
I've got two classes running...one is a document class (EgoGame.as) and another is a class linked to several similar movie clips (Ball.as).I'm trying to access a public variable from Ball.as which has been declared in the doucment class EgoGame.as.When I run the test the outputs states the following...1120: Access of undefined property _ballPlaced.Here's my code. What I'm trying to do is remove the event listeners from the Ball.as when the _ballPlaced variable is true, so that the user can't drag and drop the balls after they've been placed in a zone.
Document ClassEgoGame.as
package
{
[code].....
View 3 Replies
Apr 9, 2010
I have a project that i'm working on, and in the project it's important that i have an object that i can create with actionscript that already has two arrays inside of it. To do this, i made the movieclip, i checked export for actionscript in the library, and in the custom class that corresponds to that object i made the arrays with the following code:
package {
import flash.display.*;
public class cont extends MovieClip {
[code]......
View 6 Replies
Sep 8, 2011
I've been working my way towards better OOP design lately and I've come across a problem with accessing functions in other classes from my Main class. Here is the code:
Main.as
ActionScript Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
stage.addEventListener(KeyboardEvent.KEY_DOWN, fireBullet);
They are listening for functions that are within the Player.as class, these functions control the dynamics/movement of the player itelf. But for some reason I'm getting a 1120 error(access of undefined property). Basically how do you listen/access for functions within a different class?
View 5 Replies
Jan 7, 2012
I want to access an object from a class in which it was not created in. I have a main class (A) in which I create and instantiate an object (of class B), from this class I can obviously do whatever I want with the object, no problem. The issue I'm having is another class (C) needs to access the object in question to change its x and y location values. Class C doesn't know what the instance of class B, created in class A, is; this doesn't surprise me, but I can't figure out how to allow class C to get access to what class A created.
View 7 Replies
Jun 22, 2009
I have 2 swfs, one is main and it loads other file "skin.swf". skin contains object of custom class SkinClass. I can access it from main swf, but when I try to cast that object, the result is null. This happens when I use absolute url, when I load skin from relative url, everything is ok.
View 3 Replies
Mar 31, 2012
I've recently started development on my first proper AS3 project and I�ve hit a sort of brick wall with my knowledge of how to make AS3 classes do what I want. I could do this in AS2 no problem with referencing the stage, but now that only the document class has access I'm stuck.I have instances of a MC called activity. These sit inside a container MC that is the source of a scroll pane (that sits on the stage).
When I click a button inside the Activity MC I need to generate a new MC and set that as the content of another scroll pane on the stage. I�ve tried several things, even gotten the stage passed to the activity MC class but it can't then be used to addChild to items on the stage just reference then (much to my aggravation). And I can�t set an event listener for the new activity�s button when it�s created as it throws a static display object error of some sort.What methods can I use to pass information from a MC class back to the stage so i can call a function or just paste a MC onto the stage? I'm at my wits end after about 10 hours of exhausting everything the internet seems to have to offer on the subject.
View 2 Replies
Sep 15, 2010
So I have a menu built inside of Flash CS4 that has a graphic for a background and five text fields that sit on it for menu options. The whole thing is saved as a movie clip in the library. The text fields all have instance names like infoBtn and mapBtn etc. and the menu is already on the stage and linked to it's own class in the library. My problem is accessing those text fields on the menu from the class. I keep getting "Error #1009: Cannot access a property or method of a null object reference." and the menu doesn't work. But if I trace the infoBtn.text in the class it outputs the text that is in the text field. So the code is accessing it but it's still not working?
Code:
package classes
{
import flash.display.*;
import flash.events.*;
[cODE].....
View 0 Replies
Aug 28, 2009
How do you access Library items from classes other than the document class?For example, if I create a movie clip in Flash and Export it for Actionscript with the name Foo, I can do this in the document class:
Code: Select allvar f = new Foo();
this.addChild(f);
And it appears on the stage, as it should. But I need to be able to create other instances of this object from other classes. If I use the same code above in SomeOtherClass.as, I get nothing on the stage, obviously because this class doesn't know about the Foo object in the library.
View 3 Replies
Sep 21, 2009
how to put actionscript classes into an MXML document? Lets say my class represents a movieclip, a rotating triangle for instance. How do i put that into a <mx:vbox> containter? I can do the AS work in a <mx:Script> tag, but how do i embed my class instance?
View 2 Replies
Apr 30, 2011
I have a document class which links to several classes, one of which adds a container onto the stage and loads external .swf's into it.Q: How do I access the various classes loaded in the document class from the external swf timeline?For instance, when you click a button in the loaded swf it changes the soundtrack from the soundtrack class. I have tried dispatchevent from the external swf timeline, but I still can't seem to get it to work. Is this supposed to work, or should I be doing something different?
View 1 Replies
Aug 30, 2006
I began with a class for a movie clip rollover function FigureRollOver. It works marvellously. Three things happen:
1) it loads XML from a file "mod1_fig1.xml" and uses another class, XMLMember, to retool the scoping of the XML so that I can get at it
2) an onload call inside of XMLMember calls the myOnLoad function and transfers the XML into an array.
3) so long as the array is finished building, rolling over a movie clip attaches a new movie clip with the rollover text in it.But I don't want all those functions in one because I need it to be more dynamic, starting with being able to load any old xml file instead of just "mod1_fig1.xml", plus it seems lik overbuilding to have all of that in one class, so I've separated out the loading of the XML and building of the array into its own class, FigureXMLLoader. FigureRollOver is then left to just attach the rollover with text in it, extracted from the array built by the new class.
Problem is, though the array builds inside FigureXMLLoader, I can't figure out how to make it available outside the class. I know that I'm constructing things in the wrong order, and that the array needs to be somehow built inside the class function to be available, but I can't figure out how to do that. A cruddy work-around is to put a function call at the end of the building of the array, which calls yet ANOTHER function on the main timeline of my .swf to put the array I've just built into a new variable.This works, but it's messy. It seems like I should be able to have one line of script in the .swf that generates an array on the main timeline (or just a public array) which I can then access from my FigureRollOver class:
var myRollOvers:Array = new FigureXMLLoader("mod1_fig1.xml");
Here is FigureXMLLoader (see comments in the code for more details) which obviously does not return an array as it is, because of all the working around I've had to do. Note the "testing" variable, which can be traced from the main timeline of the .swf, but I will get "not what I want" because of course the array hasn't been built yet, and never will be, inside of the declaration as it is. How do I get it in there so I can return an array?
View 2 Replies
Dec 26, 2006
i've got two classes and i'm not extending to MovieClip. I like to attach the mc in the constructor just because i'll be working with different MC's that have the same purpose.
however, im using private var loadedMC:Movieclip and now i've got another class that needs to be able to access the instance's variable.
for example, myClass.loadedMC , but this would mean having to make it public and I rather not go that route.
View 2 Replies
May 16, 2010
Imagine you have one main document class wherein you have some variables that make your objects move or roatate. Now, you make another class in which, for instance, you draw a rectangle (with the graphics class) and want the rectangle rotate in the same way your other objects on the stage rotate. You'd probably wish to access the variables from your main class, so as to asign their values to your rectangle rotation velocity. The question is: how to access those values? Is it even possible to share variabless across all the classes?
View 1 Replies
Sep 14, 2009
I have one .swf file inside a second .swf file. How do I have one .swf access variables from the second?
View 3 Replies
Apr 21, 2011
I have the following PHP file with a variable I am trying to access to place in a dynamic text box on my flash stage.
PHP code:
$returnVars = array();
$returnVars['username'] = "test";
$returnString = http_build_query($returnVars);
//send variables back to Flash
[code].....
The code was adapted from a tutorial using a class. However I do not get on with classes so wont be using any.
View 2 Replies
Jun 16, 2008
I have finally started with AS3 and flip-'eck its a different animal that AS2
I have a swf called login.swf and in it have declared the variables var total:uint=0; and loginState:Boolean=false
All my scripts for logging in sending/receiving variable from/to server scripts are all working!
So... when a user supplies a correct password another swf (userLogged.swf) is loaded (note: in AS3 this process is seriously different than in AS2) swf dont seem to be loaded 'into' another movieclip anymore... and this leads me to the puzzle!
How do I access variables declared in the project.swf, from within the userLogged.swf!
the old AS2 way = trace (_root.loginState);
or trace (_root.project.loginState)!
I am stumped by this new approach of AS3 of loading in other swf files. The _root. options is no longer available in AS3 (that much I've descovered, some tuts say use root. but I cannot get that to work)
trace (root.loginState)
or
var userLoggedIn=root.loginState
gives me the error
1119: Access of possibly undefined property loginStatus through a reference with static type flash.displayisplayObject.
when I try to publish the userLogged.swf
View 4 Replies
Aug 13, 2009
I am trying to set the variable to classes in the loader like this
loaded_swf.content.classname.code = "AS3";
But that wont work for some reason?
View 1 Replies
Sep 14, 2008
What I have is a list of videos (FLV) and when I click on avideo name (button) I want the menu page to close, open anotherpage (the video interface page) and play the video that was chosen.I do not want the video to play on the menu page but on it's owninterface page. I am guessing I will need to save the String namein an outside file for the video class to grab. Once the video hasfinished playing I want to go back to the menu page.
View 13 Replies
Aug 18, 2009
What I am trying to do is pull data from an XML file so that I can store paramaters for my FLV player (i.e. flv link, dimensions, video name, etc) I can get the data from the XML file and story it in a dictionary but I am unable to access the data from my main class. I know it has to be something pretty simple but I think i have been looking at it to long to see it.
// Main.as
package includes.action{ import fl.video.FLVPlayback; import flash.display.*; import flash.events.*; import flash.net.URLLoader; import flash.utils.Dictionary; import includes.action.XMLData; public class Main extends Sprite[code]..........
basically with all my traces this is what I get back...
// Trace dataVIDOEXML COUNT: undefinedELEMENTS: nullMAIN:LINK: nullWe are in LoadXMLname - no get: mortgagename - get: mortgage
The trace for Elements and Main:Link should give me back the name of the video but as of yet its either returning NULL or undefined.
View 3 Replies
Jan 14, 2011
I want to send the contents of a variable to a class where it can be used in its functions. Since I have no experience with object orientated programming what so ever I tried to break it down into real simple code so I can understand better what's going on and how I can implement it in my main code.I made a test file and a test class, basicly I just want to give a variable contents in my main code, then send the variable to the class so the class can trace it. But no matter how I try it i always get "Testoop.as, Line 6 1120: Access of undefined property test.Here is the code:
so this is the FLA:
import Testoop;
var test:String;
[code]....
View 2 Replies
Aug 19, 2009
I've done a search and all I could find are creating global variables through Classes.
Is there a way of creating them on the timeline? I have a preloader.swf that loads another swf to itself and would like to read the values off of the parent.
View 2 Replies
Aug 31, 2011
How to pass a variable from one AS class to another please?
View 4 Replies
Jan 12, 2012
I'm building a simple Pong-esque game and I've 'hit' a problem. I'm having an issue with referencing one variable from one class into another. Sounds confusing to me, even harder to understand.
Basically I've got this in my "game.as" class:
ActionScript Code:
public var pongBall:ball;
and in my "player1.as" class I am trying to get said ball to bounce off the player's bat on contact. I think I have the coding right for it apart from trying to link it to the ball from game.as! So far I have this:
ActionScript Code:
public function bounceTest (event:Event) {
if (this.hitTestObject("game.as".startGame.pongBall)) {
[Code]....
View 7 Replies
Feb 21, 2007
ActionScript Code:
class Vector2d extends Math {
private var x:Number;
[Code]....
I can't seem to get my private variable, x, to be private. From my understanding of private variables, tracing n.x should throw an error, and adding 150 should throw an error. I've tried changing the variable's name, and the cast type, to no avail. The first trace goes through, the addition goes through, and the second trace goes through.
I'm new to classes, so I could easily be overlooking something vital. But the vars need to be private, because I want to use get/set to update the variables when one or another changes. For instance, if 50 is added to the y value, the magnitude and unit vectors would change, so I want to update them using getMag and getUnit. That whole system would be thrown off if the user had direct access to the properties.
View 11 Replies
Mar 18, 2007
ive written a class to control my content panels on my site. They work well! Currently they controll all the positioning perfectly on there own. What I am having trouble with, is how do i pass variables into my classes. For instance, my main content panel, has variables in the class: public var contentState:Number; Now, what I would like to do, is have movieClips on my stage, or 'buttons' that will be able to change 'contentState' within my class.How do i go about passing these variables?[code]
View 1 Replies
Mar 23, 2010
I'm trying to create a oop flash website, but I'm really struggling with some basic things. Example 1: We've got four classes
DocumentClass -> FormsClass -> Form1Class -> ListClass
Let's say someone clicks a next button in the FormClass. That dispatches an event "nextForm". Documentclass is listening for this event, and displays the next page. But it needs to read a value (selected radiobutton) from the ListClass. What would be the best way to get this variable to the documentclass?
[Code]...
View 7 Replies
Jul 19, 2011
I need to know how to reference variables in other classes. I have been avoiding this by referencing variables from the Main class, where they are created. But at this point I would like to be able to have the option and it would make me a better programmer.
Say I create a movieclip in the Main.as
Code:
public var Enemy_mc:Enemy = new Enemy();
addChild(Enemy_mc);
[Code].....
How do I do that^ without creating a variable in Main.as and having it check Background.as for variable updates?
Can I do something like "Main.Enemy_mc += 5;" like I can do in Main.as to variables that I have created in Main in other classes?
View 2 Replies
Mar 8, 2010
I'm trying to access the AchievementScreen's textfield from a medal object. Point being to have a mouseover event of the medal, change the content of the textfield shown. I tried a trace first: trace(this.parent.parent.parent.parent.textLineCon tainer); 1119: Access of possibly undefined property textLineContainer through a reference with static type flash.displayisplayObjectContainer. trace(this.parent.parent.parent.parent) shows me it is a AchievementScreen object. textLineContainer is the instance name of the MC nesting the textfield (I actually drew the achievement screen then exported it to actionscript.
[Code]....
View 11 Replies
Jul 25, 2011
[Code]....
I want to use the variable var_page3_title for dynamic text boxes in movie clips further on down the timeline. Of course I don't want to repeat this code for every textbox so my question is, how to I access the variables from the function loading();
View 2 Replies