473,800 Members | 2,518 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Named functions with return values

69 New Member
Hi,

I would like to change the following anonymous to a named function which receives the newsID as an argument and returns the title, content and image of the article (which are currently done within the function).

Expand|Select|Wrap|Line Numbers
  1. titleMC.onRelease = function()
  2. {
  3.     varSenderContent = new LoadVars();
  4.     varReceiverContent = new LoadVars();
  5.     varSenderContent.newsID = this.newsID;
  6.     varSenderContent.sendAndLoad("localhost/GetNewsDetail.php", 
  7.          varReceiverContent, "GET");
  8.     varReceiverContent.onLoad = function() 
  9.     {
  10.          for (p in this) 
  11.          {
  12.               if (typeof this[p] == "string") 
  13.               {
  14.      articleContent = this.data.split('~');
  15.      _root.copy_mc.article.text = articleContent[1];
  16.      image = "http://www.bemod.co.uk/images/newsImages/" + 
  17.                        articleContent[2];
  18.                                 var CTNR_WIDTH=525; //original width of container            var CTNR_HEIGHT=156; //original height of container
  19.                                 loadMovie(image, "_root.photo_mc"); 
  20.                                 _root.photo_mc._xscale=CTNR_WIDTH/800*100;                            _root.photo_mc._yscale=CTNR_HEIGHT/600*100;
  21.                                 _root.title_mc.title.text = articleContent[0];
  22.             }
  23.         }
  24.     }
  25. }
  26.  
For calling the function I think I use the following syntax, once it's been given a name,
Expand|Select|Wrap|Line Numbers
  1. titleMC.onRelease = returnArticleContent( newsID )
but how do I retrieve the values that I returned from the function?

Thanks,

Sean
Aug 30 '07 #1
3 3892
xNephilimx
213 Recognized Expert New Member
Hi, you cannot make a function return multiple values, what you can do is make the function do all by itself without returning anything, or returnan array or an object and use that returned array/object to do whatever you whant.
Anyway, you cannot call a function that return values the way you did, that way the button will recieve the returned "something" . You need to call the function from a variable, so the variable will be the one recieving what the function returns. Like this:
Expand|Select|Wrap|Line Numbers
  1. titleMC.onRelease = function() {
  2.      //if the function returns an array:
  3.      var some:Array = returnArticleContent; //yes, if you dont pass parameters, you don't put ();
  4.     //if the function returns an object:
  5.      var some:Object = returnArticleContent;
  6.  
  7.      //now do whatever you want with the "some" variable.
  8. }
  9.  
If the function returns an object, the variable will become that object. And then you can work with that variable -now an object- and do whatever you want width it.

Kind regards,
The_Nephilim

PD: Sorry if I missed any "k", I'm not in my house and this eyboard sucs

Hi,

I would like to change the following anonymous to a named function which receives the newsID as an argument and returns the title, content and image of the article (which are currently done within the function).

Expand|Select|Wrap|Line Numbers
  1. titleMC.onRelease = function()
  2. {
  3.     varSenderContent = new LoadVars();
  4.     varReceiverContent = new LoadVars();
  5.     varSenderContent.newsID = this.newsID;
  6.     varSenderContent.sendAndLoad("localhost/GetNewsDetail.php", 
  7.          varReceiverContent, "GET");
  8.     varReceiverContent.onLoad = function() 
  9.     {
  10.          for (p in this) 
  11.          {
  12.               if (typeof this[p] == "string") 
  13.               {
  14.      articleContent = this.data.split('~');
  15.      _root.copy_mc.article.text = articleContent[1];
  16.      image = "http://www.bemod.co.uk/images/newsImages/" + 
  17.                        articleContent[2];
  18.                                 var CTNR_WIDTH=525; //original width of container            var CTNR_HEIGHT=156; //original height of container
  19.                                 loadMovie(image, "_root.photo_mc"); 
  20.                                 _root.photo_mc._xscale=CTNR_WIDTH/800*100;                            _root.photo_mc._yscale=CTNR_HEIGHT/600*100;
  21.                                 _root.title_mc.title.text = articleContent[0];
  22.             }
  23.         }
  24.     }
  25. }
  26.  
