ActionScript 3 :: Flash S5 - Reading Variable From Different Class

Jan 30, 2012

I have already set a variable in my document class "Main.as". I am now trying to access that variable and read its value from a different Class and Function, take that value and email it. For example in my "Main.as" file I have this function:
public var _myVar:String;
function create() {
_myVar = "hello";
}

Now from my other class "EmailtoFriend.as" I have a new function to try and get the value of that pre set variable:
function getVar() {
trace(_myVar);
}

Why will it not output "hello"? Instead I get an error saying: Access of undefined property _myVar.

View 4 Replies


Similar Posts:


Actionscript 3 :: Class - Reading All Classes Under A Package Or Reading Classes With Same Metadata

Jun 19, 2011

I am doing an Actionscript 3.0 project which involves introspection. I am wondering if there is a way to get all the classes within a given package structure.

[Code]....

View 3 Replies

ActionScript 1/2 :: Reading Variable From Php?

Nov 4, 2009

I know there is a way to read variables from PHP, i have seen the many tutorials. What I want to do is slightly different. I need to load the flash file with a variable.I want the user to have a url containing a variable, the PHP will then get the posted variable and load it into the flash file on the page. Is there a way to load the variable into the flash file?URLtest.php?var="list.xml"Inside PHPget posted variableload flash file and load the var into the actionscriptFlash embeded on page or on a redirect pageActionscript uses variable which was originally embedded in the URL

View 3 Replies

ActionScript 3.0 :: Reading In Variable From .txt?

Jan 15, 2010

Does AS3 have a Class that can read in lines from a .txt file and assign values to variables. For example, say I have a Player class with three int variables health, armor and damage. I also have a corresponding player.txt file that holds the variables.

health = 3
armor = 4
damage = 5

What code can i use to assign these variables their correct values in Flash.IMPORTANT It must be a txt file. XML is not applicable.

View 2 Replies

ActionScript 3.0 :: SWF Reading An XML With Variable Name

Jan 20, 2011

I have a SWF reading a XML for text and stuff. I'm trying to make the SWF reading a XML whith the same name of the SWF, even if I change the SWF name. Is that possible? Wow!... In other words: I want to duplicate the SWF (renaming it, lets say, to MyDuplicate.swf) but I want the new one to read another XML (called MyDuplicate.xml). It means that the inside as3 code must have a variable name for the XML to load depending on the swf actual name... It may sound odd but it's perfect if you need to multiply your swf for an undefined number of copys whithin an application.

View 0 Replies

ActionScript 2.0 :: Reading A Php Variable?

Oct 7, 2005

I am trying trying to read ONE SIMPLE variable from a PHP page using actionscript's LoadVariables command. I keep getting NOTHING back. I have read through all the articles here and none of them are talking about the right thing - os there an easy way to do this?

View 2 Replies

Xml :: Reading Variable From File In Flex?

Jan 15, 2011

I'm trying to read the address of a flv file from an xml file and then put it in the "source" property of a videodisplay tag .

[Code]...

View 1 Replies

ActionScript 2.0 :: [FMX] Giving And Reading A Variable?

Jun 15, 2003

On this moment I have a menu and six windows, every item on the menu has his own window. What I would like to do is that when the item 'home' is viewable and the visitor has pressed on another item, the window of 'home' goes away and the item were is clicked on comes up.

But how can I do that the best?I think I must give every window a variable so when there is pressed on a item flash will go search for the window that is shown and let that one play the animation to go away, so the window that is shown must have variable '1' all the others are '0' and when pressed on a item flash search for '1'...But how do I do all this, and is this a good way of working??

View 1 Replies

ActionScript 3.0 :: XML Reading Class From PHP?

Oct 4, 2010

I'm building a class with AS3 which is supposed to be able to read via php an xml file of the which I specify the url and assign the return to a variable, the as3 cose is the following:

