polymer on-hold event is far too short, is there a way to lengthen it? - polymer

I'm working on implementing a hold event in my web-app for holding a post to generate a dialog with a link to that post that can be copied and shared. It's doable, and it works, but the on-hold event seems to be only 200ms of holding, and that's far too short if you're slowly scrolling while reading and you suddenly end up with a dialog popping up because you didn't scroll fast enough to bypass the on-hold event. Does anyone know what script I'd need to change or where to look? I've googled as much as I care to over the last hour and people seem to be using on-tap more than on-hold and I've not found any documentation on changing hold length. I looked in polymer.js and found
...
var hold = {
// wait at least HOLD_DELAY ms between hold and pulse events
HOLD_DELAY: 200,
// pointer can move WIGGLE_THRESHOLD pixels before not counting as a hold
WIGGLE_THRESHOLD: 16,
....
and played around with that, did not reflect any change in using on-hold or on-holdpulse
Anything helps at this point.
Edit: I've now finished the on-hold functionality for my news posts for my web-app in a separate test file. Still just need to find out if I can lengthen the on-hold time so I can actually implement the new functionality.

I don't know why it didn't work before when I was editing HOLD_DELAY in polymer.js but while playing with it tonight at work, setting it to 1000 did affect the hold length for on-hold events in my script. Maybe I was too tired to realize I hadn't saved or something when I was playing with it at home. Either way, I have my solution now.

Related

What does addChild/removeChild do to memory in Actionscript 3?

I'm unclear on how memory works in Actionscript 3. I create a series of buttons and store the address to each of them in an array. Those buttons are used to play various music files, and I want the one that is playing to have a particular color (red) and the rest to be white. I call the following code when the currently selected button is to be replaced by a different button:
removeChild(songSelectButton[currSong]);
var songSelWhite:Button = new Button(null, "images/TrackButtonNo.jpg", TRACK_SELECT_WIDTH, TRACK_SELECT_HEIGHT);
songSelectButton[currSong] = songSelWhite;
That allows the array to have the right buttons. However, I am concerned about whether I am wasting memory. Does garbage collection take care of this, or do I need a better approach?
In most cases, garbage collection is pretty smart and can clean up whatever mess you make. But it can take its time getting around to it, and it can really tie up the CPU when it decides to do it's thing. So careful management of memory is valuable.
In your case, why create a new Button? You've got a Button already, and it looks like its already in the right spot and everything. Just change the image, any listeners, and any other properties that you really need to change. Then you won't have to worry about new buttons getting allocated and deallocated, and you won't even have to worry about a new layout being calculated.

actionscript 3: calling function for second time wont work

I'm new to actionscript 3, I have sequences of frames and two buttons to control which sequence to play, it first works properly, but have problem when a sequence is being played for the second time. I have used gotoAndPlay function for my navigation. can anyone help me?
From your description I have a hunch about what may be happening...
Firstly I would ask you if the buttons are present at all frames along the timeline? If they are not (ie, sometimes the timeline shows a frame where the buttons are not present before returning to them ) you should realise that when they come back into view again, they are not the same buttons as the ones from before. That means that the event listeners you attached the first time are not going to respond to clicks on these new buttons.
This happens because flash always totally recreates timeline objects when they come into view again. Flash can sometimes cope with a "jump" over a "gap" when a symbol is the same, but this is extremely unreliable and should be avoided for this reason.
You can avoid this problem by keeping the ui on the stage at all times, and revealing and hiding the buttons when you need them. Even better, create an instance of your ui in code and add it to the stage when you need it. This way you know there is only one instance, and you are in control of it.

how to know when Map control was first manipulated?

I am using the Map control in Windows Phone 8.
I need to implement a page where user can select his location using the map control.
I am trying to know when the app was first manipulated by the user.
Some background info:
I saw that when the control is shown, it automatically centers the world map, and CenterChanged event is raised.
I am not able to understand how ManipulationStarted, ManipulationDelta and ManipulationCompleted work.
the first time I drag, ManipulationStarted is not called, only ManipulationCompleted.
I could consider the first manipulation by user as being the 2nd time the CenterChanged is fired.
But this is a hack or a guess, I am not happy not having a good understanding how it works.
The Map control intercepts and handles Manipulation events and as such you don't get all of them. Remember, once routed events are marked at e.Handled=true they no longer bubble up.
Depending on your Scenario WP8 exposes the UseOptimizedManipulationRouting property which might prove useful. Setting UseOptimizedManipulationRouting=false causes Map, Pivot and other controls to not swallow events for nested controls.
If that doesn't help, have a look at the following Nokia Wiki article where the author ran into the same problem as you did and used Touch.FrameReported to get out of it # http://www.developer.nokia.com/Community/Wiki/Real-time_rotation_of_the_Windows_Phone_8_Map_Control

Flash/AS3 "Shutdown" or "close" event?

I am making a Flash puzzle game. When the user loads the game, it needs to ask whether to resume the game from the last state (if it exists). I have a serialization system in place, but I need to ensure that the loaded state is definitely the last state.
One solution is to save the state to a SharedObject every time the state changes (when the player makes a move). However, the game state sometimes includes a countdown, so I'd have to be constantly (or periodically) saving the state in order to retain it. I guess this is acceptable, but it seems kludgey.
Is there any event which is fired when the swf is closed? Or anyone else have another elegant solution to this?
(I'm not using AIR, but solutions requiring AIR are appreciated.)
Edit: Another important point is that I may not have control over the embedding HTML for the game, as it may be syndicated to many sites. So solutions involving javascript aren't ideal.
If your Flash is hosted on a HTML page, you can use the 'Window is closing' event notification to fire a message into your Flash object either using old-skool GetVariable() or new-stylee FlashCall() mechanisms.
Whether you'll actually be able to persist state before your Flash object is destroyed is another question... you could always do the (evil) 'Are you sure you want to close/navigate away from this window?' alert that some sites use.
Handling DOM Events in Flex
HTML 5 events
The on-close event sounds the right solution, but I wonder if you could 'split' your serialisation? i.e. save the full puzzle state on each move, but also have a secondary 'lightweight' state for your countdown (or anything similar) which could be updated each time the countdown changes.
That may be easier than trying to catch the close event and save before the page is destroyed (especially as browsers are not consistent in this area).
this one should help you

Open info window if user hovers longer than x milliseconds

What I'm trying to do is very simple:
open the marker's info window only if the user has hovered on the marker for longer than x millisecond.
I can't find how to do this anywhere. I would appreciate a little code snippet to show me how to set this up!
The jQuery HoverIntent plugin might be able to help you
http://cherne.net/brian/resources/jquery.hoverIntent.html
hoverIntent is a plug-in that attempts to determine the user's intent... like a crystal ball, only with mouse movement! It works like (and was derived from) jQuery's built-in hover. However, instead of immediately calling the onMouseOver function, it waits until the user's mouse slows down enough before making the call.
Actually I finally found the solution to it on the Google Maps Group here: http://groups.google.com/group/google-maps-api/browse_thread/thread/73cf193d42a0bbfe/fa531a39b353d198?lnk=gst&q=open+hover#fa531a39b353d198
Best of luck to all the late night coders out there :)