For calling the function I think I use the following syntax, once it's been given a name,
Expand|Select|Wrap|Line Numbers
  1. titleMC.onRelease = returnArticleContent( newsID )
but how do I retrieve the values that I returned from the function?

Thanks,

Sean
Aug 31 '07 #2
Sebarry
69 New Member
Thanks so much. That's perfect. You star!!!!

Hi, you cannot make a function return multiple values, what you can do is make the function do all by itself without returning anything, or returnan array or an object and use that returned array/object to do whatever you whant.
Anyway, you cannot call a function that return values the way you did, that way the button will recieve the returned "something" . You need to call the function from a variable, so the variable will be the one recieving what the function returns. Like this:
Expand|Select|Wrap|Line Numbers
  1. titleMC.onRelease = function() {
  2.      //if the function returns an array:
  3.      var some:Array = returnArticleContent; //yes, if you dont pass parameters, you don't put ();
  4.     //if the function returns an object:
  5.      var some:Object = returnArticleContent;
  6.  
  7.      //now do whatever you want with the "some" variable.
  8. }
  9.  
If the function returns an object, the variable will become that object. And then you can work with that variable -now an object- and do whatever you want width it.

Kind regards,
The_Nephilim

PD: Sorry if I missed any "k", I'm not in my house and this eyboard sucs
Sep 1 '07 #3
xNephilimx
213 Recognized Expert New Member
You're welcome Sebarry.
Good luck with your project.

Best regards!
The_Nephilim

Thanks so much. That's perfect. You star!!!!
Sep 2 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2273
by: BlueDragon | last post by:
The place where I work is moving to MS SQL Server from Lotus Notes. I have done a lot of coding in Lotus Notes, and have, I suppose, intermediate skills in basic SQL -- queries, insert, updates, table design, etc. I have a couple of questions, however. First, stored procedures vs. functions. In my world, a function is a body of code that returns a value; a procedure is a body of code that does things but does not return a value (other than...
2
3793
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to produce two messages having the same message digest. That conjecture is false, as demonstrated by Wang, Feng, Lai and Yu in 2004 . Just recently, Wang, Yu, and Lin showed a short- cut solution for finding collisions in SHA-1 . Their result
6
6161
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but my mappings between named colors, HEX values and the Long Integer values used in Access are not jibbing. Anyone have a nice list laying around? Danny J Lesandrini dlesandrini@hotmail.com
14
1429
by: Kejpa | last post by:
Hi, I have a function Sum as.... Function Sum(ByVal ParamArray Values() As Double) As Double Dim rSum, itm As Double For Each itm In Values rSum += itm Next Return rSum End Function
2
1421
by: Ben Voigt | last post by:
I have a function that is called for several distinct reasons. It is conceivable that a subclass would want to handle those cases differently. Therefore, what I want to do is have multiple v-table slots, all pointing to a common base function. These functions should be protected, not public. Here is a short example of what I'm trying to accomplish: class XYZ {
14
3275
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To make things simpler and better readable I'd make all default parameters named parameters so that you can decide for yourself which one to pass and which not, rather than relying on massively overlaoded methods which hopefully provide the best...
36
2733
by: Pacific Fox | last post by:
Hi all, haven't posted to this group before, but got an issue I can't work out... and hoping to get some help here ;-) I've got a base object that works fine with named arguments when called on it's own. However when I call the child object I get an error " has no properties (in firefox)." I simple test:
1
19412
MMcCarthy
by: MMcCarthy | last post by:
Access has a number of built-in functions which can be generally used in queries or VBA code. Some of the more common ones are: Note: anything in square brackets is optional Date Functions Date() - Returns the current system date Now() - Returns the current system timestamp (date and time)
9
3992
by: Gabriel Rossetti | last post by:
Hello, I can't get getattr() to return nested functions, I tried this : .... def titi(): .... pass .... f = getattr(toto, "titi") .... print str(f) .... Traceback (most recent call last):
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10273
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6811
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.