1) if I create items in a for loop, is correct to add a new eventListener for each item ? Or should I add only 1 eventListener to the parent ? and call the event through ID ?
2) if I want to scale my item, (a LinkButton with icon image), I noticed that the icon is sometimes resized with delay, so I have a bit of flickering when I trigger the event. Should I not use icons, and set the image in another way ? How can I fix this ?
thanks
1) if I create items in a for loop, is
correct to add a new eventListener for
each item ? Or should I add only 1
eventListener to the parent ? and call
the event through ID ?
It depends. If the items are listening for something, add it to them. If the parent is listening, add it to the parent. If you add it only to the parent, set the useCapture arg to true in the addEventListener method. It can get confusing in Flash because there is no difference between an event listener and an event handler: the handler actually points to the class that contains the handler.
2) if I want to scale my item, (a
LinkButton with icon image), I noticed
that the icon is sometimes resized
with delay, so I have a bit of
flickering when I trigger the event.
Should I not use icons, and set the
image in another way ? How can I fix
this ?
Without knowing how exactly you are doing this, I can't offer concrete solutions. Are you using a Resize effect? Are you scaling using overrides on scaleX and scaleY properties? Does this handle on mouseover or via some other event? All I can tell you is that you may be better off not using the LinkButton, or may want to change the skin instead of resizing. Show your code if you want more informed answers.
Related
I have a list with itemrenderer with dragEnabled true and dropEnabled true. Now, I am trying to tell flex not to let the dragged item (even the icon indication) leave the drop panel. I don;t care if it stop the dragging or just freezes it as if it was the application border - and I cannot. I tried to stop the dragging on dragExit handler but it seems to ignore it. Does anyone know of a working mechanism to do such? (Flex 4)
thanks
Try on drag exit :
a setfocus on a stage element other than the item on dragExit
or a mouseEnabled false on the items
Alternatively you could try listen to mouseOut event and try to the same.
Firstly I feel this question is not a duplicate for :
Easiest implementation of onReleaseOutside in AS3?
Now, the problem , I want to do some action when the mouse_down happened inside the stage, but the mouseup happened outside it.
e.g check google finance charts, try dragging the change range divider and then make the drag such that your mouse exists the browser screen, and then do a mouse_up outside the browser, this will trigger some action inside the stage , i.e make the range stick to the position it was, when the mouse exited the window.)
How can this be done in Flex 3/4??
Thanks,
Neeraj
Try this one:
stage.addEventListener(Event.MOUSE_LEAVE, check);
I am using a box element to add a transparent overlay to a column of buttons. I want to add a click event to the buttons. However, when you click a button the click event is only triggered on the overlaying box. Is there anyway to pass the event to the underlying button or perhaps a better way to display an overlay without blocking the click event?
If you want a DisplayObject (which nearly all visual things subclass in Flex) to be treated as "transparent" to the mouse (i.e. it won't intercept click events), set that object's mouseEnabled property to false.
e.g.
transparentBox.mouseEnabled = false;
I have an ajax controltoolkit reorderlist within an asp.net application.
I need to disable certain specific steps from being reordered. This has to be done dynamically. All steps are consecutive and start from the beginning, but it's not known until runtime how many need to be disabled from being reordered any further.
I tried the e.item.enabled = false for reorderlist_itemdatabound but this just disabled links. I need to disable the drag handler.
Any help is greatly appreciated. Thanks!
To be honest, I'm not too familiar with this control, but...
You need to hide the drag handler div (or whatever is in the 'DragHandleTemplate' I believe) and/or change its class. Two suggestions:
1) Add a javascript startup script to disable the divs in question.
2) Subclass this control... Override the Render() method. Replace it with original code from ReorderList, but check the Item to see if you should render the drag handle.
as a workaround to disable drag'n'drop for some item - you can set width=0 to the control inside <DragHandleTemplate> </DragHandleTemplate>. Thus user won't be able to pick the item for dragging.
Suppose you have an image with id dragme in DragHandleTemplate; you can do this in the ItemDataBound handler:
Image dragMe = (Image)((TableRow)e.Item.Controls[0].Controls[0]).Cells[0].Controls[0].FindControl("dragMe");
dragMe.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");
This way you preserve the alignment.
I want to change the view states in my flex app when it resizes in the browser window.
I have the swf embedded at 100% x 100%. So when the user resizes the window below a certain width, I want to switch to a different state. I tried adding an event listener like this, but it only fires the event when I resize the swf outside the browser, not inside. I used:
this.addEventListener(ResizeEvent.RESIZE, SizeChanged);
I want this to work within the browser. I even tried using fixed dimensions in the embed code, instead of percentages, but that didn't help either.
You want to add the listener to the stage.
this.stage.addEventListener( Event.RESIZE, resizeHandler ); //from your Main.mxml creationComplete handler
Or you can add a listener via:
Application.application.stage.addEventListener( Event.RESIZE, resizeHandler)
Also, keep in mind that this event fires a lot as the view is resizing, so you will want to account for that.