How to print from flex app by clicking print in context menu - apache-flex

I want my flex 4 application to print proper picture when I click on print in context menu of Adobe Flash Player. Is it possible?
Proper picture - picture just a bit different then you see at the screen. I mean some colors are different.

The "print" context menu item is not suitable for printing from Flex applications. It is more appropriate for Flash applications created with Flash Professional. You should implement your own printing functionality.
If you wish to print from the context menu then you could create a Custom "context menu" in flex via the ContextMenu and ContextMenuItem classes. See also Working with Menus in the AS3 Developer's Guide.
To change the context menu:
var my_cm:ContextMenu = new ContextMenu();
my_cm.hideBuiltInItems();
var printItem:ContextMenuItem = new ContextMenuItem("Print proper image");
my_cm.customItems.push(printItem);
this.contextMenu = my_cm;
Don't forget that you can't use the "Print" caption, because it is reserved for the internal print function (see Restrictions).

Related

javafx scene builder setting accelerator sets the hot key as "N" instead of "ALT+N" for new menu item under the file menu of a text editor

I am creating a text editor using the gluon scene builder with java fx. The scene builder version is SceneBuilder-10.0.0 used with java version "10.0.1". I have a project to build a Text Editor. While building the components in the scene builder, under the File menu, I have the following menu items: New, Open, Save, Save As, and Close. I am trying to set the shortcut keys in the scene builder itself. There is an option to set the accelerator (under the Inspector Panel, in Properties) with a key. However, when I am setting it for the new menu item (and other menu items), it is set as this ignore ALT+N (Please click on the link to see the image) which makes the short cut key in the text editor to only "N" and not "ALT+N". I tried to code it in the controller class also with setAccelerator(), still it gives me similar results. I even donwloaded a fresh version of the scene builder and still does not work as expected. How can I get the short cut key to be as:
New ALT+N
under the new menu item, instead of the current:
New N

How do I conveniently reveal/expand sublevels in outline view of interface builder dock in Xcode4

I have several table columns embedded in a table view embedded in a scroll view embedded in larger view embedded in a tab view embedded in another view embedded in a window.
When click on the nib file in Xcode 4, the Editor pane shows me the Interface Builder dock in an outline view. Typically, I'd like to set the Cocoa bindings for the table columns.
To get to the table columns, I have to open many levels of subtrees, sequentially. If I click on a column header in the graphical view, and I get lucky, it takes me to the table header. In this case, I only have to open one more level, the table view. When I run my project in the debugger, and come back to the nib file, I have to do it all over again.
Is if there a way to expand all sublevels of the outline view in the IB dock with a single command, or to expand sublevels under a selected level ?
EDIT: Not an answer, but a workaround: double click the nib file to open it in a separate window. The window won't be affected by switching files in the main window. Another feature I was unaware of is Xcode 4's tab capability (Command-T) - works like a tabbed browser.
Hold Command ⌘ Alt while clicking on the disclosure triangle at the appropriate level.
Fast forwarding several years, it looks like with Xcode 11.6, you now hold Option ⌥ key while clicking on the disclosure triangle.

How to change bitmap and label of an Button component [Flash CS5, ActionScript-s]

I have created one button component using one Bitmap and one Label in it.
Thing is that when user Clicks on on the button I want to changes button's Icon/Image and Label Text.
I want to do this using FlashCS5 and ActionScript-3.
I have tried following but it gives me runtime Error
[Bindable]
[Embed(source="/Images/test.png")]
var testIcon:Class;
testButton.setStyle("icon", testIcon);
Is there any other way of doing this.
Thanks.
You need to instantiate testIcon first. Try doing this:
[Embed(source="/Images/test.png")]
var testIcon:Class;
var btnGraphics:Bitmap = new testIcon();
testButton.setStyle("icon", btnGraphics);
Looking at what you want to archive i think you should follow following steps
1. Create one movie clip using new symbol
2. Create Two new Button Symbol using 2 different images and label
3. insert these button into the key frames for the created movie clip
you can use this movieClip to create new buttons that can have 2 states
just use gotoAndStop to display the proper button.
This is an answer for a followup that ppp asked:
There is a property labelPlacement="right|left|bottom|top" property. Default is right if you set it to bottom, the icon will show above the text.
You can create a button skin in flash and import them into flex. My experience with flex 3 skins imported from Flash is that it takes a bit of work and back and forth to get it working perfectly. Flash Catalyst for Flex 4 has greatly improved that workflow.

