ActionScript 3.0 :: Save Variables To Be Used Out Of Events And Functions?

Feb 23, 2010

I'm working on a project for school which is requiring me to make a game using Flash and ActionScript 3.0. One of the tasks I have to do is load an external XML file that will be displaying questions and answers. I've looked at google to find simple scripts for loading XML, one example being below:

Code:
var myXML:XML;
var myLoader:URLLoader = new URLLoader();

[code].....

View 1 Replies


Similar Posts:


ActionScript 1/2 :: Events That Delete Functions?

Sep 8, 2009

I have a dragable object with something like
 
on(press){    startDrag("object");}on(release){    stopDrag();
}
 
How do I make it so that when the mouse button is released it makes it so the object can't be picked up any more (basically it removes the on(press) part)?

View 7 Replies

ActionScript 2.0 :: Save Time And Space With Functions?

Jan 12, 2011

I was wondering if there is something that I can write (a function? I don't know what they are or how they work ) so that I don't have to rewrite code. [code]...

View 1 Replies

Flex :: Design - Static Functions Or Events?

Feb 1, 2011

I'm working with an application which was originally designed to make heavy use of static-variables and functions to impose singleton-style access to objects. I've been utilizing Parsley to break apart some of the coupling in this project, and I'd like to start chiseling away at the use of static functions. I will explain the basic architecture first, and then I'll ask my questions. Within this application exists a static utility which sends/receives HTTP requests. When a component wishes to request data via HTTP, it invokes a static function in this class: Utility.fetchUrl(url, parameters, successHandler, errorHandler); This function calls another static function in a tracking component which monitors how long requests take, how many are sent, etc. The invocation looks very similar in the utility class:

[Code]...

View 1 Replies

ActionScript 2.0 :: MovieClip Events As Class Functions?

Aug 1, 2006

I have built a movie which has some nested movies within. I have created a class called ButtonMc in a .as file and used linkage to connect the symbol in the .FLA file with the class code in the ButtonMc.as file . This is the code for ButtonMc class:

Code:
class ButtonMc extends MovieClip
{

[code]....

View 5 Replies

ActionScript 1/2 :: Functions Called By Events Run In The Caller Context?

Sep 16, 2009

Imagine I have Class A that is listening to an Event on Class B. This listener will call Method X in the Class A. Inside Method X, "this" refers to the Instance of Class B, I'm not in the context of Class A. Isn't this a bit awkward, or am I getting everything wrong? Is there a way to make the listener call my method in the context of A?

View 3 Replies

ActionScript 3.0 :: Can't Trigger Functions That Are Mapped On Keyboard Events

Sep 24, 2009

I build a game that is working great on its own.Using keyboard events enter frame.When i load it in another movie, i cant trigger functions that are mapped on keyboard events.The listener is executed, but doesnt listen.On its own fine, loaded into another movie: no keyb events and from time to time enter frame event errors.I can access the keybard functions AFTER clickin on the movieclip that contains my loaded swf.

View 3 Replies

Actionscript 3.0 :: Events Never Seem To Get Fired (since I Traced The OnComplete Functions)?

Jun 19, 2009

I am building a flash site in AS3 using AMFPHP. I could really use some help in the Event department...The structure of the site is as follows:

Documentclass,
adds PageConveyer (which holds all Pages)
- adds addEventListener( Event.COMPLETE, onPageConveyerComplete ), onPageConveyerComplete:
- startAnimation (loop through pages and components in arrays to animate into screen)[code].....

The problem lies in the Event listeners.I want to make sure everything (pages/components) is loaded before I start animating. My guess was that Flash listens to the underlying objects until they are done running, then fires the Event.COMPLETE event to the parent object, which in turn fires it's own COMPLETE event. These events never seem to get fired (since i traced the onComplete functions). Im lost here. How can I best listen to this many objects within objects, to know for sure whether they are finished and ready to be animated in?

View 2 Replies

ActionScript 2.0 :: Dynamically Assigning Functions To Button Events Results?

Jun 25, 2009

I am in the process of writing a scrolling image viewer that dynamically updates from an xml file. I have written the scroll function (with a lot of help from Kirupa and other sources), and the pictures are updating beautifully, but when it comes to adding the function for the buttons I am encountering an unusual error.

Using the following code:

Code:
initButtons=function(){
for (var i in btnArray) {
var btn:MovieClip = btnArray[i];

[code]....

from this site results in the doClick function being called for each of the buttons in the btn array at runtime, and then not working afterwards.

View 4 Replies

ActionScript 3.0 :: Function That Pulls In Values To Save Writing 15 Separate Functions?

Nov 18, 2009

I have just started learning AS3 (2-3 weeks) and I have to say its very enjoyable!I am trying to make a function that pulls in values to save me writing 15 separate functions!I have a "street mc" which has 15 "house mc's" inside.When the user hovers over a house I want the resident to appear above the house.The house instance name is house1 and there is a mc in the library linked using the MrsRoy() class.This is my code so far:

Code:

var house1Res:MovieClip = new MrsRoy();
function resIconIn(e:MouseEvent):void{
var currentHouse = "street." + e.target.name;
var currentRes = e.target.name + "Res";

[code]....

I get the error:

TypeError: Error #1006: value is not a function.
at Dignity_drive_fla::MainTimeline/resIconIn()

View 1 Replies

Actionscript 3 :: Flash RIA Development - Using Events / Listeners Or Allowing Children To Call Functions In Parents?

Oct 20, 2011

I'm working on a web app built in Flash AS3. At a high level - the app has a main screen, and several "modal dialog"-type screens that pop-up to manage various user interactions. (This is a similar pattern I use in most of the apps I develop...) Typically - when the user clicks a UI control on the dialog screen (e.g., button, text box, slider bar, etc.) - the main screen needs to react, or manage the consequences. It seems like there are two general ways to handle this: Have the dialog screen dispatch events that the main screen listens for Allow the dialog screen to call functions in the main screen when those controls are clicked (which requires that the dialog screen maintain a reference to the main screen, and that the functions in the main screen are public)

In general - I understand that one of the key benefits of the first method is that the dialog screen isn't so tightly coupled; it's only responsibility is to broadcast the event. This would allow me to more easily use the dialog class in other contexts, or applications. But for many RIAs I develop - a particular screen is SO SPECIFIC to the the application that there's no chance I'd ever reuse it in another application. So, the "easy re-use" benefit is minimal. So - if you eliminate that benefit - which method is actually better? (More performant, less resource-intensive?) For example - if I use events, then Flash needs to manage many listeners for events that may never occur. So - it might be more efficient if the dialog window could call a function in the main screen directly, instead of dispatching an event.

View 3 Replies

ActionScript 2.0 :: Save Some Variables In A *.txt Or *.xml?

May 15, 2002

I want to save some variables in a *.txt or *.xml. Is this possible with Flash 5??

for example:I have 2 vars:

varA en varB. They are placed in the root.When I hit a button I want them to be saved on (p.e.) C : gamessave.*

View 2 Replies

AS3 :: CS3 - Calling Variables From Other Functions

Aug 20, 2009

If I have a function and I want to call a variable from another function (only 1variable), how do I do it? I know in the olden days you could set the variable to local or global, but that does not seem to work anymore. There is only 1 variable I need access to, but all the tutorials I have come across talk about making classes for multiple variables.

e.g. function2();
{
variable_b = variable_a;
}

[Code].....

View 3 Replies

Dynamic Variables In A Functions?

May 8, 2010

Why does this not work???

Code:
function myFunction(val0,val1,val2){
trace(this["val"+0);
trace(this["val"+1);
trace(this["val"+2);
}
myFunction("hello","test","hi")

All i get is undefined. If i just put "trace(val0)" i will get "Hello" -- so i cannot work out how to get the value of the dynamic variable inside hte function?

View 4 Replies

ActionScript 3.0 :: Variables Used In Functions

Mar 16, 2012

I got this variable:[code]is there a possibility that the compiler gets confused because my variable has the same name like the functions's parameter (type = type)? i'm not certain about this topic. Normally I'd write my function's parameter like this (if such a case occurs):[code]just to make sure the names do not exactly match.

View 3 Replies

ActionScript 2.0 :: Variables In Functions?

Nov 16, 2005

I can't figure this out.

Code:
function createTextBoxes() {
for (var n=0; n<caption_obj.textXML.length; n++){[code].....

The XML portion is working fine. What I'd like to be able to do is access the created text fields outside of the function. For example:

captions1.alphaTo(0,1,"linear",1);

This works fine when it's inside of the function, but outside of it, it won't. Basically I need to time the captions to things that are happening in an animation. The animations are also tween driven, so it would be something like obj_mc.tween("_x", 200,2,"linear", 5,fadeOutCaption1); with fadeOutCaption1 being a function that fades out the first caption and brings in the second. If there is a better/more effecient way of doing this let me know.I also can't seem to apply any styles to the text field. Do I need to create an array or object with ["captions"+n] and then pull from that?

View 2 Replies

ActionScript 2.0 :: Save/Load Variables To .txt

Dec 21, 2006

I know Flash applications cannot store data locally for security reasons, however, Macromedia has addressed this issue:

[URL]

But I don't understand that at all...

So, probably using what that link says, what's the best (easiest on the user) way to store data to a consenting user's computer? I don't mind if it has a prompt for permission, but it should not rely on too much software that nobody has (java and shockwave seem ok). The goal would be to store data across sessions, so that it would remain available if one returned to the application after closing it and going offline.

This would be useful for saving a character's HP, experience, and location variables in a game for example... possibly ending up with a .txt file that looks like:

name: Aesir
level: 2
exp: 50
zone: Cave of the Poo
x coordinate: 10
y coordinate: 30
gold: 5

Or something simple like that.

View 3 Replies

ActionScript 3.0 :: Casting Variables Into Functions?

Feb 5, 2009

haven't wrote here for a while!This is what I'm trying to do:

var level:Number = 1;
var goat:* = "thisIsLevel" + (level + 1);
var camel:Function = goat;

[code].....

View 3 Replies

ActionScript 3.0 :: Simplify Functions An Variables?

May 26, 2009

I have an animation that has roll overs controlled by AS (see code below). It works the way I have the code, but it's really messy code. And I hate that I'm have the functions rewritten for each event.How can I simplify this code?

//On the main timeline
var gearsEnabled:Boolean = true;
var gears2Enabled:Boolean = true;

[code]....

View 4 Replies

ActionScript 3.0 :: How To Pass Variables In Functions

Jul 19, 2009

I know PHP, JavaScript and AJAX. All of these other languages easily allow me to pass variables through a function, but I can't seem to work out how to do it in ActionScript 3. As you can see from the code below, I have created a variable called 'flag', this variable is set to 'notAdded'. However, once the function is called, I want to change the variable to 'added'. This for some reason does not work, the variable update only works within the function itself. There seems to be no global scope for functions.

Code:
var flag:String = "notAdded";
bobRunning.addEventListener(MouseEvent.MOUSE_UP , bobRunningUp);
if (flag=="notAdded"){function bobRunningUp(event:MouseEvent):void{ bobRunning.width = 30;
bobRunning.height = 30;
flag = "added";
}}trace(flag);

View 5 Replies

Actionscript 3 :: Functions And Accessing Variables?

Jul 14, 2010

I'm trying to create a JW player plugin, a part of the source code is shown below:

public function initPlugin(player:IPlayer, config:PluginConfig):void {
api = player;
var streamUrl:String = 'xxx';

[code].....

View 1 Replies

ActionScript 2.0 :: Performing Functions With Variables

Jan 12, 2010

i've just written the function below and I want to perform it multiple times but with different urls,

[Code]...

View 7 Replies

ActionScript 2.0 :: Class Variables In On Functions?

Nov 30, 2006

I was wondering if they found a better way of allowing the use of variables outside of an on function. For example in the script below I can use the variable bounds inside the target.onEnterFrame function because it's declared inside the constructor. However I can't use m_Bounds even though it's declared in the class.[code]...

View 7 Replies

ActionScript 2.0 :: Paths Functions And Variables

Aug 13, 2007

I have a variable in the _root called 'ordered'. I have another variable called 'total' inside a function called 'loadXML'. 'total' receives a number value from a node in a XML file correctly. I now want to transfer this value to the variable 'ordered' which, as I said, is in the _root. However, 'total' is restricted to the function and I can't access it from the variable in the _root. Neither can I transfer the value from the variable in function to the _root.ordered, since such a line targets the _root of the function itself.I guess this isn't too hard to solve, probably just a path issue, but I have a few rather large gaps in my knowledge of actionscripting.On the stage, there are three objects; a movieclip with the instance name 'clip', a movieclip with the instance name 'orderbox' and finally a dynamic text field with the instance name 'pos_txt'.[code]

View 2 Replies

ActionScript 2.0 :: Passing Variables Between Functions?

Oct 16, 2007

I am building a flash photo gallery that is fed by an XML file, now I am fine with all of the XML things in flash, my problem comes when creating the thumbnail images onRelease event. Here is my code:

Code:
_global.counter = 0;
for (_global.counter = 0; _global.counter<itemArray.length; _global.counter++) {
//populate thumbnail array with URLS

[code]....

The problem is that when I release the mouse button I get a variable undefined error in the output window. I have researched and have found that my problem is that I can't pass a variable from the main function to the onRelease function.

View 3 Replies

ActionScript 3.0 :: Flash Variables Used In Functions?

Dec 18, 2008

I have a stupid question. I got this variable:

Code:
var type:int;
and this function:

[code].....

View 5 Replies

ActionScript 2.0 :: Accessing Outside Variables From Functions?

Aug 1, 2004

how to access variables that are declared in a movie clip from a function declared in that same movie clip.

i.e.
****************************
var int1 = 1
var int2 = 2

[Code]....

I'm trying to do this in the main movie clip of a movie that I plan on importing dynamically in another movie. I've tried to use this.int1++, but I think that flash was looking for a variable that belongs to "myfunction" when I did that. I could just use _root.int1++ but like I said, I plan on dynamically loading this into another movie, in which case it would be pointing to the wrong movie.

View 2 Replies

ActionScript 3.0 :: Events - Variables And Input Text

Oct 14, 2010

I'm not new to Flash or AS3 but I've never really made anything too complex. I'm making a Flash game and getting to know Variables for the first time. The tutorials online confuse me because they're mostly geared towards AS2 and I bought this book (which is awesome) Game Design with Flash, but it only covers variables involving numbers and a guessing game.

All I want right now is a field to enter your name and below, whatever the user has entered, will show up in a Dynamic text field that will go, "Oh, so your name is (whatever)?" I understand that the information that the user types into the Input Text Field has to be entered in somehow, so do I need to make a function to make it work with a button? Right now I can type in the Input but nothing shows up in the Dynamic text field. I borrowed an AS3 example from elsewhere on this forum and added my own Instance names. I also wanted to know, how can I call up the user's name throughout the game? Just calling that same variable up?

[Code]...

View 17 Replies

ActionScript 3.0 :: Pass Mouse Events As Variables?

Sep 4, 2009

Is it possible to pass a mouse event as a method parameter in a function that is not a direct call to an event listener? [code]...

View 3 Replies

ActionScript 3.0 :: Call Functions And Classes From Variables?

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







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