Wednesday, April 15, 2009

Flash 10 Security issue Filereference workaround Example

Upload and download require user interaction
In Flash Player 9, ActionScript could perform uploads and downloads at any time. With Flash Player 10, the FileReference.browse and FileReference.download operations may be initiated only through ActionScript that originates from user interaction. This includes actions such as clicking the mouse or pressing the keyboard.
What is impacted?
This change can potentially affect any SWF file that makes use of Filereference.browse or FileReference.download. This change affects SWF files of all versions played in Flash Player 10 beta and later. This change affects all non-app content in Adobe AIR (however, AIR app content itself is unaffected).
What do I need to do?
Any existing content that invokes a browse dialog box using Filereference.browse or FileReference.download outside of an event triggered by user interaction will need to be updated. The dialog box will now have to be invoked through a button, keyboard shortcut, or some other event initiated by the user.

Solution


try{
var urlReq:URLRequest = new URLRequest("http://www.myUrl.com/file");
fileReference.download(urlReq);
}
catch(error:Error)
{
Flash10Workround();
}

WorkAround Method :

var popup:Somepopupcustomobject;
private function Flash10Workround():void
{
popup= new Somepopupcustomobject();
PopUpManager.addPopUp(popup,this,true);
PopUpManager.centerPopUp(popup);
popup.LABEL="File is Ready to Exported, Please Click Ok to continue";
popup.submitSub.addEventListener(MouseEvent.CLICK, closePopUp);
}
private function closePopUp(e:MouseEvent):void
{
var urlReq:URLRequest = new URLRequest("Ur Link here");
fileReference.download(urlReq);
PopUpManager.removePopUp(Object218PopUp);
}

Sunday, April 12, 2009

Cairngorm Command Result Dispatching Event to View

Cairngorm !!!!!!!!! I am New It and was looking for listening event in view to change style of my flex application, after lot of trying i found out its fairly simple.

Write on the top of command:

[Event(name="enableChange", type="com.adobe.cairngorm.control.CairngormEvent")]

Result Method of Command:

public function result(data:Object):void
{
var e:CairngormEvent=new CairngormEvent("enableChange");
CairngormEventDispatcher.getInstance().dispatchEvent(e);
}


Listen for that in a view :



height="100%"
creationComplete="creationComplete()"
layout="absolute" backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #FFFFFF]"
xmlns:components="components.*"
xmlns:business="business.*"
xmlns:view="view.*"
xmlns:control="control.*">


import com.adobe.cairngorm.control.CairngormEventDispatcher;
import mx.controls.Alert;
import com.adobe.cairngorm.control.CairngormEvent;

import flash.events.Event;


private function creationComplete ():void {
CairngormEventDispatcher.getInstance().addEventListener("enableChange", enableChangedListener);
}



public function enableChangedListener(eventOb:CairngormEvent):void {
Alert.show("Handle Event", "Catch");
// Handle event.
}