ActionScript 3.0 :: Access Variables Across Classes?
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
Similar Posts:
May 9, 2010
I'm working on a game. Yep. I have the main class where I control all the stuff that's packed in external classes. My current issue is that I listen for a mouse event to happen, and when the left button is pressed, I add a child to the stage.[code]...
However, I want to set all the stats of the bullet in an external class called "Rock". In the main class I just attach a movieclip to the stage, and the behavior of this MC is supposed to be controlled by the Rock class. The problem is I dont know how to access the bullet variable from the Rock class.
View 3 Replies
Jan 10, 2012
The system i am trying to make is structured like this: How can i acess the vars of the class var from the other classes?
View 4 Replies
Apr 16, 2010
I have a menu movieclip that has several buttons, each with listeners writtin in the movieclip's actions layer in Frame1. The script goes something like this:
[Code]...
View 1 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
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
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
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
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
Aug 12, 2010
I have an SWC of all my graphical assets. I'm using FlashDevelop as my IDE, and I have set the SWC as a path.I can import classes in the SWC just fine and the the intellisense works. But when I try to create a new instance of one of the assets, it seems to work, I can trace out the variable I assign it to, but when I try to add the actor to the stage it doesnt show up.
View 1 Replies
Feb 23, 2011
I'm trying to load a local SWF file and use the classes in that SWF (its a code only SWF, nothing in library).
Here's the code that loads the library:
Code:
var AD:ApplicationDomain = ApplicationDomain.currentDomain;
var context:LoaderContext = new LoaderContext(false, AD);
SA_gamecore_loader = new Loader();
[Code]....
ReferenceError: Error #1065: Variable MenuArt is not defined.
The GameCore.swf is in the same location as the parent swf.
View 1 Replies
Oct 1, 2009
If we have declared some variables on a particular frame, say frame 20 in the actionscript coding window, can we use these variables defined on a frame in a class? Is there something like a global variable which must be declared to do this?The class extends to movieClip and it has been encapsulated by a movieClip which is then put on the stage to run it when the corresponding frame plays.
View 2 Replies
Dec 1, 2010
I have this problem from time to time with AS3 where I extend a Class and then try call methods and variables which are public from the new class but I get errors that method or variable doesn't exist. My IDE recognises the methods and variables though.[code]When I run the script flash hates it. I thought when you extend a class it was supposed to inherit its properties and methods?Does anyone else have these problems? I shouldn't have to cast it as Box. I swear I have this working in a project but cant see the different in setup?
View 4 Replies
Oct 20, 2009
I was wondering if ActionScript had some way to call functions and classes from variables, like they do in PHP:
function funcname() {
print "Potatoes come from tree";
}
$function = "funcname";
print $function; // Prints out "funcname"
$$function(); // Prints out "Potatoes come from tree"
In case you don't know the syntax for PHP, you should know that anything perpended with a $-symbol is a variable.
View 1 Replies
Oct 27, 2010
m new to as3 & am trying to make a platform game. i'm just not sure how to define the objects & variables. like my character & any other object i want it to collide with will be sprites, but im not sure where to go from there.
View 2 Replies
Aug 11, 2009
I'm stuck in a project because I don't know how to communicate with other classes in another external swf? After I load the swf using the loader class how would I be able to access the classes loaded by the swf?
View 2 Replies
May 6, 2010
I'm making a little application in Actionscript 3. In my initApp.as I have created another class which needs to edit the currentState, which is only accessible from the main .as (initApp.as). I found a solution such that I can reach the currentState property from my other class: Application.application.currentState.This is however not a good solution as it couples the classes too much.. is there a better way of editing the currentState from other classes?
View 1 Replies
Feb 23, 2011
I'm trying to load a local SWF file and use the classes in that SWF (its a code only SWF, nothing in library).[code]And this is the message that's traced: ReferenceError: Error #1065: Variable MenuArt is not defined.The GameCore.swf is in the same location as the parent swf. I'm using Flash Develop if that helps.
View 1 Replies
Dec 13, 2011
I'm coding a small flash game, and wan't to access different functions between classes. In C# I'm used to just making it static, but I'm having some problems with it.Here goes:
Main.as
package
{
import Bus;[code].............
View 3 Replies
Jan 9, 2010
How to organize access to classes from the loaded swf?[code]...
View 1 Replies
Jan 9, 2012
I'm having some doubts about how to access some features of embedded files and loaded.
For example, I created a .fla and added a symbol to your library - a MovieClip with name and class circle. Then convert the .fla to .swf, thus becoming test.swf.[code]...
View 8 Replies
May 20, 2011
Have any of you guys attempted to embed a library SWF and access the classes as it was an externally loaded SWF? If so, how is it done? In an effort to make my game into a single SWF, I have no other option than to embed my external library SWF's, the simplest of which is just an SWF full of images in the library. My normal method is this
[Code]...
View 7 Replies
Sep 2, 2010
Long time ago I've been creating some as 2.0 projects, all of them based on the code within the timeline. I wanted to start learning as 3.0 based on classes rather on timeline but I find it confusing and difficult to understand introduction into the classes. I can't get to understand why the following example is not working :
I've got 3 files:
main.fla with main class "Main"
Code:
no code
Main.as
Code:
package {
import flash.display.MovieClip;
import projectconfig.Configurator;
public class Main extends MovieClip {
var projectConfigurator:Configurator;
[Code] .....
View 14 Replies