ActionScript 3.0 :: Return A Value(xml) From A Class?
Jun 10, 2009How would I return a value from this class?
package com.ryancanulla.utils
{
import mx.collections.ArrayCollection;
[code]......
How would I return a value from this class?
package com.ryancanulla.utils
{
import mx.collections.ArrayCollection;
[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 found myself loading a new XML file every day and so decided to create a small class that will load the xml file and return it.The class is loading the file but when i try to return it to a new xml object in the document class it doesnt load it.I think that it's something to with the return being in a nested function but i tried a few ways and non seems to work.
[DOCUMENT CLASS]
loadXML:LoadXML = new LoadXML();
myXML:XML = new XML(loadXML.loadXMLFile("gallery.xml"));[code].....
I am trying to write my first real class (it works when I just use trace statements). The main part of the function returns a value and since the constructor can not return a value I was not sure how to handle it, so I did this...
[Code]...
I created a class that returns and array. How can I access that return from my main timeline?
I just need to trace the return in this case.
GetTeams.as
Code:
class GetTeams {
public function GetTeams () {
var teamLoaderURL:String = "teams.jsp";
[Code]....
I am writing a method in a FileIO class called returnBMP()
The idea is: I want to pass it a file name, and I want it to return a Bitmap. ( not a loader )
The problem is that the only way I know how to pull a bitmap out of a loader is by creating an eventListener on the contentLoaderInfo for COMPLETE.
That just doesn't work in a return function. the return is executed before the bitmap is loaded. I get a null..
here's my code:
ActionScript Code:
public function returnBMP(img){
var bmp:Bitmap;
var loader = new Loader();
[Code]....
Possible to create something like the following[code]...
View 9 RepliesI have a question about return..example:
Code: var date: Date = new Date(); trace (date)//Thu Oct 8 23:05:51 GMT-0300 2009 How i can get a String return by a Class? The default return with a normal Class is ([object Date])... Constructor can`t return values... how i can make that? :p
I created a menu from a created .as extended Sprite class.
Except from this menu, I need it to return a String value of the item name the user selected.
i want to essentially classify a simple function in it's own .as file. the function compares integers. but i don't know how to call the class and receive a boolean return.
here's my class
package
{
public class CompareInts
{
[Code]....
so now i'd like to write something like this:
if (CompareInts(1, 5) == true). or output 'true' by writing trace(CompareInts(1, 5));
I have to implement a menu with icons using actionscript only. I create a data provider from XML and set
menu = Menu.createMenu(null, dataArray, true);
menu.iconFunction = iconFunction;
Till here everything is fine and my menu is presented, but only with labels.
I create iconFunction as following:
private function iconFunction(item:Object):Class
{
var st:Loader = new Loader();
st.load(new URLRequest(item.icon));
return ?;
}
how do I return my loader object as Class?
Is there anyway to include a function or overrite something in a class that'll output a custom string when the object is called as a string?
So for example if I created a class named "myClass" and I instantiated it:
Code:
var myObject : myClass = new myClass();
When I:
Code:
TextControl.text = "blah blah, " + myObject;
myObject is getting casted as a string. Normally it would output:
"blah blah, [object myClass]"
Is there a built-in function that recast the object as string? Is there anyway for me to change that string output? I know I can just make a public toString() method in the class or something, but just wondering if there was something better.
This is class for xml:
ActionScript Code:
internal class RandomItem {
private var randomNum:int;
private var instantName:String;
private var itemsXML:XML;
[Code]...
I know how to pass a value to a class that need to be called, but how to call a class that returns a value?
can someone show me how to call it and how to write the class that returns a number?
I have an as3 class that I use for communicating with my Zend_AMF endpoint:
[Code]...
All of this works fine, but it takes a lot of work to use it. I always expect a Response object when calling send() on my request. Ideally I would like to be able to call request.send() and have it return a Response object directly and not having to deal with a listener: var result:Response = request.send(); Is this possible? If so, how can I go about doing this?
I'm making a custom class and all my get functions are working fine except the one that returns an array. Here is the code for my class (abridged to the relevant parts):
ActionScript Code:
/*
VolcanicIsland class for Polypelago
Script in progress
[Code].....
How do I get an array to return correctly? Doing trace(VI1.getData()[0]) doesn't work either.
I want to load an array with images in Main.as, by using a loader in another class. The problem is, I have to wait for the images to load before returning the array. How do I return the array images[] (once it's loaded) back to characterGFX[] in Main.as? I'm just lost.
Main.as
Code:
package {
public class Main extends Sprite{
private var gfx:Gfx = new Gfx();
[code]....
Im trying to set up a class which will load xml and return data I can later parse with a parser class.
When I run the getRawData function from the fla, I get [type function].
[code]...
I'm using a class that I converted from AS2 to AS3 using Patrick Mineault's converter: [URL]
The original AS2 class:
Code:
/**
* Colour handling routines
* Culled from many places:
* - http://www.actionscript.org/forums/s...d.php3?t=15155
[Code]....
Is the AS2 to AS3 conversion part of the problem (aside from my ignorance of how to use it)?
I have a CSV reader class that parses a CSV file.....
1,11.15126526
2,11.28306635
3,10.78296071
4,10.79878325
The CSV reader class works and produces a Vector.<Point> ... However the container class (which includes an instance of the CSVFile class) needs to access the resultant Vector. Whenever I 'return' the Vector.<Point> to the container via a CSV method it is always empty...I don't know if its something to do with the size of the Vector<> or what?
I have a class ErrorMessages which holds all my error messages as static constants. So I could access them like ErrorMessages.PASSWORD_INVALID or ErrorMessage.PASSWORD_TOO_SHORT. I want to know if it is possible to have separate classes that hold subset of these constants and access them like ErrorMessages.PASSWORD.INVALID or ErrorMessages.PASSWORD.TOO_SHORT, etc. This way I can more structured static structure and makes it much easier to use autocomplete. I tried few different ways and couldn't figure out if this was possible..
View 3 RepliesHow do you return data from a custom class, and only when something in the custom class has completed something. For example, let's say I have this code in the custom class[code]...
This, of course, doesn't work. I need the whatever.getLoadedObject() method to wait until the loading has finished inside the custom class then do whatever with the image loaded.
I currently have my own class, for arguments sake, lets say it's called User and is for logging into my own system.
I would like to call a function from the user class called, say, login(), which would send the username and password attributes to a service (in my case, PHP), and then get the data back with the response (either successful or unsuccessful).
This would ideally make my code behave like this:
Code:
var user1:User = new User("Jim", "password");
var loggedIn:Boolean = user1.login();
[Code]....
I don't know of a way of getting the login function to return a boolean based on the result of the HTTPservice it sends, so does anyone know of a better way of doing this?
I have a question about my xmlReader.as file about XMLReader class.this will be xmlreader class , but i can not take the data.
View 1 Repliesi was mugging on this tutorial :
[Code]...
The return a.attributes.first > b.attributes.first will return what value?
I'm having some problems importing a class, the message that Flash gives me is this; The class being compiled, 'ImageLoader', does not match the class that was imported, '[URL]'. The only line of code in my flash movie is this: import com.martijndevisser.*; And yes, the class is in that folder The class is from here: [URL] I've used the class before and it works fine, I just dont know what to do?
View 4 RepliesI have a button in frame 20. This button attached a script to go to frame 1. How do I add a script to this button or any other way so that I can know it was from frame 20 when I am in frame 1 ?
View 9 RepliesI just want when i press the button "VOLTAR" it returns to the first mc called "rest", to the fist page you seee when you open the fla.
View 0 Repliesin a function
function randomness(){
var randX:Number = Math.random();
var randY:Number = Math.random();
[code].....
I have define complete event handler and want to return value . But I lose "myString". I do not know how to return "myString" from loadXMLFile.[code]...
View 1 Replies