ActionScript 3.0 :: Function Return More Than One Item Or Object?
Aug 16, 2011I am trying to move text movies and textfields around a stage. This is a learning curve for me. I am confused by an example I have found on the internet.
[Code]...
I am trying to move text movies and textfields around a stage. This is a learning curve for me. I am confused by an example I have found on the internet.
[Code]...
I'm having some troubles with the use of interface and inheritance in AS3. I've done lots of OOP in the past and what I'm trying to do seems obvious to me, but doesn't work in AS3. The question is : Is it possible to override a function that return an Object of class A, and make it return an Object of Class B which extends A ? It seems not to be possible, since I'm getting a signature error in Flash, when compiling. For example, the following set of class do not compile (the code in function definition doesn't matter):
[Code].....
I'm trying to create a function that determines which of 4 similar classes to create, and returns the new object itself.
Basically, I have a base class (Panel) that has 3 additional variations in layout, each of which has a subclass: TextPanel, FeaturePanel, and LinkPanel. The two parameters for my function are the "kind" of window to create and its name ("linkString"), both of which are provided by external XML. I'm wondering if it's even possible to return the new Panel as an object...?
My code will probably explain this better than I can:
Code:
// create the new Panel variable ("addPanel") with a call to newPanel:
var addPanel = newPanel(linkList[i].attribute("kind"), linkString);
Code:
// newPanel function:
[Code].....
within the Panel constructor, the provided string (linkString / 'h') is set as the Panel's .name. I did not copy that function into the subclasses, since they inherit it - unless I'm mistaken.
is it possible to send a string to a function and return a object??? here is the code, but it doesn't work
[Code]....
How can I return an object with an update data, that is pass in to a public static function?
GetDate.dayName(MyDate.setDate(1984,3))
//MyDate with new info (year, month) will be pass into GetDate.dayName
package hwang.time
[code].....
I want to be able to select an item from my list component and fire a function directly related to selecting that item. list is called "tidlist" function is "selecttid(n)" the "n" needs to be replaced with the index number... so if run my swf and the list component displays my items... when i select one (the third one for example)... i want to fire "selectTid(3)".... cant seem to grasp.
View 1 RepliesI want to be able to select an item from my list component and fire a function directly related to selecting that item.
list is called "tidlist"
function is "selecttid(n)"
the "n" needs to be replaced with the index number... so if run my swf and the list component displays my items... when i select an item (the third one for example)... i want to fire "selectTid(3)".... cant seem to grasp.
I want to return just 1 item in the filtered array.[code]I want "arr" to contains just one item.
View 3 RepliesI have populated a List component with data from an XML file. I simply want the index of the line clicked returned so I can gotoAndStop to that Frame number. I have found the 'selectedItem' property but I don't want the text, I want the number of the line.
View 5 RepliesI'm using an AMF service that was built by someone else. Basically what happens is that some info is passed to the AMF service and it returns true or false.I want to be able to pass in various info to the a function that calls the AMF service(submitTracking) and then get the true or false value returned in onResultSubmit to be passed back to submitTracking.
var screen:String;
var buttonnumber:String;
function submitTracking(screen:String, buttonnumber:String) {
[code]....
Is there a way to return the target of a Tween object from within the object?
Code:
myTween.onMotionFinished = function (){
trace (this.target)
}
That's obviously not the way you do it, but that's what I want it to be...
It seems that dropTarget only returns the name of the object that is directly under the mouse. Does anyone know whether there is a simple way for it return the name of the object that is under the entire bounding box of the object being dragged?
View 1 RepliesAnyway, I have a function that goes through an XML file, looking for a specific value. If it finds it, it should return the node that contains that value. However, I'm having trouble with the whole return part of it.My code is:
Code:
thisExpando.onRelease = function() {
trace("is this me? " + this._name);
[code].....
I am trying to have the function toggleClick return powerData. I need to store powerData in a variable and have it passed to another function to do calculations.
Inside the function toggleClick, I am assigning powerData to houseArray[e.currentTarget.name.toLowerCase()];
var powerData:int = houseArray[e.currentTarget.name.toLowerCase()];
I tried just to write return powerData--but it breaks the program.
// function toggleClick
function toggleClick(e:MouseEvent) {
// Store "Power" Values of House Objects in Array
[code].....
I'm communicating to these movie clips with another program via binary sockets.For the first set of movie clips: when it recieves its instance name, and a second number (InstanceName+#) from the socket, the named movie clip will jump to the frame corresponding with that number. for ex:if the incoming data from the socket is (mc7+3), then movieclip 7 will jump to frame 3.
For the second set of movie clips: when it recieves its instance name, and a second number (InstanceName+#) from the socket, the named movie clip will move location across the screen, by the y coordinate moving to the # given by the socket...thats a little confusing. for ex: if the incoming data from the socket is (mc4+500), then movieclip 4 will move so that it's y coordinate is at 500.[code]...
After reading about classes, package, namespace and classpath till not able to understand what is the best way to write classes....
Here I am facing problem with this error can you tell me what mistake I am doing here.[code]...
How can I return a value from within a timer function? This doesn't work:
if (timeOneSec()) {
doSomething ();
}
[Code]...
I have several buttons calling the bounceOut() function andthe bounceOut() function calls the onMotionFinish() function. Afterthat function is finished I want to go back to the original callingFirst a call is made to bounceOut() when a button is clicked.I have ten buttons.
function bounceOut() {
var smSlide:Tween=new
Tween(sideMenu_mc,"x",Regular.easeOut,200,-200,2,true);
[code].....
there is an interesting problem here:
How to return a value from a function to public?
Here is the code:
var df:String; //i declared it here
function onResult(e :OperationEvent):void
{
df = e.data.toString(); // i set it here
[Code]...
How do make a function return *, by star, I mean the function is able to return anything, and then I can typecast it accordingly?
[Code]...
I basically have a class which loads a set of MovieClip objects and provides accessor functions to return them.[code]Obviously this doesn't work, but it gives an idea of what I'm trying to do. I want to return a MovieClip to the calling code only if the object has been loaded.
View 2 RepliesI have one function "Login" and function "_urlSended" inside of function "Login". So i want that sub function returned value as a parent function. I just want that script to work
<![CDATA[
function onButton1click():void {
Label1.text = Login('irakli', 'password1');
[Code].....
It doesn't appear to be possible to get the return type of a function. Is this correct?
View 1 RepliesI've run into a bit of a snag on this slideshow I'm trying to create. My plan involves adding movie clips from the library by attaching them to an empty movieClip. Then using setInterval and a variable as a counter, it increments in the function. When the number reaches "20" the first movieclip is removed and the next one is displayed. Here is my code:
ActionScript Code:
createEmptyMovieClip("canvas_mc", 1);
canvas_mc._x = 75;[code]....
//How do you bring on the second slide when the first is removed? So, my problem is that I'm thinking that the return value from my function should be 20 but instead I get 0 in the trace statement.My plan was if it equaled 20 to bring the next slide out from the library, thus moving forward with the slideshow.
In the code below - fRequest_activate initiates a sendAndLoad - all fine and dandy. Thing is - I want to be able to return a value from this function that indicates whether the server response was satisfactory - and I can't work out how to to it.Because the onLoad function is nested within my fRequest_activate function it has all got a bit messy - and just doesn't work - how do I pass the status from an asynchronous server call - which at the moment is picked up by the onLoad callback, back to my original function? - or should I just approach this problem in a different way? All I want to do is call one function - and know if it has been successful or not in talking to my server.
Code:
function fRequest_activate():String {
var lvEmail_send:LoadVars = new LoadVars();
var lvEmail_response:LoadVars = new LoadVars();[code]...............
I'm trying to define a variable as a function that loads a text file, like this:
ActionScript Code:nouns = loadFile( "nouns.txt" );
The problem is I can't see how to get "loadFile" function to return the value because I have to use that event listener function to tell when the load is complete, then I can't return from inside the listener function... how can this work?
[Code]...
I was just curious if you HAVE to assign the return value of a function to something in order to preform operations on it.
Code:
something.getClip().onRelease = function() {
//
}
Thats probably illegal right? It's illegal in C++, but theres usually a way to get around it like.. (getFocusClip()).onRelease. Or should I just forget it and do it the right way:
Code:
var tempClip:MovieClip = something.getClip();
tempClip.onRelease = function() {
//
}
Ok, I have a function that creates a button, it takes the paramaters
bX, bY, bcColor, bbColor, bHeight, bWidth, bHandle;
here is my function
Code:
function createButton(bX:Number, bY:Number, bcColor:Number, bbColor:Number, bHeight:Number, bWidth:Number, bHandle:MovieClip)
{
[Code]....
some reason when I try to hide Handle, it doesn't do it, & trace's dont do anything either it is suppost to create the button & store it in any handle I give it
The title of this post may not make much sense, let me explain. I have a function:
findSurface(origin:Point, vector:Point, attempts:Number):Point The function has an obscure use, but the idea is thus: given those three arguments, returns a point IF the 'line' (created by the origin and vector arguments) intersects the object the function is called on. [but that is another story...]
More importantly, if there is no point of intersection at all, what should the function return? Void? Null? Undefined? Object? Or can I use one of those return types instead of Point incase the function does not encounter an intersection?
Is there a way to return URLVariables from a function
eg:
function varsLoaded():URLVariables {
var variables:URLVariables = new URLVariables();
variables.var1 = 'string1';
[Code]....
Now what I would like to do is assign "variables" to a variable:
var theVar = varsLoaded();
trace(theVar.var1);
Obviously the code above isn't correct; just to illustrate what I'm hoping to accomplish.