9/5/2010 8:04:11 PM
Title:
opening a page in a browser when a choice is selected from the Menu
The choice item is defined in MXML as
<menuitem label="Help">
<menuitem label="Documentation" data="documentation.swf" />
</menuitem>
Code on what to do when it is selected is
<mx:ApplicationControlBar id="appBar" x="0" y="0" dock="false" visible="false" width="100%">
<mx:MenuBar id="appNavigation" dataProvider="{appNavigation_dp}" labelField="@label" iconField="@icon" itemClick="menuBarButtons(event);" />
</mx:ApplicationControlBar>
//Function called menuBarButtons is
private function menuBarButtons(event:MenuEvent):void{
var pageName:String = event.item.@data;
switch(pageName){
case 'Documentation':
var url:URLRequest = new URLRequest('http://www.mydocumentation.com');
navigateToURL(url,'_blank');
break;
}
//I have done the required imports such as
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.net.URLVariables;
When I click on the Documentation option from the menu, no new URL opens
while I am expecting a page with a URL http://www.mydocumentation.com to be
opened
What am I missing?
Any suggestions would be appreciated.
9/5/2010 10:48:35 PM
Hello Chris
I have tried same code at my side, Code working fine.
I would suggest to check your browser setting may be pop-up is blocked in your window.
or debug the code and go step by step in function might be you will solve it.
Regards,
Virat Patel
9/6/2010 1:16:13 PM
Hi Virat,
Thanks for the reply, but the code I had was wrong. How did it work properly at your side?
I changed the data = "documentation.swf" to data = "helpdoc"
and changed case 'Documentation' to case 'helpdoc' and it worked fine.
After then only it worked fine.
9/6/2010 11:07:33 PM
Hi...
Code working fine at my side it means the code syntax is right like
var pageName:String = event.item.@data;
switch(pageName){
case 'Documentation':
var url:URLRequest = new URLRequest('http://www.mydocumentation.com');
navigateToURL(url,'_blank');
break;
i have forcefully set variable pageName to 'Documentation' than it work fine.
that's what i mean to say in my above answer. but is condition may fall wrong in your case than definitely a problem in data or code.
Regards,
Veerat