Entries Tagged as "Flex"
Flex: Popup a Window with Javascript
Posted by David in Flex on May 20, 2008
I had the need to popup a browser window from my Flex application and wanted it to popup without toolbars, etc. I found some online examples that did it in different ways. Below is the solution I went with.
FlexPopup.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function goToURLPopup(url:String,winName:String,w:int,h:int,toolbar:int,location:int,directories:int,status:int,menubar:int,scrollbars:int,resizable:int):void
{
var fullURL:String = "javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open('" + url + "','" + winName + "','" + "width=" + w + ",height=" + h + ",toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",top='+((screen.height/2)-(" + h/2 + "))+',left='+((screen.width/2)-(" + w/2 + "))+'" + "')}else{myWin.focus();};void(0);";
var u:URLRequest = new URLRequest(fullURL);
navigateToURL(u,"_self");
}
]]>
</mx:Script>
<mx:Panel width="100%" height="100%" title="Flex Popup Example" paddingLeft="10" paddingTop="10">
<mx:Button label="Google" click="goToURLPopup('http://www.google.com/', 'popup', 640, 480, 0, 0, 0, 0, 0, 1, 1)"/>
</mx:Panel>
</mx:Application>
And here is my example:
Flex: Adding Your Own Context Menu Items
Posted by David in Flex on May 1, 2008
Well I've been working with Flex alot more so I will hopefully be posting more things on Flex. Something I have been working on lately is adding Context Menu items to my applications. You can add as many as you'd like but I would limit them to only the essential ones. I searched online and found various examples. Here is how I did it:
FlexContextMenu.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
<mx:Script>
<![CDATA[
[Bindable] public var cm:ContextMenu;
private function init():void
{
// Create custom context menu items
var cm1:ContextMenuItem = new ContextMenuItem("Copyright © 2008 DCFusion.com");
cm1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,cm1_link);
cm = new ContextMenu();
cm.hideBuiltInItems();
cm.customItems = [cm1];
application.contextMenu = cm;
}
private function cm1_link(evt:ContextMenuEvent):void
{
goToURL("http://www.dcfusion.com/blog/");
}
public function goToURL(urlStr:String):void
{
var webPageURL:URLRequest = new URLRequest(urlStr);
navigateToURL(webPageURL, '_blank');
}
]]>
</mx:Script>
<mx:Panel width="100%" height="100%" title="Flex Context Menu Example">
<mx:Label text="Welcome to my Flex app!"/>
</mx:Panel>
</mx:Application>
I added a link to my new context menu item using an event listener, but that is not necessary.
And the final product (right-click on the Flex app to see the context menu):
New Site on Flash, Flex, and Apollo API's
Ted Patrick has created a new site that deals with the hidden API's of Flash, Flex, Flash Player, and Apollo.
Check it out when you can...
How To Share Your Flex Source Code
Posted by David in Flex on February 1, 2007
I'm working on a Flex application and I thought it would be good to share how I do certain things in the application. Here is a quick way to enable the 'Show Source' selection in the right-click menu:
- Select Project > Publish Application Source

- Select the application file that will include the View Source menu. By default, the main application file is selected.
- Uncheck the source files that you do not want to be published.
- (Optional) Change the source output folder. By default, a source view folder is added to the project's output folder.
- Click OK.
More info can be found here.
Flex 2.0.1
Posted by David in Flex on January 9, 2007
Recent Comments