Sending my AS3 AIR application window in front of everything - actionscript-3

I tried searching for this but nothing worked.
I'm trying to make my AIR application window to be always visible on top of every other windows.
I read about alwaysInFront, but I can't get it to work.
I am using an AS3 Class file on AIR 20.0 for Desktop.
My code looked like this:
I imported flash.desktop.NativeApplication; and in the first function I added windowObj.alwaysInFront = true;.
It did not work, saying windowObj is not a thing. How do I do this?
Thanks for your help!

Try:
this.nativeWindow.alwaysInFront = true;

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.

addFrameScript does not work correctly with Air 2.6

I have coded two programs using flash cs5.5. Both of them use addFrameScript to organize the code on each frame.
The first one I exported on Air For Android and had no problem with it.
The second one I exported on Air 2.6 and a problem occurred.
If I go from frame to frame in order (using gotoAndStop()) then frame script loads perfectly.
But when I use the same method (gotoAndStop()) to go back to a previous frame, all of the stage instances on my lower layers are not loaded properly so I get ERROR 1009: Cannot access a property or method of a null object reference
Funny thing, when I move them up to the first two layers, things start working again.
But I still want to keep them in their own layers. Some help please?
Thanks in advance
EDIT 1:
I just found out that if move them up to a new layer then the older elements in that layer will not be loaded properly. It's like only the first few children of the display list are loaded.
EDIT 2:
If I change it to Air For Android, the problem disappears !! my mind is blowing right now

AS3: How to use GTween?

I'm working with the latest version of the SDKs and FlashDevelop. So far, everything about my setup works fine, including external libraries. But when I use GTween, nothing happens. At all. I've tried several of the included samples and some of my own code, and all I get is a blank window or nothing moves, respectively. No errors, but also no action.
Could someone paste in some minimal code that just loads GTween and has it move a sprite? I'd like to have a known good for comparison so I can see if I'm missing something obvious or if there's something weird going on.
Thanks! :)
i just downloaded GTween and copied the com folder to my source...
... this worked fine:
package{
import com.gskinner.motion.GTween;
import flash.display.Sprite;
public class GtTest extends Sprite{
public function GtTest(){
var ball:Sprite = new Sprite();
ball.graphics.beginFill(0xFF0000);
ball.graphics.drawCircle(300,300,10);
addChild(ball);
var myTween:GTween = new GTween(ball, 2, {x:100, y:100}, {swapValues:true});
}
}
}
hope that helps ;)
Are you sure you're compiling to the version of flashplayer you have? It's possible that your player needs to be updated. Hard to tell from this info what could be the problem.
Also GTween is ok, and I have it in one project and used it fairly recently, but there are better alternatives. (gtween was last updated in 2009)
I've been using eaze a lot, but I know most as3-ers flock to TweenLite (for a good reason).

ActionScript 3 scrolling issues

I'm trying to make a google maps style interface for a design project. I've got the drag/drop and zoom functions working, but I also want to make it react to gestures on a trackpad (macbook). I assumed 'listening' to the event.delta of a MouseEvent would do the trick, but somehow it's not working. So what's wrong with my code?
stage.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheelEvent);
function onMouseWheelEvent(event:MouseEvent):void {
tafelOrigineel_mc.y += event.delta;
}
I have loaded the flash MouseEvents earlier in the document, so that shouldn't be the problem. After I got this working, I will try to use it on the x-axis too. Is that possible with the MOUSE_WHEEL eventlistener?
Thx in advance
It is a long time problem regarding flash player on MacOS.
MOUSE_WHEEL event won't dispatch on MacOS. Though there are some workarounds involving the use of JavaScript to detect the use of the wheel (over the entire flash content), if it isn't a issue, try checking one of those.
There is a list in this blog post:
http://www.impossibilities.com/v4/2009/03/06/flash-mousewheel-implementations-for-mac-os-x/

how do you find error in a SWF?

i feel stupid asking that question, but it seems like i'm unable to find out.
i have a SWF that works perfectly inside flash. once i export as SWF, it doesn't work anymore.
i can't use "trace"
i have tryed that function but it doesn't trigger it for some reason. :
function quikTrace(string:String){
//INIT VARIABLES
var tmpTxtField:TextField;
//TEXTFIELD PROPERTIES
tmpTxtField = new TextField();
tmpTxtField.text = string;
tmpTxtField.x = stage.width / 2;
tmpTxtField.textColor = 0xFFFFFF; //white (black background)
tmpTxtField.y = stage.height / 2;
addChild(tmpTxtField);
}
is there any "outside the box" way to find errors in a SWF?
You can view trace statements in the browser by doing a few quick steps:
Get a debug flash player for your browser. link
Set up mm.cfg to enable flash logging to a file. link
Get a text editor / "tail" viewer and read the flashlog.txt file that is generated. This is where FireBug & Flashbug come in handy, if you're in firefox. You can also try baretail for PC, or regular old "tail -f" on a mac/linux machine.
Good luck.
It's not a stupid question at all! You're just learning how to debug Flash for the first time. You can use "trace" with an exported SWF by doing a debug/test build from Flash IDE or Flash Develop. You can then read these traces with Firefox by using the extentions Firebug combined with the Flashbug extension. Now you're all set for getting feedback using traces.
For this particular problem, it's hard to say. Is this function inside of a class or timeline code? If it's a class, it probably because Stage is not ready yet. You can use the event Event.ADDED_TO_STAGE to know when the Stage reference is ready to be used.
Hope this helps!
Install a debug version of flash player for your browser. It will tell you exactly which line of code is throwing error.
http://www.adobe.com/support/flashplayer/downloads.html