package
{
public class phpInterfaceClass
{

[Code]....

I know that I should make the readXML function return only after the loading event has completed, but I don't know how!

View 5 Replies

ActionScript 3.0 :: Reading Class Name As String

Jun 1, 2010

does anyone know how do i make a string as a classname.[code]

View 11 Replies

ActionScript 2.0 :: Number Variable Gets Converted To String When Reading From Textfield Of Numbers

Aug 20, 2010

I have the input textfield with instance name vIn, and the variable _vIn. (The textfield is empty.)[code]i have five other variable/textfield pairs were this works ok. I don't get why this pair doesn't work also, my textfields won't accept the subtraction operator, - , even though they're all set to vIn.restrict = "0123456789.-";It doesn't even work in the output textfields were there's no restriction (Negative results are displayed positive)

View 3 Replies

ActionScript 2.0 :: Reading Ext XML Data Into Class Object Array?

Sep 21, 2009

Ok, I've written a simple class with some string/number variables and set/get functions (tested by creating static objects).

ActionScript Code:
import EventClass;
var aEvent = new EventClass();

[code].....

View 1 Replies

ActionScript 3.0 :: Reading LoaderInfo Flashvars Then Chaning Them And Reading Them Again Fails

Oct 24, 2011

I am changing the flashvars variables v1=value&v2=value ect then after the flash movie runs I am changing the variables externally by javascript, so far so good.when flash first loads it reads the vars correctly.when I try to read them ( after the change ) it keeps reading the old values.[code]everything works except I cannot seem to read the changed FlashVars.

View 1 Replies

Flash :: How To Get Variable From Another Class

Feb 16, 2012

I am developing flash game.

first class:
public class Game{
public var age;

[code].....

View 1 Replies

Flash :: How To Access Variable From Onother Class

Jan 24, 2012

I have a class name project and project2

public class project1 extends sprite
{
var window1:camera=new camera()

[code].....

View 1 Replies

ActionScript 3.0 :: Flash Variable Monitoring From Outside Class

Aug 5, 2011

I am attempting to make a simple class that I use to debug some of my code at runtime. I use a function in my debug class to pass a variable from another class that I want to monitor in realtime. For simplicity sake I am only passing Stings at the moment. I can pass the variable that I want successfully but I am stumpted as to how I to get my DebugClass to monitor that variable in realtime. Since the variable is being altered in another class, what would I needto do to have the debugClass monitor that variable without having to call a new function everytime the varible changes, which could be 300+ times a minute.

This is the current method I use to add the variable to my displayList:

protected function addDebugData(stringToAdd:String):void{
var debugText1:TextField = new TextField();
debugText1.border = true;

[Code]....

View 10 Replies

AS3 :: Flash - Simulate AS2 _global Variable Using A Simple Class?

Feb 14, 2011

I have recently started making (and am still making) the transition from ActionScript 2 to 3. I have used the _global variable in an AS2 project as I needed a variable to be accessible from within ANY swf loaded into my main movie. This worked like a treat.

However, along came AS3 and whipped that from right under my feet. After much Googling, a few people suggested making use of a simple class with a simple variable that can be publicly set and retrieved. I made a simple class, imported it and manipulated the value, and all went well, however the instance of the class I create in my main loader movie is still not accessible from within a second SWF that gets loaded into my movie. If I re-instantiate the class in the SWF that is being dynamically loaded, the value reverts to the default value in the class code, not the new value set in my parent (first) movie.

Here is my class code, stored in an external .as file, is there any way I can simulate the ostype variable being a global variable?

package{
public class ostype {
public var ismac:Boolean = false;

[code]....

it's used as a simple identifier as to what operating system this flash app is being used on (mac or windows) and as a result let's me server content - such as saving files - in a different manner.

View 1 Replies

Flash :: Accessing A Variable Declared In Fla From Document Class?

May 24, 2011

On the stage I have a movieclip by the name of rect_mc. Inside it have have a MovieClip square_mc.In the time line that I get when I double click on rect_mc (timeline of rect_mc) I have written the following code

var width1:Number;
width1 = sqaure_mc.width;

How can I access width1 from the document class?The thing that I want to is access the variable declared (width1) in the timeline of rect_mc. Just for the sake of a example only I choose the width of MovieClip.My doubt is how can access a variable declared inside the timeline of rect_mc from the document class. It could be any variable.My document class is:

package
{
import flash.display.MovieClip[code]....

View 1 Replies

Flash :: Sending Variable From Fla To Document Class And Then Accessing?

May 31, 2011

I want to find out whether my swf was loaded locally or from another swf. For this purpose I have declared a variable 'parentType' in my fla. var parentType:String = String(parent); There is a function in the document class that determines whether swf was loaded locally or from another swf. The name of the function in the document class is 'externalOrInternal'. The varaible parentType is passed as a parameter to the function externalOrInternal externalOrInternal(parentType); The name of the document class is Main. In the constructor of Main I have the function pollResize() (the use of this function is to listen for the resizing event. That part of the code is not shown in the snippet given below).

[Code]...

I see that swfParentType is has value insde the function externalOrInternal. My doubt is why null is traced inside the function pollResize. Why is it not [object Stage] as inside externalOrInternal. Due to this I am not able proceed further with the stage resizing event.What needs to be done so that proper value is traced in the function pollResize.

View 1 Replies

ActionScript 3 :: Variable Flash UI - MouseCursor Class Not Defined

Jan 16, 2012

This is quite strange to me since the MouseCursor class is being used as static.
Mouse.cursor = MouseCursor.BUTTON;
This is what I am using the MouseCursor class as and hence it is static. We got this error posted by a customer and the customer has also attached a screenshot of the error.
ReferenceError: Error #1065: Variable flash.ui::MouseCursor is not defined
I first assumed that this could be perhaps because he was running an older version of Flash Player ( older than v10 ). But his screenshot clearly shows that it is running version 10 of the flash player.

View 2 Replies

ActionScript 3.0 :: Pass Variable From Class File To Flash?

Dec 21, 2011

I am adding some movieclips dynamically to stage. If we click on the movieclips, they goto and stop at frame 2. The Click Event for the Movieclip is defined in the base class

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

[Code].....

But, I cannot figure out how to get the name of the movieclip.

I cannot add click event for movieclips in flash, because there is already a click event in the class file.

View 1 Replies

ActionScript 3.0 :: Passing Variable From Document Class To Movie Clip Class?

Oct 12, 2010

i have a movie clip which is exported for ActionScript , i want to get a variable from the document class into the movie clip class i tried this but there was an error !!

ActionScript Code:
var main:Main=new Main();
main.txtScore.text="hello";

View 1 Replies

ActionScript 3.0 :: Accessing A Class's Static Functions From A Variable Of Type Class?

Feb 19, 2010

I realize this is kind of an odd issue, but I am wondering if there's any way to get Flash to allow me to access a class's static functions using a class variable that points to the class. Example:I create a class called FooClass that has a static function named fooI then create a variable of type Class that points to it

Code:
var class:Class = Class(getDefinitionByName("FooClass"));
However, when I try to call foo() using the variable, it errors saying the function

[code].....

View 6 Replies

Flex :: Assign Variable As Class In Flash Builder 4 Hero SDK

Jan 17, 2011

I am trying to assign a variable to a view navigation as follows:

protected function list_clickHandler(event:MouseEvent):void
{
var name1:String = list.selectedItem.vPage;
var name2:Object = list.selectedItem.vPage.valueOf();

[Code]....

As the View is presented as a static and not a variable. When you try to submit it as a variable in any format (String, Object) an error occurs.

Error #1034: Type Coercion failed: cannot convert "IM" to Class.

how I can send the (View)Class as a variable or if this is a bug in the SDK

View 1 Replies

Flash :: Converting String Based Array To Class Variable Name?

May 29, 2011

I have an array, which are the literal names of class references. Eg. in my main class I have

var page1:PageOne = new PageOne();
var page2:PageTwo = new PageTwo();
var page3:PageThree = new PageThree();

[code].....

View 1 Replies

ActionScript 2.0 :: [Flash 8 Class] Variable Alias No Longer Working?

Aug 8, 2006

I like to make alias varaibles for long names, so that i don't have to keep repeating huge lines of text, but when i try to create one for a custom class, it fails.

Code:
Clients["Client"+i] = new Client();
var Client:Object = Clients["Client"+i]

Its almost as if flash is trying to make the new variable a new Project(); instead of a reference to the other variable...

View 2 Replies

ActionScript 3.0 :: Passing A Variable From The Document Class Into A Custom Class?

Dec 28, 2009

I'm trying to create a class which will create a tween for several different instances of an object. I am creating the instances in the Document Class. The trick is, I would like to specify how long each tween will take.

Here's what I have so far:

DOCUMENT CLASS

ActionScript Code:
package {
import flash.display.MovieClip;
import mcCloud;

[Code].....

As you can see, I have a variable "myTime" which syncs the timer and the tween. This causes to tween to repeat and the clouds to continually scroll across the stage. How can I determine the var myTime at the time I create each instance of the Movie Clip mcCloud?

View 6 Replies

ActionScript 3.0 :: Reassign Class Variable To A Blank Instance Of Its Class?

Aug 31, 2011

When I declare a class variable
 
private var myVar:MyClass = new MyClass(); 

It creates a new instance of that class that will trace as [Object MyClass].
However, as soon as I assign it to something
 
myVar = thisOtherVar; 
It will now trace as [Object thisOtherVar].
 
I need to get it back to where it's just an "empty" blank class instance, if that makes any sense at all.

View 14 Replies

Professional :: Accessing A Variable Defined In One Class From Another Class

Mar 14, 2011

I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem to be working for me.[code]

View 1 Replies

Professional :: Accessing A Variable Defined In One Class From Another Class?

Mar 14, 2011

I've only been programming in as3 for a couple months, and so far I've written several compositional classes that take MovieClips as inputs to handle behaviors and interactions in a simple game I'm creating. One problem I keep coming upon is that I'd love to access the custom variables I define within one class from another class. In the game I'm creating, Main.as is my document class, from which I invoke a class called 'Level1.as' which invokes all the other classes I've written.Below I've pasted my class 'DieLikeThePhishes'. For example, I would love to know the syntax for accessing the boolean variable 'phish1BeenHit' (line 31) from another class. I've tried the dot syntax you would use to access a MovieClip inside another MovieClip and it doesn't seem  to be working for me

package  jab.enemy
{
import flash.display.MovieClip;

[code].....

View 1 Replies







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