public function weekFilter(selKnop:String):void { var knop:String = selKnop; loads.filterFunction = filterBylWeek; loads.refresh(); sailings.filterFunction = filterBysWeek; sailings.refresh(); } public function filterBysWeek(item:Object):Boolean { var isMatch:Boolean = false if(item.sweek.toLowerCase().search(knop) == -1) { isMatch = true } return isMatch; } [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => pope on acid [ip] => alex.walgraeve@ [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> Passing variables between functions - Macromedia Flex General Discussion

Passing variables between functions - Macromedia Flex General Discussion

I want to keep a variables value to use in filter function,but this way it doesn't works: [Bindable] public var knop:String = new String; [Bindable] public var selKnop:String = new String; //<----------------------------------------------------------------------------> public function weekFilter(selKnop:String):void { var knop:String = selKnop; loads.filterFunction = filterBylWeek; loads.refresh(); sailings.filterFunction = filterBysWeek; sailings.refresh(); } public function filterBysWeek(item:Object):Boolean { var isMatch:Boolean = false if(item.sweek.toLowerCase().search(knop) == -1) { isMatch = true } return isMatch; }...

  1. #1

    Default Passing variables between functions

    I want to keep a variables value to use in filter function,but this way it
    doesn't works:



    [Bindable]
    public var knop:String = new String;

    [Bindable]
    public var selKnop:String = new String;


    //<---------------------------------------------------------------------------->
    public function weekFilter(selKnop:String):void
    {
    var knop:String = selKnop;
    loads.filterFunction = filterBylWeek;
    loads.refresh();
    sailings.filterFunction = filterBysWeek;
    sailings.refresh();
    }

    public function filterBysWeek(item:Object):Boolean
    {
    var isMatch:Boolean = false
    if(item.sweek.toLowerCase().search(knop) == -1)
    {
    isMatch = true
    }
    return isMatch;
    }

    pope on acid Guest

  2. #2

    Default Re: Passing variables between functions

    I'm assuming you haven't assigned any values to the bindable public vars knop
    and selKnop by the time you invoke the weekFilter() method. If this is the
    case, the scope of your variables is the problem.

    Your declaration of the variable "knop" in weekFilter() is local in scope.
    Referring to it in filterBysWeek() before it's been assigned a value therefore
    wouldn't work. If you're looking to set the public var knop in weekFilter(),
    then you'd do this:

    public function weekFilter(selKnop:String):void
    {
    knop = selKnop;
    sailings.filterFunction = filterBysWeek;
    sailings.refresh();
    }

    Note that the parameter selKnop you have in the local scope of weekFilter() is
    NOT referring to the bindable public var "selKnop" you have declared at the top
    of your code. But you probably knew this, right?

    TS

    VarioPegged Guest

  3. #3

    Default Re: Passing variables between functions

    1) Do not use "new" to create a string variable.
    public var knop:String;

    2) Do not re-declare the variable inside the weekFilter function. That makes
    a local var, whose scope is only within the function.
    knop = selKnop;

    3) Do not use [Bindable] unless you need to bind to the var.

    Tracy


    ntsiii Guest

Similar Threads

  1. Passing vars into functions
    By jaquito13 in forum PHP Development
    Replies: 2
    Last Post: May 18th, 09:06 PM
  2. Variables & Functions
    By Shaggy1 in forum Macromedia Flash Actionscript
    Replies: 5
    Last Post: February 22nd, 05:06 PM
  3. passing arguments to functions
    By jassismara@xtra.co.nz in forum PERL Beginners
    Replies: 1
    Last Post: January 20th, 01:32 AM
  4. Passing arrays to functions
    By Eric Kincl in forum PHP Development
    Replies: 1
    Last Post: November 19th, 09:13 PM
  5. Passing arrays through functions
    By Henry in forum ASP
    Replies: 3
    Last Post: September 15th, 02:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139