Flex: Custom context menu for a component

I have a Flex application, running with Flash Player, not AIR, that contains a Tree that I would like to put a custom context menu on.
Tried just doing <mx:Tree ... contextMenu="{MyClassWithStatic.menu}">, but that didn't do anything.
Went searching, and found this quote from some Adobe docs somewhere
In Flex or Flash Builder, only top-level components in the application can have context menus. For example, if a DataGrid control is a child of a TabNavigator or VBox container, the DataGrid control cannot have its own context menu.
so went upwards, trying each parent element until I reached my <Application>-element, which is consistent with what they wrote.
Tried making a Flex component, based on Group (the default) which contained my tree, and the context menu on the top-level element there, hoping it would work, but to no avail.
Is there any other way to manage this that I haven't found yet?
The code I use to create the menu:
var menuItems:Array = [];
var rename:ContextMenuItem = new ContextMenuItem("Rename");
rename.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, renameSelectedHandler);
menuItems.push(rename);
menu.customItems = menuItems;
menu.hideBuiltInItems();
You're right, the contextmenu only works on top level components. It's a limitation of Flex which is annoying and shouldn't be there in the first place. There's not much you can do since there is no way to capture the event other than using some Javascript trickery, but even then, it doesn't tell you where you were clicking.
If I were you, I would just forget the concept and go away from using right click altogether if possible.
I can't be sure, as all the code isn't' there. But you seem to have ignored your own research. Don't use your new component, or anything which "contains" your tree. Then just stick the Tree in your application.
Also I've a memory of TreeItemRenderer not being the same as in other UIcomponents. Maybe, test your "menu" code with a Datagrid first and make sure it works. Good luck
I did not try it myself, but after reading the comments on http://michael.omnicypher.com/2007/02/flex-trees-with-context-menu_14.html it looks like you could add a context menu to the tree's item renderer.
The article and comments at http://blog.arc90.com/2008/04/21/adding-a-contextmenu-to-a-flex-tree/ are worth a look too.

Hide default options in right click context menu in flex

I'm developing a flex application and I want to add it a context menu. I got it with this code:
var myMenu:ContextMenu = new ContextMenu();
myMenu.hideBuiltInItems();
var defaultItems:ContextMenuBuiltInItems = myMenu.builtInItems;
defaultItems.print = false;
var item:ContextMenuItem = new ContextMenuItem("Go to google");
myMenu.customItems.push(item);
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler);
this.contextMenu = myMenu;
But I have a problem. The menu shows four default options (Settings, about flash...) I would like to hide them. With defaultItems.print = false; I hid the print option, but I don't know how to hide others.
Does anybody know how to do that?
Thanks.
There is a technique to hide the Settings, about flash etc. from the context menu in Flash. The high level concept is to use JavaScript in the HTML container to disable the right-click on top of the SWF. Capture the event and then forward it to your Flex app using the ExternalInterface API which allows you to call Flex functions from JavaScript. Call a function defined in your Flex app to display a custom ContextMenu with only the menu items you want. This sidesteps the hardwired behavior in Flash/Flex where a right mouse click always causes a ContextMenu with the Settings, About stuff to come up.
A detailed walkthrough can be found at this link.
As the reference for ContextMenu says,
You cannot remove the Settings menu
item from the context menu. The
Settings menu item is required in
Flash so that users can access the
settings that affect privacy and
storage on their computers. You also
cannot remove the About menu item,
which is required so that users can
find out what version of Flash Player
they are using.
So you'll just have to live with the Settings and About items. For other default items, see the reference for ContextMenuBuiltInItems.

Resources