ActionScript 2.0 :: Referring To External Object Within Function?
Jul 9, 2006
I have a class with a method "movePaneTo". I want to create a tween and do multiple things at every step not just change a movieclip property. Tweening a property of the class seems to be working but how do I refer to the class that initiated the tween from the onMotionChanged handler, so that the trace would display the current value?Should I be using a listener for the onMotionChanged?What's this kind of function (the one assigned to "onMotionChanged") callled? [code]
View 4 Replies
Similar Posts:
May 31, 2011
I have four buttons named button1, button2, button3 and button4. I want the code to trace the name of the button when the button is clicked. This is just an eample of what I'm doing in my project. The project itself is too convoluted to put up and explain. My problem that needs to be solved is, how do I refer to the button in the Function?
var c:int;
var buttonName:String;
for (c = 1;c < 5;c++) {
buttonNum = "button"+c;
[Code]....
When I say "trace(this)", the code doesn't know what "this" is because I've taken this[buttonNum] out of the loop by having to put it in a Function. How do I call to the object that is in the listener that called the Function?
View 8 Replies
Apr 12, 2010
I have a small Flash file where I control a ball.In ActionScript 2.0, I have it to where this ball moves around based on input from the Arrows on the keyboard. It also bounces off the edges.I added a new separate ball (not the same symbol) and I want to refer to the NEW ball's X and Y coordinates to see if I am running into the new ball. How do I refer to the other ball's (or any other object for that matter's) properties from within the ActionScript of the first object?
View 2 Replies
Mar 4, 2010
I have an object that I add movieclips into when a user does something.
I'm trying to loop through the items in this object later and perform something when object.objectName = something, however I'm finding it hard to get the right code to use in place of the something.
code within a function that adds movieclip to object:
Code:
if (thisHImage==1) {
healthArray[healthIndex] = new mcCake();
}
[Code]...
when i trace(healthO.objectName) i get [object mcCake], but it won't enter the if statement,
View 2 Replies
Feb 20, 2009
I'm fairly new to AS3 and CS4, and I'm trying to figure out how to write code that isn't needlessly repetitive. I'm not sure exactly how to streamline it, or if that's possible in my case. My issue in particular is with buttons. I have 40 buttons that perform the same function with a single variable, so I'd like to figure out if I can accomplish that without writing 40 separate functions.This is the current version: http:[url]......Here's the full code, with the relevant part in the last commented section:
Code: Select all// Library button opens library
libraryButton.buttonMode = true;
libraryButton.addEventListener([code].......
It seems that something like that might work, but I don't know how to go about setting my variables up in an array or otherwise putting them in a state where an incremental statement could refer to them.The bigger issue, though, is whether I need to make a separate function for each button.Each button will do the same thing, just with one variable.When the user clicks a button, I want it to perform a function that will update text fields with text pulled from XMLList variables.Each button is given a unique identifier that corresponds to an index in the XMLList.So clicking the button just needs to establish that identifier as a variable n, so that the function can, for example, update the titleText text field with the text contained at titleList[n].
For the purposes of this example, let's just say that I want the mgInteraction function to trace the identifier (name, array index, or whatever) of the clip that's being interacted with (mg0/mg1/mg2/mg3). Is there a way to set this up to work with a single function, or do I need to create 40 unique functions, one for each button?The flash, if need be, is here:
http:[url].......
View 1 Replies
May 22, 2011
I have an mc "mc" that I made in flash. It has a text box in it with instance name "txt1". I dimmed a variable var mc:MovieClip = new mc() and used the add child method to add it to stage. Now I want to refer to the text box in the mc. I tried mc.getChildByName(txt1).text="abc" but it gives me errors. How do I refer to that text box.
View 4 Replies
Oct 23, 2008
Using AS3, I was wondering how to control one object, a ball, while another ball bounces around. I'm modifying code from "Foundation ActionScript 3.0 Animation" by Keith Peters.
I'm pretty new so I'm probably making some obvious mistakes here. First of all I thought I could refer to the balls as ball[0] and ball[1] since they are in an array called ball. Is this correct?
[Code]...
View 7 Replies
Jan 27, 2012
Is there a external-source-path option available in Flex compiler similar to external-library-path? My requirement is that, I am building a "SWC" file but I don't want to include certain folders inside my 'src' folder as these are anyway available in my other application during run time. (Trying to be resource constraint). So, I want to use these folders during compilation but do not want to include them in the generated "SWC" file.
View 2 Replies
Jan 29, 2003
is it possible to write a function to move an object and then call that function on a clip event for instance
function (bounce){
script;
script;
}
and then call it by saying
on(mouseOver){
this.bounce;
}
View 2 Replies
Jan 10, 2012
I have an AS3 program that calls a function multiple times. The function must return multiple variables, so I created a class for the function to declare an object containing all of these variables. For example, here's my class:
package
{
public class PER
{
[Code].....
Let's say the calling program calls the function, which returns the variables into data_set1 (where data_set1 depends on input variables arg1, arg2, arg3) using:
var data_set1:PER = function_name(arg1, arg2, arg3);
The calling program does some stuff, then calls the function again, but returns the variables into a new variable name, data_set2:
var data_set2:PER = function_name(arg4, arg5, arg6);
My intention is that data_set1 and data_set2 are different (e.g. not linked together).
My question is, given that arrays are passed by reference, will data_set1 be modified to agree with data_set2 upon the 2nd function call? Why or why not?
View 1 Replies
Feb 22, 2011
I have an object which is assigned a number of properties:
var project_array:Array = [];
var slideObject:Object = {
project_title : myXML.projects.project[i].title.toUpperCase(),
[Code].....
but I'm not quite sure where to place this. If I place it outside of the object constructor, I get "term is undefined", I guess because it doesn't know what project_clips_array is - but if I declare project_clips_array in the constructor, it appears to need to be defined, i.e. I can't create a blank property. But I can't place it in the constructor either, because it doesn't seem to allow me to run a function within an object constructor. What is the proper syntax or arrangement of code for executing this function to get the array within the object?
View 2 Replies
Mar 26, 2011
Alright, I've looked online at a bunch of different collision tutorials but they don't explain what I'm looking for. I want object A to hit object B and then execute a function via to a Event listener.
View 1 Replies
Jun 29, 2010
Use Flash CS5 (and AIR, though this does not seem like it would be AIR related) in Win XP 64 I have a MovieClip symbol in my library with the identifier 'Puzzle10Piece10' with the following actionscript attached to frame 1 of the only layer with the following actionscript:
[Code]...
This runs contrary to my understanding of the pre-compiler and code execution order. In my way of thinking, any reference creation and related memory allocation is made when the object is instantiated, and indeed that allocation, unlike C depends not on code order (declaration before use), though this is an order that would satisfy even the C pre-compiler. If I understand the Flash compiler at all, it's not even a question of 'code order'... the symbol is pre-compiled such that for it to exist... for it to be instantiated, the variable would exist before the function would even be 'available' to be called internally or externally. Is my thinking way off, or is this a bug?
View 6 Replies
Apr 17, 2012
I am using in AS3 "External Interface ". When I call the JS function that is on the same page as swf everything works fine.
I added a link in the html page to an external JS file, when I move the JS function to the external JS file the website crushes.
I would prefer to have all my JS functions on an external file so I can use them in the future in other project and it also makes it easier for me to update the site.
how to call a JS function that is on an external file from AS3?
View 6 Replies
Sep 28, 2010
in this case this.name return me root1
i was expecting the name of the function caller witch is a btn dynamicly created on stage (see exemple)
var facebook:SimpleButton = new socialIconFacebook();
addChild(facebook);
facebook.x = 134;
[Code]....
i know i could put the url right there instead but i have a lot of btn who would use that function
View 5 Replies
Oct 22, 2011
I am trying to access a function in a loaded swf that has external class.. I would like to avoid having to put the function on my "Main" Doc class in the external swf and instead access the function directly from the class
This is what ive tried so far and it's a no dice:
private function startLoad(){
var loader:Loader = new Loader();
var req:URLRequest = new URLRequest("one.swf");
[Code]....
View 1 Replies
Oct 20, 2010
im creating multiple objects (the number is dynamic)they move randomly, but i want dont want them to be able to pass thru each other.i'm having dificulty on writing the hitTextObject code because I dont know how to refer the other objects.[code]
View 5 Replies
Jan 27, 2010
I have a problem I just can't seem to solve.I have an FLA .. (augmented.fla)I have a movieclip inside of augmented.fla with a class name of myMaterial that has the following code on it's timeline.
ActionScript Code:
var request:URLRequest = new
URLRequest("main.swf");
[code].....
View 0 Replies
Dec 21, 2006
This is my problem: I've got a couple of movieclips, when I click on them I want them to open the URL that I've typed in my XML-file.(The photos are thumbnails stored inside of the movieclips)Here's my XML:
Code:
<?xml version="1.0"?>
<select name="photos">
<option photo="film14" url =">[code]....
How do I refer to the url-code in the actionsscript?
View 4 Replies
Aug 4, 2009
Given a Function object, can you get its name as a String? See example:
function doThingWithCallback(callback:Function):void {
trace("i'm going to run " + callback); // outputs "i'm going to run function Function() { }"
}
[code]....
This example is sort of arbitrary, but it would be very useful to get function names for debugging, particularly when passing around Function objects.
View 1 Replies
Feb 20, 2010
Now that I've set labels, I'm trying to create actionscript code to go to the labels. Here's an example of my code:
btn_me.addEventListener(MouseEvent.CLICK, gotome);
function gotome(event:MouseEvent):void{ gotoAndPlay(me);}
This code has been borrowed from the online video - Getting Started 18: Building an Application. Of course, in that video explicit frame numbers are used so the code looks like gotoAndPlay(15). I'd prefer to use labels for obvious reasons. My question - how do I tell Flash that 'me' is a label? I expect I need to use a special character and I've already tried gotoAndPlay(#me) but that gives me a Syntax error.
View 3 Replies
Nov 23, 2009
i need to refere to a whole bunch of mc named a1, a2, a3, a4, a5 and var who:MovieClip="a"+3 dosnt work...
ActionScript Code:
import gs.TweenLite;
stop()[code].............
View 1 Replies
Apr 17, 2003
say i have this code: blah = "123 + i" so blah is a variable right? so how would i refer to this variable? i want to be able to do: _root.blah.onPress = function () but this won't work beause you need an instance name instead, so how would you do this? thx, i hope you understood what i was saying
View 9 Replies
Feb 7, 2006
Code:
var l = 2;
duplicateMovieClip(button, "button"+l, this.getNextHighestDepth());
[code].....
View 4 Replies
Mar 31, 2006
im trying to, to make my MC have a rollover effect but my movie clip had been added by Action Script so this doesnt work
[Code]...
View 5 Replies
Jan 29, 2008
How do you refer to the level one below the current level . I know _root refers to the bottom level, parent refers to one level above but I don't know what to use for one level below. Otherwise, is there a way to refer to a level by its name?
For my needs, I have a clip portfolio.swf that is loaded into a Base flash file. Within portfolio, is a loaded movie called Gallery.swf. Gallery contains a movieclip called Thumbnails which has buttons to load various image.swf files. Also within Gallery is an empty movieclip called "ContainerMC" which is where image.swf are loaded into when called upon by the thumbnail buttons. From within Thumbnails, I want to be able to refer to that movieclip "ContainerMC" which those selected image.swf files are loaded into. I can't use _root as that will refer to the base flash file. I can't use "this" as that refers to the Gallery file.
View 2 Replies
Mar 15, 2009
I have created a loop to add my clips by class and give them a name
tempClip = new clientsThumbs[i]();
tempClip.x = xPos;
tempClip.y = yPos;
[Code]....
How do I reference my instances by name
View 1 Replies
Jul 23, 2009
I'm trying to access an instance by using a variable but when I try to manipulate a property to the instance (by referring to it with a variable) it only recognizes it as a string... for instance... (pun intended??)
public var prevbutton:String = "btn1";
trace(["page"+prevbutton]);
// which traces - pagebtn1
trace(pagebtn1);
// which traces the instance class - [object btn1pageclass]
I want to call the instance by using a variable... how do I do this?
View 11 Replies
Jun 3, 2011
What I am basically trying to do is Like,the yellow boxes are dynamically made,with Actionscript Code: new Sprite(); inside that red and blue are also made with new sprite(); with instance names yellow1(red1,blue10),yellow2(red2,blue2) etc... How can I refer to yellow1.red1?Like,these are dynamically made,and i dont know the limit,like say it adds on with each click,It will make Actionscript Code: 'yellow'+i and red+i etc... How can I refer to the ith sprite when the user clicks?Suppose the user clicks yellow5,I want a reusable code that will refer to yellow5.red5
View 1 Replies
Jul 8, 2009
I have a button located in a movieclip which I want in its overstate to gotoAndStop a particular labeled frame located in a different movieclip. How do I go to a frame of "movieclip A" by interacting with an element of "movieclip B"? Must I sever the relationship between the button and the movieclip its in which I wouldn't want to do...?
View 3 Replies