I'd store the currently selected resource in a field here:

    _resource = spark.focusManager.currentResource;