how may I store values to function's arguments? REFdn7045338143

View: New views
3 Messages — Rating Filter:   Alert me  

how may I store values to function's arguments? REFdn7045338143

by dennis-121 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some times, the one result of a function is not enough, cay we use the
arguments to get back values from them?

 

internal function getXY(x:int,y:int):void{

  x=10;y=20;

}

 

internal function test():void{

  var x:int; var y:int;

  getXY(x,y);

  trace("x: "+x.toString()+" y: "+y.toString());  // here I get "x: 0 y: 0",
I want to get "x: 10 y: 20"

}

 

For instance, in c the getXY should be like this:

 

internal function getXY(int* x, int* y):void{

  x=10;y=20;

}

 

dennis

 


Re: how may I store values to function's arguments? REFdn7045338143

by Amy-28 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



--- In flexcoders@..., "dennis" <dennis@...> wrote:

>
> Some times, the one result of a function is not enough, cay we use the
> arguments to get back values from them?
>
>  
>
> internal function getXY(x:int,y:int):void{
>
>   x=10;y=20;
>
> }
>
>  
>
> internal function test():void{
>
>   var x:int; var y:int;
>
>   getXY(x,y);
>
>   trace("x: "+x.toString()+" y: "+y.toString());  // here I get "x: 0 y: 0",
> I want to get "x: 10 y: 20"
>
> }
>
>  
>
> For instance, in c the getXY should be like this:
>
>  
>
> internal function getXY(int* x, int* y):void{
>
>   x=10;y=20;
>
> }
>

Try:

private function getXY(x:int, y:int):Object {
    return {x:10, y:20);
}

private function test():void {
    var obj:Object = getXY(0, 0);
    trace('x: ' + obj.x + ' y: ' + obj.y);
]

HTH;

Amy


RE: Re: how may I store values to function's arguments? REFdn7045338143

by dennis-121 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Amy. it works!!!

 

dennis

...we are what we are doing...  P Think! before you print.

 


Try:

private function getXY(x:int, y:int):Object {
return {x:10, y:20);
}

private function test():void {
var obj:Object = getXY(0, 0);
trace('x: ' + obj.x + ' y: ' + obj.y);
]

HTH;

Amy





__________ NOD32 4563 (20091101) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com