Entries Tagged as "Flex"

Flex: Popup a Window with Javascript

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:

No Comments

Flex: Adding Your Own Context Menu Items

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):

No Comments

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...

http://api.onflex.org/

No Comments

How To Share Your Flex Source Code

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:

  1. Select Project > Publish Application Source

  2. Select the application file that will include the View Source menu. By default, the main application file is selected.
  3. Uncheck the source files that you do not want to be published.
  4. (Optional) Change the source output folder. By default, a source view folder is added to the project's output folder.
  5. Click OK.

More info can be found here.

No Comments

Flex 2.0.1

Its finally here. Flex 2.0.1 is available for download now.

More info on the update here.

Download here.

No Comments