ActionScript 3.0 :: Returning More Than One Value?
Jul 14, 2009
ActionScript Code:
var temp = 1
function change(out){
out = 2
return "something"
[code]....
(I would do this if I had a function that returned a value already and I needed it to output more information - I'd pass it an output variable which it would fill for me)but in AS3 that doesn't seem to work - it seems changes I make to a function argument apply only within the function.
In as 2.0 there was a simple code like trace(_root._url) that would return the url of the actual swf file. What is the equivalent in AS3? The samples I found were all realted to window.location and other things, is there no simple code for this like in as 2?
I am trying to transfer a movie-clip staged in a swf(on local machine) to a remote server. Below is a part of the action-script code concerned with it;
function createJPG(mc:MovieClip, n:Number, fileName:String) { trace("sdf:"); var jpgSource:BitmapData = new BitmapData(mc.width,mc.height); jpgSource.draw(mc);
[Code]....
I want to close the swf when the upload is complete., I would like to know how to return a value(may be a number which I intend to use to indicate completion of file transfer) from the php script to the swf and how to receive that value in the swf?
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]
only issue i'm having is that if i drop the item in the zone requiring a change, and pick the item back up, it combines the shapes. I'm thinking I need to have the if statement more universal. I've uploaded my fla to rapid,I'll put my coding below as well.
I am trying to save settings to an XML File and setting the relevant data if the check box is checked or not.
private static function createXMLData():void { prefsXML = <preferences/>; prefsXML.application.@windowsstart =
[Code]....
well i assume that is what the error means, it cannot get details of something that is not set yet.. so how would i get it to check and if nothing then it is obviously a "false".
When using flash remoting with amfphp, what can I write in php that will trigger the 'status' method that I set up in my Responder in Flash? Or more generally, how can I determine if the service call has failed? The ideal solution for me would be to throw some exception in php serverside, and catch that exception in flash clientside... How do other people handle server errors with flash remoting?
I am makign something which generates a random number, then proceeds to check it against a range of fields loaded from an XML file. I have checked and the fields are loading the correct numbers in, but the "if" statement is always returning 'true'. The only time I have been able to get it to properly execute is when I use numbers instead of variables. I have tried using Number(variable), but that doesn't seem to fix anything. here is my code.
ActionScript Code: on (release) { _root.colnum = Math.round(Math.random()*100); if ((_root.colnum<=_root.wballmax) && (_root.colnum>=_root.wballmin)) {
I have a setter and getter method , the getter method should return an array collection but it's always returning an empty array collection even when I've run trace to check on it.[code]...
i have a MC, that contains a button, and when i press that button i need it to send the instance name of _parent.MC (instance name is "kala") to the variable "_root.eelmine".result must be: _root.eelmine = kala;
I decided to turn this util into a class because I use it in almost all of my projects. Basically what it is is I import an XML file and it has all these HTML characters like & or and my function basically converts those strings of characters to its regular form ie: ['&' (&] or [' ' ( )]
so calling it in a FLA file would be something like this:
Code: var entity:DeEntitizeHTML = new DeEntitizeHTML("bob & jim"); and here is my class file: Code: class com.dop.DeEntitizeHTML { function DeEntitizeHTML(my_str)
[Code]....
how to return that value back to the var entity in my FLA.
Is there any method that returns the Class name of an instance as a String? I would like to then pass that String as the parameter into the getDefinitionByName() method to create a new instance of that Class (whatever it is).basically, whatever I have stored in the variable 'currentPage' (which could be any number of classes I haev written), I want to create a new instance of (therefore re-instantiating it). this will then act as the method for a 'reload' button which is designed to reload whatever the current page/activity is.
A SWF (published as AS2 for player version 9) sits on a page called home.aspx with other textual content. The SWF is a wrapper that loads in various other SWFs based on flash cookie data. Here is the problem: In I.E. (and not Firefox), sometimes the wrapper SWF hangs and fails to load the external SWFs.
The only time this happens is when returning back to this home page via another link that ends in a hash mark (home.aspx#) or to (default.aspx) which is supposed to act the same as home.aspx Also, this doesn't happen every time. Only sometimes. Anyone have any clues? I'd love to provide a link but this is on a beta server at the moment and I don't think I'm allowed to.
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]
var aaa:Sound = new Sound (new URLRequest ("awd awd.mp3"));aaa.play ();trace (aaa.id3.artist);
The song plays but when I try to get the song's artist / album it returns null. I also tried copying the format from live adobe help website but it still returns null.
Also I have 3 songs named 1, 2, and 3 in a folder. I made a playlist type thing and it works fine, the only problem I see is that I would have to rename 30 songs.
Is there a way that I can obtain the name of a clip's children just like I can obtain the name of it's parent by using _parent?
Basically, I have a whole bunch of MovieClips that I have created through a function that parses an XML file. Basically, it's a custom-made Tree.
I have them all set up in their proper horizontal and vertical positions, but the one thing I'm having trouble doing is closing a branch on it. I've tried storing values in arrays to help me sort all the MovieClips on the Stage, but I must confess that I'm not good with arrays at all, so is there some sort of obscure function somewhere that can return the child clips, so I can do something like:
Code: myMC.onRelease = function():Void { if (myMC.hasChildMovies() == true) for (var i:Number = 0; i < myMC.childMoviesArray.length; i++){
I'm trying to track one of my characters as it moves across my stage, however it seems that samuraiChar's (my character) x position has a much higher decimal rounding system in place rounding to maybe 8 decimals where as the over object that I'm trying to track with it has only a 2 d.p rounding system. Can someone explain to me why this is and how I can fix it, also I may be wrong I'm not 100% sure if this is the problem.
how can I output the lower value inside an array of numbers? I have this but it is not doing the work, it is always returning the very first number in the array.
I have a color picker which I set usingMenu.ColorPicker.selectedColor = 0x339900;It displays the correct color when ran. If trytrace(Menu.ColorPicker.selectedColor);it traces 0. Why is this? Even stranger is later I set some xml parameters using
I built a class that parses JSON data, stores it in an array, and now I want to return that data so that it can be stores in an array in my root AS file. I'm eventually trying to pass the returned array to another class. My class looks like this:
1061: Call to a possibly undefined method payload through a reference with static type com.src.DataGrab.
Does anyone have advice on what might be wrong with my class, or a more logical way to write the getResults() function so that I can get retrieve the array being generated by this class?
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 think this is just a matter of fine tuning some different elements, but I'd like to know your take. I've got a Flex app, using the Flex 4 data services, communicating with Zend AMF services. One of the services returns all the results in a database using SELECT * FROM table there are ~1200 rows (140KB package size).
My problem is the response time, it's rage inducing. Total duration is always between 7-8 seconds. All but about 150ms of that is latency. I broke up the PHP to figure out exactly where the latency was and turns out return $rows is eating up ~6.8sec latency. I can deal with 1-2sec, but when I start waiting around for 8sec I feel kinda dumb. I cross checked the query response speed directly from the database, and just like I was expecting the total query time is 45-60ms.
PHP, this is basically just the generated Flex data service code, although in production it isn't the same:
public function getAllProject_entries() { $stmt = mysqli_prepare($this->connection, "SELECT u.* FROM $this->tablename u");
in AS3 I'm trying to load a URL (a Yahoo address) into the application so I can process the source code and pull things out of it.However, when I load it, or any other page, I get 0 bytes back.Here's my current code.
private function doSearch():void { var req:URLRequest = new URLRequest("http://yahoo.com"); var loader:URLLoader = new URLLoader();
I can use toString() to return any string desired when using trace(instance), is it possible to return other types of objects?For example, I may have this class:
public class List { private var _content:Array = []; public function add():void{} public function remove():void{} }
I normally need to make a getter that returns the _content, eg:
public function get content():Array{ return _content; }
So that I can do things like:
for each(var i:Object in myList.content)
Can I make myList in the above case actually return the value of content automatically? So that I can do like:
trace(myList); // item, item, item (similar output as tracing an array) for each(var i:Object in myList)