ActionScript 3.0 :: Passing A Function Around?
Feb 24, 2009
so, i think it's just cause it's the end of the day and my brain wants to quit, but i would like some input.
im trying to pass a function to a question box that when you click the YES button the function passed in will fire for some reason im having a hard time holding the function until the YES is clicked.
here is what i got Code: //the call that opens the choice box and sets the info the gui_obj part is cause the //funciton is in a separate class file gui_obj.displayChoice("Add the cell phone to your inventory?", "YES", "NO", gui_obj.addToInventory(item))
[Code]...
View 5 Replies
Similar Posts:
Apr 21, 2010
How do I execute callback functions dynamically by passing a function in as an argument to another function?
Look at this example:
Code:
package {
public class myClass extends MovieClip {
public function myClass(callback) {
[code]....
View 2 Replies
Sep 16, 2009
I need to pass a variable to a function inside a function. However this parameter (i) seems not to be passed (to function ...onRollOver). This is required to attach a textfield to a movieclip (reading the adress and showing it as a tooltip).
ActionScript Code:
for (i=0; i<array_BE_ElecCities.length; i++) {
var attachElecCity = mc_map.mc_places.attachMovie("Plant",
[code].....
View 1 Replies
Apr 20, 2011
I im trying to pass one a var from one function to another, Im trying to pass 'THICKNESS' from 'moveMouse' to 'mouseDown'.
ActionScript Code:
var THICKNESS:uint = 1;
ActionScript Code:
function mouseDown(_x:Number, _y:Number):void {
[Code].....
View 4 Replies
Aug 19, 2010
I'm new to AS3, I have an index.swf that loads thumbnail images from this file (projects_list.xml). When the user clicks on a thumbnail image I want it to pass the selected thumbnails "link" node information to the callFull function. You can see that I have managed to get it to work when I use the real path name. I just can't figure out how to pass the link node text.
Projects_list.xml file set up
Code:
<project id="0" name="Con" thumb="portfolio/images/con/thumbs/web_1_200pix.jpg" htm="" link="portfolio/xml/desc/desc_con.xml"></project>
desc_con.xml file set up (details file)
[Code].....
View 1 Replies
Mar 19, 2009
I have 3 movieclips in the Libarary, called (both by name and class) section0, section1 and section2.This works for instance to attach a movie clip to the stage:
Code:
var myMovie:MovieClip = new section1;
addChild(myMovie);
[code].....
View 2 Replies
Feb 21, 2011
Trying to create a random movement for fish MCs:
//----------------------
var deg2rad:Number = Math.PI / 180;
var speed:Number = 1;// set to speed you want
var numFish:Number = 4;
[Code].....
Problem I have is that they all move to the same angle (the last one created).
How do I pass the different "my_angle" values to the "move_me" function...?
View 7 Replies
May 6, 2009
How do I pass mulitple variables from a function using AS3? Does this have to be done using a Class?
example:
var endValue; // variable I want to fill
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, dataLoaded);
[Code].....
View 8 Replies
Jun 8, 2009
This is a function on the first frame of a .fla updated to AS3 from an old AS2 file:[code]When the function is called it should set "max_messages" to 600 in AS3, right?
View 1 Replies
Sep 4, 2011
I have 2 methods in a class and 2 properties. The first method fetchXMLData() gets data from an XML file. In the addEventListener method on the urlLoader object, I pass it a listener which tries to set the returned data to the xmlData property. However, it never sets it, and I know the data comes back because I can alert out urlLoader.data using the mx.controls.Alert component.
[Code]....
View 18 Replies
Oct 8, 2009
I have a movie clip that contains several movie clips, only one of which should be shown at a time. Which one is shown, depends on what buttons the user selects.Having trouble with the syntax for passing the argument in a button to the function that controls the tweening of the clips. (When I hard code the references into the function, it works, so I know the basic function is ok).There's a clip called 'slide1_mc' which contains various MC's to be shown based on user selection (in this case, using 'system' clip as the first one already showing). Here's the code in the parent clip of that item:
Code:
var currSection = slide1_mc.system_mc;
function changeSection(newSection):Void {
TweenLite.to(currSection,.3,{_yscale:200, _xscale:200, _alpha:0});
[code]....
Here's one of serveral buttons that will control the content to be seen:
The code in the button is:
Code:
var changer = slide1_mc.software_mc;
smallButton.onPress = function() {
_parent.changeSection(changer);
};
So - the initial part of my function works so I know my 'external' initializing of "currSection" is working (that clip is zooming/fading out)... but then the clip that I want to fade in isn't doing anything.
View 0 Replies
Jan 20, 2010
I'm creating a jeopardy like game and have run into a problem. when you click on the dollar amount a create a sprite on the fly and inside the sprite is a shape and some textfields. One of the fields is an input box. once you enter in an answer and press enter I create another sprite with a textfield inside it to let you know if the answer is right or wrong. Herein lies the problem. once your told if your right or wrong, I want the sprites to stay on the screen for 3 seconds then disappear.
I can get them to stay on the screen, but I can't get then to disappear because I can't pass the sprite to the function that I created to remove them. So everything works except the remove function. This is the error I get when the remove function runs: "TypeError: Error #1009: Cannot access a property or method of a null object reference."
I'd post some code but its broken What I'm looking for is just information on how to assign a sprite to a variable so I can use it in a function. if thats not possible then is there a better way to do what I need done?
View 2 Replies
Aug 5, 2010
Hello, I'm trying to minimize code, so I am trying to use functions, and need to pass some strings through them in order for it to work.I believe I may be doing this incorrectly, so could someone please take a look and tell me what I'm doing wrong? On one of my movieclips:
[code]...
What that previous code should do is loop through all movieclips in the game and if it's not named player, move it in accordance to what "Direction" is.If the player is pressing the arrow down key, it will change "Direction" to "DOWN" and hopefully pass it.
View 4 Replies
Aug 19, 2010
I have an index.swf that loads thumbnail images from this file (projects_list.xml). When the user clicks on a thumbnail image I want it to pass the selected thumbnails "link" node information to the callFull function. You can see that I have managed to get it to work when I use the real path name. I just can't figure out how to pass the link node text.
[Code]...
View 3 Replies
Feb 23, 2011
If I remember correctly, objects are being passed to functions by reference, so I wrapped my primitive variable into object but did not get the resilt I wanted. I combed this group to see the solution and found only this one:
function changeObjectStatus(obj)
{
return obj.status = true;
}
[Code]....
var v seems to be a new object rather then a reference to the old one. and changing v does not affect the original object.
Does this mean that if I want the function to work with several variables, I need to create a separate object for each variable?
View 2 Replies
Oct 19, 2011
when doing something like passing an array of movieclips to a function then trying to access the name of the movieclip (a[i].name) why does it give instance names instead of the names passed in.
Here is example code from a function I'm trying to use to enable whatever navigation movieclips i pass into it:
ActionScript Code:
function enableNavButton(a:Array):void
{
for(var i = 0; i < a.length; i++)
{
[Code]...
View 3 Replies
Apr 8, 2009
i have been playing with the Zend Tutorial - and all works fine... however, stuck on something that i found quite easy in amfphp/as1&2
In AS3 - i am using NetConnection and i want to pass arguments to my php function
The first function i show here works fine....
inMyPhp...
Code: Select allpublic function getTutorials()
{
$result = mysql_query("SELECT * FROM testTable");
$t = array();
[Code].....
View 1 Replies
Jan 12, 2004
I have a global function that does some stuff with a LoadVars in it.I 90% of the cases, the onLoad reference of the LoadVars is the same, but I sometimes need to do something else when the LoadVars is loaded.Is there a way to pass a function reference to a function so that I could do something like that :
[AS]
_global.function myFunction(maybeFunction)
{
myLoadVars = new LoadVars();
[code]...
View 1 Replies
Feb 3, 2006
way to say the same in just a few line of code? 25 lines of code people
[AS]menuAS = function () {
//TIOCCHA
menuBar.menu01.menu01_btn.onRelease = function() {
[Code]....
View 6 Replies
May 12, 2007
Here is the code that I have right now (it obviousvly doesn't do what I want it to):
Code:#include "lmc_tween.as"
orig_x = mc_01.black_bkg._x;
orig_y = mc_01.black_bkg._y;
function buttonIn() {
What I want to be able to do is pass the name of the movie clip (ie mc_01, mc_02...) to the function, and have the function effect that particular movie clip. I had this code that didn't work
[Code]...
View 6 Replies
Aug 31, 2007
Been looking everywhere to find out if there is a way to do this:
[Code]...
Anyone know Of a way to accomplish this without having to use an if/then statement
View 4 Replies
Oct 16, 2007
[code]how to get my target variable in my function to work? I am trying to make it the movieclip in which to make the text field.
View 2 Replies
Jan 18, 2008
im making a function that limmits text to a specified number... only problem is i cant seem to pass in the text var that contains the text
Code:
var textF1:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam neque purus, aliquam sed, sagittis tincidunt, adipiscing ac, urna. Ut libero urna, nonummy sodalesxxx";
[Code]....
View 1 Replies
Apr 25, 2008
I'm trying to do something like this and it doesn't work, but I get no errors.
callback = function(){
//bla bla bla
}
[code]........
View 5 Replies
Jul 28, 2008
I have this script that reads pictures and links of the pictures from the an xml file, display the picture and then put the link for the image, but I can't seem to pass the link to the onRelease function anyone can help me on this, below is the code:
[code]...
View 4 Replies
Apr 7, 2009
i am loading an image with a loader, and in onComplete function i would like to call calculateRatio function and pass it Loader.content.width and Loader.content.height so it can compare it with the current stage width and height and resize image proporcionally to fit the screen. how would i go about passing that parameters?
[Code]....
View 4 Replies
Apr 8, 2009
In my database i have a field called "live", and i only want to grab entries in a table that have "live" set to "1"
This is what i have tried, but it doesn't work....
InMyPhp...
PHP Code:
public function getTutorialsLive($live)
{
$result = mysql_query("SELECT * FROM testTable WHERE live = '%s';", $live);
[Code]....
View 1 Replies
Sep 11, 2009
how can i pass array elements as parameter in function ?
View 2 Replies
Oct 11, 2009
I'm trying to achive the following, but it doesn't work..[code]
View 1 Replies
Apr 9, 2010
It seems that with as3, the error compiler is just waiting to get you.I have a function that loads in an external swf. Which swf depends on which button they click. So, it could be pic1.swf, pic2.swf, pic3.swf, etc.
function loadMovie(){
my_mc.addChild(my_Loader);
addChild(my_mc);[code].....
When i test, I get "error: access to undefined property myVariable.
View 3 Replies