PDA

View Full Version : AS3 problem, are MAC and PC flashplayers different?



bootiteq
August 2nd, 2008, 08:35 PM
Im using flash player 9.0.124.0 on both MAC and PC...

This below example works on my mac in both Safari and Firefox but does not work on a PC in IE or Firefox


var _fs:Boolean = false;

btn.addEventListener(MouseEvent.MOUSE_DOWN, toggleFullScreen),

function toggleFullScreen(e:MouseEvent){
if(_fs == false){
_fs == true;
}else{
_fs == false;
}

trace(_fs); // no mater how many times I click "btn" on a PC _fs remains false;

}

If you can help that would be great :hat:

senocular
August 2nd, 2008, 08:45 PM
it shouldn't work on mac either. it should be:


if(_fs == false){
_fs = true;
}else{
_fs = false;
}

Krilnon
August 2nd, 2008, 08:48 PM
Or _fs = !_fs;

Pier25
August 3rd, 2008, 02:45 PM
Yes, the players are different... even from browser to browser.

Or at least the same player reacts differently depending on the browser...

senocular
August 3rd, 2008, 03:15 PM
A lot of that can be dependent on the browser APIs. Not all browsers are created equal.

bootiteq
August 3rd, 2008, 05:03 PM
Maybe I need to use MOUSE_UP instead of MOUSE_DOWN. I will give that a go.

and ah yes that wouldnt work on a mac or a pc ha ha!

Pier25
August 3rd, 2008, 05:14 PM
Not all browsers are created equal.

Very true :)

bootiteq
August 3rd, 2008, 06:59 PM
Nup wasnt MOUSE_UP

nikefido
August 3rd, 2008, 10:13 PM
senocular already solved the issue for you....



if(_fs == false){
_fs = true;
}else{
_fs = false;
}


not the use of "=" vs "=="

bootiteq
August 4th, 2008, 11:37 AM
thanks nikefido but that was a typo I made when writing the post, my code used = not == I must have been in a hurry.

On ther good news front however and after many hours of debugging I managed found the issue. When I clicked the fullscreen button on my video player certain elements of my function would call but stangely not all of them and also I had to double click the button instead of just clicking once.

Here is the broken version - using Event.DEACTIVE
http://www.whitecoatdesign.com/kirupa/deactive.html



btn.addEventListener (MouseEvent.MOUSE_UP,funcUp);
stage.addEventListener (Event.DEACTIVATE, deactivate);

var _fsU = false;
tfU.text = "fullscreen: "+ _fsU;

function deactivate(e:Event){
_fsU = false;
tfU.text = "fullscreen: "+ _fsU;
}

function funcUp (e:MouseEvent):void {
if (_fsU == false) {
_fsU = true;
stage.displayState = StageDisplayState.FULL_SCREEN;
} else {
_fsU = false;
stage.displayState = StageDisplayState.NORMAL;
}
tfU.text = "fullscreen: "+ _fsU;
}


Here is the fixed version without Event.DEACTIVE
http://www.whitecoatdesign.com/kirupa/no_deactive.html



btn.addEventListener (MouseEvent.MOUSE_UP,funcUp);

var _fsU = false;
tfU.text = "fullscreen: "+ _fsU;

function funcUp (e:MouseEvent):void {
if (_fsU == false) {
_fsU = true;
stage.displayState = StageDisplayState.FULL_SCREEN;
} else {
_fsU = false;
stage.displayState = StageDisplayState.NORMAL;
}
tfU.text = "fullscreen: "+ _fsU;
}



So I guess I will have to find another way to determine if the esc key has been pressed.
Many thanks.

wvxvw
August 5th, 2008, 04:31 AM
ESC key is a key reserved by browser (for aborting loading current request). So, along with few other keys/key sequences it's not catched by the flash player. To make player recieve events for those keys, when they are pressed you, probably, will have to make some JS function that'll catch them and redispatch to flash.

bootiteq
August 5th, 2008, 10:07 AM
Hi wvxvw do you what Javascript will do this?

merlijn1111
August 6th, 2008, 02:01 PM
Hey bootiteq,



So I guess I will have to find another way to determine if the esc key has been pressed.
Many thanks.

You don't have to trace the esc key or sth, flash cs3 already has a trigger to check if the screen is switched fullscreen <-> normal.

stage.addEventListener( FullScreenEvent.FULL_SCREEN, checkFullScreen);

function checkFullScreen(e:FullScreenEvent):void {
_fsU=e.fullScreen
}

this one will just do fine with you.
First it checks if the fullscreen is triggerd to full or normal.
If it's triggered, it will put true or false in your variable.

Greetz,
David.

bootiteq
August 6th, 2008, 03:26 PM
Thanks David but sadly I couldn't get that one to fire on first go so in a crazy fit of madness I ended up doing a long winded test for RESIZE. This way was recommended to me by a geezer who has built 3 full screen players from scratch.

Admittedly I am concerned about stage.addEventListener( FullScreenEvent.FULL_SCREEN, func); not working in all browsers as Event.DEACTIVE didn't

Thanks again

merlijn1111
August 6th, 2008, 04:19 PM
Thanks David but sadly I couldn't get that one to fire on first go so in a crazy fit of madness I ended up doing a long winded test for RESIZE. This way was recommended to me by a geezer who has built 3 full screen players from scratch.

Admittedly I am concerned about stage.addEventListener( FullScreenEvent.FULL_SCREEN, func); not working in all browsers as Event.DEACTIVE didn't

Thanks again

I use it for several months now on a website for a friend http://www.ieoie.nl/
Never had a problem with it, or people complaining about things going wrong.
Tested it myself on windows with IE and firefox, and even mac with firefox and Safari.

Double check and triple check your code, and check if you are using the correct versions of flash!
People using older versions of windows and some other systems will not be able to see any flash content written in AS3. As they haven't developed new flash versions for windows 9x.
Wrong flash versions are my number 1 weird effects causing those problem.
Full screen support wasn't there from the first flash 9 release!

Also keep in mind that the full screen option in flash isn't yet 100% stable and error free.
Sometimes little weird things can happen, I especially experienced errors when adding or removing content while switching or in full screen video mode.

Personnaly I do not recommend looping tests or extensive checkings as they easily eat up processor time, and slow down your animation and even your computer and of everybody who is using it.

bootiteq
August 6th, 2008, 04:41 PM
Looks like I should definitely try that again. Thanks for the reply.