Hey Angelina,This issue is similar to the issue in this thread: http://forums.arcgis.com/threads/61828-Opening-Edit-Widget-causes-secure-service-challenge?p=213638#..., the out-of-the-box Edit Widget is not passing the token when creating feature layers on the fly.For workaround, you can update the code as follows:
// get corresponding featurelayers
var jsonTask:JSONTask = new JSONTask;
var urlVars:URLVariables = new URLVariables();
urlVars.f = "json";
// Line 401
jsonTask.proxyURL = layer.proxyURL;
jsonTask.token = layer.token;
jsonTask.url = featureServiceURL;
jsonTask.execute(urlVars, new AsyncResponder(jsonTask_resultHandler, jsonTask_faultHandler, { layer: layer, count: index }));
and
fLayerObject = candidateFeatureLayers[index1];
var featureLayer:FeatureLayer = new FeatureLayer;
// Line 461
featureLayer.proxyURL = arcGISDynamicMapServiceLayer.proxyURL;
featureLayer.token = arcGISDynamicMapServiceLayer.token;
featureLayer.url = featureServiceURL + "/" + fLayerObject.id;
updateFeatureLayerMinMaxScale(featureLayer, fLayerObject.id, copyLayerInfos);
featureLayer.addEventListener(LayerEvent.LOAD, featureLayerLoadHandler);
featureLayer.addEventListener(LayerEvent.LOAD_ERROR, featureLayerLoadErrorHandler);