Moving Native Window in AS3 - actionscript-3

How to move native window when any display object start drag in Flash action script? As we do with clock gadget in windows 7.
Actually, I am trying to make my custom clock that will work like a clock in windows 7.

If you are targeting Air, then use stage.nativeWindow.startMove(); like so:
private function dragWindow(e:MouseEvent):void
{
stage.nativeWindow.startMove();
}
clock.addEventListener(MouseEvent.MOUSE_DOWN, dragWindow);

Related

How to prevent AIR application from jerking around while dragging?

I've created an AIR application and it seems to be working fine but when I drag the title bar to move the native window it shakes violently and have seizures while it's dragging about.
FYI It does eventually end up where I want it to be when I stop moving the mouse.
I'm using Flex 4.6 and AIR 3.6 on Mac OSX 10.10.5. It's a s:WindowedApplication I'm also using the DragManager on a list in part of the application if that matters but it is not enabled until the user clicks into the list and moves more than a certain number of pixels.
Here is my descriptor file minus name and version info:
<application xmlns="http://ns.adobe.com/air/application/3.6">
<initialWindow>
<autoOrients>false</autoOrients>
<fullScreen>false</fullScreen>
<visible>false</visible>
</initialWindow>
</application>
On initialize I run this:
protected function initializeHandler(event:FlexEvent):void {
width = Capabilities.screenResolutionX * .96;
height = Capabilities.screenResolutionY * .9;
nativeWindow.x = (Screen.mainScreen.bounds.width - width)/2;
nativeWindow.y = (Screen.mainScreen.bounds.height - height)/2;
}
UPDATE:
I removed the main view component so it is an empty application and it drags around smoothly.
UPDATE 2:
I added the main view back in and dragged around step by step along the way. It appears to start happening when I've loaded a second Application (called a sub application) into the main application. I'm not sure though.
This happens in numerous number of my applications. It is probably because I have a component inside my application file set to size to 100% of the application. But I have not verified this on all my apps.
The solution is to resize the AIR app. After I resize it it works fine. I can drag it around and it works as expected. I think this is an AIR bug.

Flash Auto Pause video after x seconds and play after selected option

I am doing project on developing a small game(A Soccer Penalty shootout guess game). I was hoping if someone could tell if it is possible to do the following function. I am using Adobe Flash Pro CC.
I am trying to pause the video that i have imported at 3.5 seconds and then two buttons appear with options either a Miss or Goal.. Once the user selects either option the video continues to play.
My question, is it possible to do this using Actionscript in Flash. if so what commands/function does it require.
Thanks
You could do it something like this (given that you are using the FLVPlayback component with the variable name of myFLVPlaybackComponent)
should be
myFLVPlaybackComponent.addEventListener(VideoEvent.PLAYHEAD_UPDATE, videoPause);
private function videoPause(evt:VideoEvent):void {
if (evt.playheadTime >= 3500){
myFLVPlaybackComponent.stop();
}
}
then call myFLVPlaybackComponent.play(); on your resume video function

Windows phone 8 Performance progressbar

Do i need to use performance progressbar in windows phone 8. In my windows phone 7/7.5 application i was used the progressbar shipped with the toolkit(performance progressbar). Is it necessary to use the same in windows phone 8 or simple progress bar is sufficient?
The WP8 SDK contains the improved progress bar now. So use this one only.
The TK version in not working properly anymore on WP8.
See changes for the SDK here, including a sentence about the progress bar:
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206940%28v=vs.105%29.aspx
See a discussion about that topic here:
http://social.msdn.microsoft.com/Forums/en-GB/wpdevelop/thread/dd457734-a11a-48e2-8443-ba8f5e3f67ac
Use the WP8 SDK's progress bar, but don't forget to set IsIndeterminate = false after collapsing the progressbar. It will run in the background & use battery & UI thread cycles even though its collapsed! :(
I think you should use something like this when targeting WP7 and WP8 with linked files:
#if WP8
public class MyPerformanceProgressBar : ProgressBar
{
}
#else
public class MyPerformanceProgressBar : Microsoft.Phone.Controls.PerformanceProgressBar
{
}
#endif
and use the class MyPerformanceProgressBar in your XAML code (which is linked in WP7 and WP8 project).

Need my Adobe Air desktop App to make the system tray icon blink

I have a created in Flash CS5 a very simple Adobe Air Desktop App. The App is just a small 400 x 200 window that has a dynamic text field that loads a ".txt" file sitting out on the internet using URLRequest. The App checks for a new file at set intervals, right now every 5 minutes.
I need to find a way to make the App blink the system tray icon or Flash a button in the Application itself when a "NEW" file has been loaded looking at the time/date stamp of the ".txt" file. not just when it loads the file again.
I apologize in advance I am very new to Adobe Air and Flash Actionscript 3.0
For desktop (not mobile) AIR apps, you could use the NativeWindow class's nofityUser function.
Example:
import flash.desktop.NotificationType;
import flash.events.MouseEvent;
function notifyMe(aNotificationType:String):void
{
if(NativeWindow.supportsNotification)
{
stage.nativeWindow.notifyUser(aNotificationType);
}
else
{
trace("Notification not supported on this OS");
}
}
function onStageClicked(e:MouseEvent):void
{
// You could also pass NotificationType.CRITICAL here
notifyMe(NotificationType.INFORMATIONAL);
}
stage.addEventListener(MouseEvent.CLICK, onStageClicked);

Handling JavaScript calls to window.open()- not using Native Windows - Adobe AIR

I am developing an Adobe AIR application which uses both native windows and floating panels. Is is possible to enable the creation of a floating window instead of a native window when a JavaScript window.open() function is called?
It is required that all of the floating windows are contained within one native window, therefore the creation of more native windows is not suitable.
I have used a Custom HTMLHost class in order to enable the creation of a native window but I can’t work out a way of creating a MDI window instead. I am using the flexMDI framework for my floating panel interface.
Any help on this would be much appreciated.
You can try hijacking the HTML's window object via code:
htmlContent.addEventListener(Event.COMPLETE, htmlLoaded);
private function myOpenFunction(...args) {
// Do stuff with args
}
private function htmlLoaded(event:Event):void
{
htmlContent.domWindow.open = myOpenFunction;
}
I'm not sure if that (or something very similar) will work, but it's probably the only way to do it if it can be done at all.