ActionScript 3.0 :: Assigning Variables To Specific Objects On Stage?

Jan 3, 2010

I may just be forgetting something really simple here but I'm stumped.I have 2 guys on the stage.I want one guy to do a certain amount of damage and the other to have a certain amount of health. The problem comes from having hundreds of guys coming and going and they all need to have stats attributed to them.I don't know where I could store those variables so they can be referred back to in the code. The guys on stage are all named guy1, guy2, etc. and it would be nice if there was a way to just say guy1.health and guy2.damage and store the variables in the objects themselves somehow.

Also, I already tried putting "var health = 10" in the actual objects in the library but for some reason it takes 2 or 3 frames in game for the code to call those variables from inside the object and it causes a lot of problems. Am I missing some much easier way to do this?

View 3 Replies


Similar Posts:


ActionScript 2.0 :: Assigning Array Elements To Objects On Stage?

May 6, 2005

I have built an array of colors that I want to assign to clips on stage but there is something missing in a script and I'm stuck:

[AS]
//create a script assigning RGB color to a clip
function combineRGB (red, green, blue) {

[code]......

View 2 Replies

Actionscript :: Fix Flash Objects In Specific Location In The Stage - Resize The File?

Dec 23, 2009

I have an object inside my flash file and i want to lock the object on 0 x-axis 0 y-axis but when i re-size my SWF file my object's location changed to another location how can i fix that?

View 1 Replies

Use Variables To Call Objects From Your Library Onto Stage?

Nov 11, 2010

does anyone know if it's possible to use variables to call objects from your library onto stage like this:I have an object in my library called Level01 as is it's linkage

Actionscript Code:
var MyMap:String = "Level01";addEventListener(Event.ENTER_FRAME,LoadMap);function LoadMap(event:Event) { var myLVL:MovieClip = new MyMap();// how do you use the variable

[code].....

View 4 Replies

Flex :: Assigning XML Into Specific DataGrid DataFields

Mar 26, 2011

Coming back to flex after not using it for a while, trying to load some xml (generated by php) into a datagrid using dataprovider to create a simple grid showing the daily high and low temperatures over the course of a week. I can get the data to display in my datagrid, but the columns are loading in random order. (So friday is coming before monday etc.) How to assign specific data to specific datafields.

Here's the flex code; (updated to working code. Note that the dataFields simply contain the names of the xml tags and/or the names of the tags within those tags)
<?xml version="1.0" encoding="utf-8"?>
<fx:Declarations>
<s:HTTPService id="weather" url="[URL]" result="weather_resultHandler(event)" fault="weather_faultHandler(event)" />
</fx:Declarations>
[Code] .....

View 1 Replies

ActionScript 3.0 :: Assigning Numbers To Objects?

Jan 7, 2011

Is this right?

var movieclip5:int = 150;
movieclip6:int = 200;
movieclip7:int = 250;

[code].....

View 1 Replies

ActionScript 3.0 :: Assigning Flashvars To Variables?

Jan 16, 2009

I am using swfobject v2.1 to pass flashvars to my swf and I was wondering what the best or preferred way to pass those flashvars values to AS3 variables inside the swf.

snippet of javascript inside my html file from swfobject's required code.

Code:
....
var flashvars = {};
flashvars.myVar1 = "one";
flashvars.myVar2 = "two";

[Code].....

I essentially want to be able to pass a handful of flashvars to my swf and assign their values to AS3 variables inside (such as flv file url, skin, background colors, autoplay true/false, etc... my approach would be that certain AS3 variables would have default values (realizing my above examples do not show this), while others would require them passed from Javascript (flashvars).

View 2 Replies

Flex :: Assigning An Array Of Objects To A DataGrid?

Aug 24, 2009

When the dataProvider for an DataGrid is an array of objects, how do I set each column's dataField to a property of the object.I have an ArrayCollection (say a) where each item is an objectFor example a[i] = data:ObjectWhere the object data has some subproperties - data.name, data.title, data.content etc.I have a DataGrid in which I want to display this data.So I put:

<mx:DataGrid id="entries" dataProvider="{resultRSS}">
<mx:columns>
<mx:Array>

[code]......

View 1 Replies

ActionScript 3.0 :: Assigning Same Function To Multiple Objects

Mar 8, 2011

I have 4 mc on my stage which i want to tween to a specific size (400x400) on MOUSE_OVER. I would like to assign each mc the same function to achieve this. I have half achieved this with the code below, however when I MOUSE_OVER one of the mc, the stage also resizes. I would like to avoid using XML if possible.

This is my code.
Select allmc1.addEventListener(MouseEvent.MOUSE_OVER, thumbOver);
mc1.addEventListener(MouseEvent.MOUSE_OUT, thumbOut);
mc2.addEventListener(MouseEvent.MOUSE_OVER, thumbOver);
mc2.addEventListener(MouseEvent.MOUSE_OUT, thumbOut);
mc3.addEventListener(MouseEvent.MOUSE_OVER, thumbOver);
mc3.addEventListener(MouseEvent.MOUSE_OUT, thumbOut);
[Code] .....

View 4 Replies

ActionScript 3.0 :: ArrayCollection - Assigning Keys From Variables

Jul 16, 2010

I'm constructing an ArrayCollection that I want to be completely dynamic. I do not want to hard-code in name/value pair values to create it. I've written up a program that grabs some XML from an exterior source and then assigns values from it. The ArrayCollection is being used as the source for a chart.

This example works, but is not reuseable:

ActionScript Code:
projects = new ArrayCollection([
{Project:"On Time", Percentage:60},
{Project:"On Time With Developer Exception", Percentage:20},

[Code]....

and the expected values are assigned in the [0] members of the variable structure. Basically it's the exact same thing, but with the values buried a level deeper. So my question is in two parts. The first is a plea for general help with this problem. The second part is in regards to the ArrayCollection's addItem function. Is it required to hard-code in the keys to the ArrayCollection? That severly limits its usefulness. Since the key appears to be interpretted as a string, even though it's assigned without double-quotes, I would think that a string variable could be used instead.

View 1 Replies

ActionScript :: Dispose XML After Assigning Data To Array Of Objects?

Nov 13, 2010

after assigning loaded XML data to an array of objects, i would like to remove the XML from memory, or at least available to the garbage collector. however, doing so also removes the assigned object values in the array. rather than calling XMLdata = null;, i'm calling System.disposeXML(XMLData); as directed by the documentation:

[Code]...

View 1 Replies

ActionScript 2.0 :: Assigning Tween Classes To Objects In An Array?

Jan 11, 2006

My array has a few objects that are revolving like on a carrousell...I want them to react on my mouseclick.I cant seem to get this to work...how would one make objects in an array do things?I cant even define the path to them properly, it appears that I SUCK. Allow me to present to you my little code-turdthat wont work in a million years level0.holder_mc.dot0.onRelease = function() {var xScaleT:Tween = new Tween(dot0, "_rotation", back.easeOut, 0, 1222, 2, true);

View 4 Replies

Data Integration :: Assigning Loaded Variables Using Loadvard?

Jun 27, 2007

i am using loadvars to load url encoded data from a php file.

when i trace the output it shows that the variables have been retrived successfully.

now i need to use the values by assingning then to a variable. i cant seem to get this going

i am using flash 8 with as2.

myVars.onLoad = function (success) {
if (success) {
trace (" variables loaded ");
ad1id.text = myVars.ad1id;

[Code].....

is the above method used for assigning the variables correct.

View 1 Replies

Flex :: Flash Builder - Not Assigning Data To Variables?

Mar 4, 2012

I am trying to assign a value from my database to a variable inside my Flex application. So far I read up a few ideas and I have at the moment the following code using a PHP web service:

protected function btnSubmitUser_clickHandler(event:MouseEvent):void
{
username = txtUsername.text;

[code].....

View 1 Replies

ActionScript 3.0 :: Assigning Unique Variables To Movieclip Instances?

Apr 10, 2009

When one creates several instances of a movie clip on the main timeline, how can one assign separate variables to each of these instances and then invoke each of these values from the main timeline? I know how to do this by creating a separate movieclip and putting code on that movie's timeline (using 'this'), but I always feel this is sloppy because I'd like to keep my code all on one timeline.Here's some example code. It creates three instances of a movie clip, and assigns each one a variable called 'contImage' which contains the source of the loaded image. How can I get this variable traced when each of these images is clicked?Even though, as I said above, I have a work around, it has stuck in my craw for a while now.

Code:
var photos:Array = new Array('images/1.jpg', 'images/2.jpg','images/3.jpg');
for(var i:int = 0; i < photos.length; i++)

[code].....

View 6 Replies

ActionScript 3.0 :: Assigning Variables Into Dynamically-created MovieClips And Indexing Them

Apr 27, 2010

I'm having a problem while assigning variables into dynamically-created MovieClips. Here's a pseudo-code of what I'm trying to achieve.

[Code]....

I need the movie clips to contain their index values as a variable within them. I've tried several approaches, including declaring the variable names within the MC itself, but that doesn't work either.

View 2 Replies

ActionScript 2.0 :: Creating Variables In A Loop And Assigning Them Non Empty XML Values

Jun 1, 2011

Here is the structure of the XML file: PHP Code: <xmlfile><page></page><page> <source></source> </page></xmlfile> Some "page" nodes contain the extra "source" node. What I'm currently doing is looping through all the page nodes and looking for any source nodes. If there is a source node, I create a variable, and want to assign it a value of the contents of the "source" (HTML).

[Code]....

View 1 Replies

ActionScript 3.0 :: Assigning Class Name To String On Stage

Mar 11, 2009

I have a loop which add my button to the stage. However I want to assign a name to the buttons which is the same as the class. I am trying to use the AS keyword with no luck.

var movieList:Array = [AboutBut, WhatBut, OurWork, News, ContactUs];
var tempClip:MovieClip;
var tempClip:String;
var yPos:int = 0;
for (var i:uint=0;i<movieList.length;i++) {
[Code] .....

View 3 Replies

ActionScript 3.0 :: Accessing Stage Objects From Other Objects?

Jul 24, 2010

I have drawn colored rods which I have placed in the library and have put one of each on the stage with instance names likeblueRod_mc, etc.I place them around with time-line code like
blueRod_mc.x = 300.0;I have now created an Actionscript class called Problem.I build a new object from Problem which I have called Riddle.But when I put blueRod_mc.x = 300.0 in a method (of Problem),I get the message that blueRod is not accessible.So I triedstage.blueRod_mc.x = 300.0;That did not work either.

View 9 Replies

Actionscript 3 :: Centering Objects On Stage And Auto-Scaling With Stage Resize

Oct 19, 2011

I'm writing a web based flash app that's written entirely in AS3. I have objects on the screen as part of a GUI. I would like the user to be able to resize the window, or make it full screen. I would like everything to auto-scale with the resize, but also remain in the same relative position on the stage.

View 1 Replies

ActionScript 3.0 :: Get Number Of Specific Objects In Array?

Feb 6, 2010

How could I get a number of all same objects in array (lets say I have five "Grass" objects and ten "Wood" objects. Now I want to get the number of Wood objects.

View 6 Replies

IDE :: Make Objects Move In A Specific Path?

Dec 1, 2010

i want to make 3 objects move in a square pathi tried to use guide layers but it didn't work good for both three objectsonly the first object followed the exact pathis there some other way to do it??

View 6 Replies

ActionScript 3.0 :: Tweening Objects To Specific Position?

May 10, 2011

Right now I'm working on a website that has movie clips that I want to tween back and forth across the stage when a button is pressed.

Here's the idea:

When 2_btn is pressed, I want 1_mc, 2_mc, and 3_mc to move from right to left and then stop when 2_mc is positioned on the stage, stop moving and play

Then if 3_btn is pressed I want all three to be animated from right to left until 3_mc is positioned on the stage, stop moving and play

Then if 1_btn is pressed I want all three to move from right to left until 1_mc is positioned on the stage, then stop moving and play

Basically I have no idea how to accomplish this, or how to word it into Google.

What I have right now, which obviously isn't accomplishing what I want is:

Tween from left to right across the timeline, and then using a gotoAndPlay, and then stop(); on the frame..

View 2 Replies

CS3 Assign Specific Actions To Random Dynamic Objects

Apr 1, 2010

I have 4 objects in the library. I use a switch case statement to randomly generate them to the stage;[code]When the user clicks "taskMC", I want to assign behaviors according to which object. If I trace "taskMC" I get the name (object A_Graphic, object B_Graphic etc.)but I can't assign actions to them that way. How do I get object A_Graphic to do one thing, object B_Graphic another thing...?

View 2 Replies

ActionScript 3.0 :: Drag A Specific Image Without Dragging All The Other Objects?

Feb 7, 2010

how can I drag a specific image without dragging all the other objects. The image to be dragged is exported dynamically from the library and activated on a mouse over. Here is the code:
  
function myImage(event:MouseEvent):void {
var img:BitmapData=new livery(0,0);
var MyImg:Bitmap=new Bitmap(img); 

[Code]....

View 1 Replies

Flex :: Binding To An Specific Property Of Objects In An Array?

Jul 22, 2009

I am using Flex to create a small form. All I have at the moment is a List component, that I want to populate with a list of font names.I am getting the fonts using Font.enumerateFonts(true);. This returns an array of flash.text.Font objects.

The Font objects have a fontName property that is a String of that fonts name.My problem is that I can't figure out how to bind the List's dataProvider to the fontName property of each of the Font objects in the Array.Is there a way to do this just with binding? and not creating a new array of Strings by looping through the Font objects?

View 1 Replies

Flex :: Separate Objects Into Two Datagrids Based On Specific Value

Oct 5, 2011

Im using Oracle, BlazeDS, Java and Flex. I have a list of objects displayed in a datagrid(Lets call them Main-objects. Each of these objects have a set of UserComment-objects associated with them(One-to-Many relation in the DB). These comments may come from two different "types" of users, distuingished with either a 1 or 0 in the UserComment-object's "userType" field. Each time the user selects a Main-object in the datagrid, the UserComment's related to this object is displayed in a separate datagrid below.Based on the introduction, i want to separate the UserComment's into two separate datagrids (one for each user-type), instead of the one i have now. So my question is: What is the best approach for performing this task? What is the best way of separating the UserComment's into two separate data grids based on the value of the "userType" field?

View 3 Replies

Flash - How To Randomly Create Objects From Specific 5 Points

Feb 13, 2012

I am developing a mini flash game. Player control character and move left and right to collect money coin. There are 5 points that money and bomb release and move from top to bottom. When character collide with money then increase money else hit bomb age increase by 1. Once the age is 99, the game is over and the money is the final scores

Here is my code:
package Class {
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.media.Sound;
[Code] .....

This is my Game:
Currently, the bomb and money random appear X, 100 with 15 money and 10 bombs in a screen.
What I want is, how to amend it become money and bomb appear from specific point, after that the money and bomb when hit the wall will bounce back.
An example similar game play with my game is [URL].

View 1 Replies

Actionscript 3 :: Make Object Obscure Specific Objects?

Mar 17, 2012

Right, so here's the scenario: I have 4 objects, A, B, C and D. What I want is that C obscures A, but not B. Similarly, I want D to obscure B, but not A. A and B can overlap each other in any order, it doesn't matter.In other words, what I want is an object (C) to be able to cover one object (A) but not another (B), even if it comes into contact with it.Same with D, which can cover B but not A, even if it comes into contact with it. The problem is that I can't think of a layer configuration that allows this: D will always be higher than both A and B, and thus will obscure both.I'm not expecting anyone to come up with some unfathomably clever configuration, but I'm wondering if there's some kind of ActionScript that can do this. In particular, I would like A and B to be dynamic TextFields, and C and D to be MovieClips of any shape (i.e. not a rectangle).

View 3 Replies

ActionScript 3.0 :: Load Library Objects At Two Specific Times?

Oct 3, 2009

I want all my libray object that are classes to load on frame 2 except for one which is the preloader class I want this to load on frame one.

I can go into my publish setting and set frame two for all the classes to load, but then my preloader class isn't available until frame two.

can I write a line of code that will make the preloader class available on frame one instead?

View 2 Replies







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