ActionScript 3.0 :: Returning Multiple Objects From Function?
Jun 22, 2010
I have a function that returns an object full of data pulled when an XML file gets parsed. But I also need to use an array object with additional data. That array also gets built in the same function. Is there a way to return both? I am trying to get both the "Obj" and "SlideTime[idx]" data to use as globals.[code]
I am building a scrolling image bar, so I've created code that works perfect on one object. However, I need this code to apply to multiple objects at once so that they will move left and right and resize independently from each other (to give this sort of 3d revolving look). Other boxes will be to left and right of the current black box. Code is below as well as link.
Code: function mousetracker(object){ boxstartx=object._x; boxstartwidth=object._width;
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] .....
I've got an issue with resizing multiple similarly named objects.I've got the following code that works: mc0.nb0.autoSize = "left"
nb0 is a text box placed inside mc0, which is a movie clip. My script simply resizes the box, according to the ammount of text inside it. what I'm trying to achieve is a more dynamic code that would work for no matter how many boxes...I tried something like "mc"+i."nb"+i. autoSize = "left", but I get a syntax error. So, how do I call the MC inside the function?
I have an object array into which I've pushed a number of objects with different variables :- myArray.push({myRef: 1, myValue: "W"}); I can sort the array in numerical order using :-myArray.sortOn("myRef", Array.NUMERIC);but after sorting I would like to collapse the array using something along the lines of :-myArray.join("");to join the OTHER variable (myValue)...Is it possible to do this without pushing every instance of 'myValue' to another array and then joining that?
Is the same possible in ColdFusion? Currently I am using .Net/Fluorine to return objects to the client. Whilst in testing I like to pass strings representing the select statement and the custom object I wish to have returned from my service. Fluorine has a class ASObject to which you can set the var 'typeName'; which works great.
I am hoping that this is possible in Coldfusion. Does anyone know whether you can set the type of the returned object in a similar way. This is especially helpful with large collections as the flash player will convert them to a local object of the same name thus saving interating over the collection to convert the objects to a particular custom object.
I am refactoring some code. I have a PHP page that contains a MySQL query and stores the result in a PHP variable $my_result. This result is then echoed to a Flash SWF during embedding with SWFObject. I now want to call this PHP page that makes the query from a javascript function like so - one change I have made to the PHP is that instead of storing the result in a variable $my_result I am echoing the result. Javascript function to call the PHP page and make the database query
I have an external function that needs to return a customerID value. However, it seems to be returning the initial value instead of the value that I believe is being set within the function.[code]
I have a variable which needs to be updated upon user input. It works inside the function, the trace function returns the correct type, but for a reason it wont pass it on the variable on the main timeline.[code]
Say I have four sub-classes of 'Car'. One for each color. I want to have one function that can build and return a 'color-car' sub-class based on the passed value. This is a dumb example, I know, but it is precisely what I am trying to do only on a smaller scale.
public class Car { } public class BlueCar extends Car
[code]....
Ok. You get it. This doesn't work for a reason unknown to me. I get 1118 errors which complain about conversion of BlueCar into Car, etc...
I need to load data from a database, so I created the following function and placed it in frame 2 on the main timeline.
Code: getQuestionSet = function (category:String, subject:String, level:Number, count:Number):Array { var questionSet:Array = new Array(); var writeV:LoadVars = new LoadVars();
[Code]...
Whenever I try to call the function, it fails to set the value of the questions array. It always appears empty(questions[0]-questions[10] have the value undefined). But, if I check the values from within the function after I have set them, it works, so I know that it is receiving the values. What am I doing wrong?
Code: questions = getQuestionSet("Art and Music", "Art", 1, 10);
Here is an example of how I have would call the function.
I have a question regarding classes.[code]What i want is that clue() should return me the value of NetStatus which is generated in returnResult() when this function is invoked.Now in this case var "f" will become undefined because Clue() is not returning anything, so how can i find a way that value of NetStatusEvent.NET_STATUS (in this case) will be returned from Clue().Although i can use ENTER FRAME EVENT to check when it has generated a status but i'm sure that there must be a better way.
I am new to AS3 and need to gather data from an XML file, parse it and then return all the vars to be used globally. How do I return an object like in the code below?
Code: var dSession:Object = new Object(); function parseXMLData(incomingData:XML):Object
I am using Flex's Alchemy library to generate SWC's out of C files. I have a byte array (unsigned char buffer[size]) in the c-layer that I'd like to return to the ActionScript layer as a ByteArray. Do I have to iterate through the array and explicitly call AS3_Set on each element or is there a way to just return the entire C array at once?
I've been trying to implement a QuadTree to store a two-dimensional array representing a terrain. I generate the array first, then I use the below function to generate a QuadTree for the array.
I need to get the value inside a handler.. ActionScript Code: public function verifyUser(p:String):String{ var verify:String var variables:URLVariables = new URLVariables(); var varSend:URLRequest = new URLRequest("verify.php"); varSend.method = URLRequestMethod.POST; varSend.data = variables; [Code] ..... It's always returning 'null'. because its not waiting for the completehandler to be completed and just passes the null value of verify..
ok so i've been stuck on this for a while...What i'm trying to do is create a function that updates a global variable (randomVar) that is itself a parameter in the function e.g
[Code]....
Basically, i thought randomVar and vari were the same so when vari was changed randomVar would too but that's not the case. So how do i make the parameter equal the new value(5). I want to repeat the function using different variables so putting randomVar = vari in the function is not possible.
I have 5 buttons that onRelease (= when clicked) calls the same function with each a different variable.
contentLoader(profile); contentLoader(projects); and so on.
the function is:
function contentLoader(sName:String) { trace(sName); }
Now the trace returns 'undefined'...I just do NOT see it anymore The idea behind is that I want to use a moviecliploader to load in the content corresponding with the clicked button (projects.swf, so it'll use myMCL.loadClip(sName + ".swf"); That trick always worked, but like I said, it keeps returning undefined. Did I make a mistake by strict data typing sName as a String?
I am working with code where the variable "k" is a counter. I stripped out the extraneous stuff from the code below - so essentially when the function onExamPlusClick is called, the counter "k" and the minutes of an activity in an array both increment (as well as other things not shown). I'd like to return "k" as well as "activity[0].minutes" to the main program. Since the function is a MouseEvent, I'm unable to change "void" to "number"... and not sure how to return (pass) those variables back to the ain program.
I'm trying to return XML from an event complete back to the main function, but can't figure out how to do it.Here's the functions I'm calling:Main File:
public var mySendAndLoad:SendAndLoad = new SendAndLoad(); mySendAndLoad.sendData(url,variables) The mySendAndLoad class:
However, on a bright note its coming!!!! So far, everything is going well and I am now seeing the light with AS3I do have a question on returning a variable from a function that loads an external CSS. This particular function is located inside a LoadStyleSheet.as class along with another public function that sets text properties to fields when accessed. What I am looking for is accessing the stylesheet after its been loaded in another class. I know in AS2 I could use the Delegate method for something similar to this situation. Not sure what the next step is for AS3. Anyhow, function script is below.
ActionScript Code: public function loadStyleSheetItem(loadStyleSheet_str:String):void { var styleSheet_css = new StyleSheet;
In C you can pass a reference to a data item as a parameter to a function. then within the function you can write to that address thus passing back a value to the caller. Can you do anything similar in AS3?
I know you can use the return statement but I want to return a status by that mechanism plus a value in a parameter.
i am trying to return an XML object, but having issues. The object is only created via an Event.complete function. I need to return the XML created from my loadXML function via my grabXMLfromFile function.
Code: function grabXMLFromFile(attrPathToXML:String):XML { var fileUrl:String = attrPathToXML; var myUrlRequest:URLRequest = new URLRequest(fileUrl);
In Actionscript 2 I find that I cannot have a "private function set" without returning the error "A member attribute was used incorrectly." If I change it to "public function set" I'm fine but that defeats the goal of trying to protect the function from setting externally
I want to be able to drag any of the 4 objects onto any of the targets, right now all I can manage is to allow each object drop onto one specific target only.
I thought by calling all my target names by the same instance name eg target_mc that would work but only one target will ever work.