I write a flex application. I added some custom menu items in context menu. when I compiled this code using flashplayer 10.0, it works fine and my added context menu items are shown when I Right-Click. But when I compile same code for flashPlayer 10.1, menu items that I added in context menu are not shown when I Right-Click. What should I do to resolve this issue?
I am using sdk 3.5.
Any help or suggestion will be appreciated.
I am doing this;
private var cm:ContextMenu = new ContextMenu();
var versionMenu:ContextMenuItem = null;
var dateMenu:ContextMenuItem = null;
if(model.appVersion.length > 0)
{
versionMenu = new ContextMenuItem(model.appVersion);
}
if(model.releaseDate.length > 0)
{
dateMenu = new ContextMenuItem(model.releaseDate);
}
cm.hideBuiltInItems();
var cmArray:Array = new Array();
if(versionMenu != null)
cmArray.push(versionMenu);
if(dateMenu != null)
cmArray.push(dateMenu);
cm.customItems = cmArray;
Thanks.
there is no reason. It works fine for me in flashPlayer 10.1 . Also it is listed as supported in 10.1 here : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/ui/ContextMenu.html
alert the isSupported property in code to double check (it will most definitely be true).
If you are trying to create a context menu for Application then here is the correct code:
<s:Application ... initialize="init();">
private function init():void
{
var versionItem:ContextMenuItem = new ContextMenuItem("Version 1.5.443");
contextMenu.hideBuiltInItems();
contextMenu.customItems = [ versionItem ];
}
</s:Application>
Related
I'm trying to use GridView from Forms Lab. Problem is that I'm not getting anything shown on screen. One thing to note - when i set Content = gridView or Content = mainLayout I'm getting null pointer reference exception, but i cannot find out which element is null. Here's code in view :
var itemTemplate = new DataTemplate(typeof (MedicineBoxItemCell));
var gridView = new GridView();
gridView.ItemsSource = medicineBoxViewModel.MedicineBoxViewModelItems;
gridView.ItemTemplate = itemTemplate;
StackLayout mainLayout = new StackLayout();
mainLayout.Children.Add(gridView);
var scrollView = new ScrollView()
{
Content = mainLayout,
BackgroundColor = Color.Yellow
};
Content = scrollView;
}
public class MedicineBoxItemCell : ViewCell
{
public MedicineBoxItemCell()
{
var name = new Entry()
{
HorizontalOptions = LayoutOptions.FillAndExpand
};
name.SetBinding(Entry.TextProperty, "MedicineBoxItem.Medicine.Name");
View = name;
}
}`
What platform are you testing? This a very alpha version that has some problems, specially with ItemTemplate.
Try one of the demo ViewCells and see if it works for you.. and go from there.
One thing that will not work is having a layout inside a layout on the template. For example, if you are using a Grid, and inside the grid u have a stackpanel that stackpanel and it's contents will not appear , it s somethign we don't know how to fix yet.
I've converted a PowerPoint into Flash so each slide is a .swf. I've used a number of different converters and the problem here is the same.
What I'd like to do is trigger the .swf's animation (contents of slide appearing) programatically. I can click on the .swf with a mouse and the animation advances. I can automate this when the .swf's embedded in a web page simply by doing:
document.getElementById('myMovie').play();
Each time I execute that code, the swf advances to the next animation. However, I can't find a way to do this in flex. I've used then MovieClipSWFLoader and tried:
private function animate():void {
var simulatedClick1:MouseEvent = new MouseEvent(MouseEvent.CLICK);
var simulatedClick2:MouseEvent = new MouseEvent(MouseEvent.MOUSE_DOWN);
var simulatedClick3:MouseEvent = new MouseEvent(MouseEvent.MOUSE_UP);
frameNo++;
myMovie.gotoAndStop(frameNo);
myMovie.nextFrame();
myMovie.nextScene();
myMovie.play();
myMovie.dispatchEvent(simulatedClick1); // with clicks 1, 2, and 3
}
<s:MovieClipSWFLoader id="myMovie" source=""/>
<s:Button id="btnAnimate" click="animate()"/>
I've also tried loading as an Image component and using the simulated click too... no good. Can anyone tell me how I can do this?
The problem was that the .swf was created with Flash 8 and wasn't compatible with my version of Flex. I found a great solution in ForcibleLoader at https://gist.github.com/nsdevaraj/409902. It converts old .swf's to new ones and then the code worked as it should.
private var libMC:MovieClip = new MovieClip();
ur = new URLRequest(guide_url);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfComplete);
var fLoader:ForcibleLoader = new ForcibleLoader(loader);
fLoader.load(ur);
swfMovie.addChild(loader);
private function swfComplete(event:Event):void{
libMC = event.currentTarget.content as MovieClip;
}
private function animate():void {
libMC.nextFrame();
<mx:UIComponent id="swfMovie"/>
In Flex 3.2 I had implemented a tooltip manager and I used the topLevelSystemManager from ISystemManager to add a child to the sandbox root:
The code was as follows:
var sm:ISystemManager = getSystemManager(currentTarget) as ISystemManager;
sm.topLevelSystemManager.addChildToSandboxRoot("toolTipChildren" , currentToolTip as DisplayObject);
In my endeavour to upgrade Flex to 4.5 I discovered that this method does no longer exist.
What's the appropriate way of migrating this piece of code to 4.5?
Part of the ActionScript class is shown here:
mx_internal function createTip():void
{
// Dispatch a "createToolTip" event
// from the object displaying the tooltip.
var event:ToolTipEvent =
new ToolTipEvent(ToolTipEvent.TOOL_TIP_CREATE);
currentTarget.dispatchEvent(event);
if (event.toolTip)
currentToolTip = event.toolTip;
else
currentToolTip = new toolTipClass();
currentToolTip.visible = false;
var sm:ISystemManager = getSystemManager(currentTarget) as ISystemManager;
sm.topLevelSystemManager.addChildToSandboxRoot("toolTipChildren", currentToolTip as DisplayObject);
}
Any help will be greatly appreciated.
Use the tooltip manager, as explained here.
turns out I can just use this
sm.topLevelSystemManager.toolTipChildren.addChild(currentToolTip as DisplayObject)
context menu is working well in desktop project but not display in web project...........kindly help and suggest if anyone has some suitable answer
In main.mxml, on application initialize, run this function:
private function init():void {
var customMenuItem1:ContextMenuItem = new ContextMenuItem(“WHATEVER DUDE”);
var contextMenuCustomItems:Array = application.contextMenu.customItems;
contextMenuCustomItems.push(customMenuItem1);
}
I'm doing an Image Cache following this method: http://www.brandondement.com/blog/2009/08/18/creating-an-image-cache-with-actionscript-3/
I copied the two as classes, renaming them CachedImage and CachedImageMap.
The thing is that I don't want to store the image after being loaded a first time, but while the application is being loaded.
For that, I've created a function that is called by the application pre-initialize event. This is how it looks:
private function loadImages():void
{
var im:CachedImage = new CachedImage;
var sources:ArrayCollection = new ArrayCollection;
for each(var cs in divisionData.division.collections.collection.collectionSelection)
{
sources.addItem(cs.toString());
}
for each(var se in divisionData.division.collections.collection.searchEngine)
{
sources.addItem(se.toString());
}
for each( var source:String in sources)
{
im.source = source;
im.load(source);
}
}
The sources are properly retrieved.
However, even if I use the load method, I do not get the "complete" event... As if the image is not being loaded... How is that?
Any help would be appreciated.
Thanks in advance.
Regards,
BS_C3
I found the problem with my code =)
It was a declaration problem.
I moved the declaration of the cachedImage inside the for each loop where the images are loaded. So that I get something like this:
for each( var source:String in sources)
{
var im:CachedImage = new CachedImage;
im.source = source;
im.load(source);
}
And this does the trick.