Optionally use Flash 10.2 cursors still compatible with Flash 10.0?

I have a Flash application that requires Flash version 10.0 to run. I want to add my own mouse cursors that were introduced in Flash 10.2, but I do not want all my users to be updated, and I do not want to create two separate versions of my application.

Is there a way at runtime, I can determine if cursors are available and then use them?

It seems that if you are only compiling Flash 10.0, it marks the header of SWF version 10 and you do not have access to the new APIs. And if you compile Flash 10.2, it marks the title of version 11, and you have access to the new APIs, but it can no longer work in the old Flash player (I get crazy errors when I load the Flex framework, for example

VerifyError: Error #1053: Illegal override of play2 in org.osmf.net.dynamicstreaming.DynamicNetStream.

ReferenceError: Error #1065: Variable _379fa43169660c76f131cadc0adfbfe8f347bd31d3ceec26a9cb2a56f0dda1f9_flash_display_Sprite is not defined.
+3
source share
3 answers

Something like this should work:

var bitmapDatas:Vector.<BitmapData> = new <BitmapData>[new BitmapData(32,32,false, 0xFF0000)];

var MouseCursorDataClass:Class;
try {
    MouseCursorDataClass = getDefinitionByName("flash.ui.MouseCursorData") as Class;
}catch(e) {}
if(MouseCursorDataClass) {
    var cursorData = new MouseCursorDataClass();
    cursorData.data = bitmapDatas;
    Mouse["registerCursor"]("test", cursorData);
    Mouse.cursor = "Xmas";
}else {
    var customCursor=new Bitmap(bitmapDatas[0]);
    addChild(customCursor);
    stage.addEventListener(MouseEvent.MOUSE_MOVE, moveCursor);
}

function moveCursor(e) {
    customCursor.x=mouseX;
    customCursor.y=mouseY;
}

And in fact, the MouseCursorData object is created and valid in 10.2, but for some reason the browser crashes when you try to call Mouse.registerCursor (). I publish for 10.0, although it is possible if you publish for 10.2, it all works correctly on both 10 and 10.2.

+2
source
if (Mouse["supportsNativeCursor"]) 
{
  // do stuff with MouseCursorData...
}

Notes:

  • This is equivalent to calling a property Mouse.supportsNativeCursor, but since it is supportsNativeCursornot supported either before 10.2, you need to check a property like this
  • Some devices may not support cursors, even if they have 10.2 (Android tablets don't have cursors) - so keep that in mind!
  • , , , ,

. 7:40 :

http://www.youtube.com/watch?v=rtc3DYSuahI&feature=player_embedded#at=464

: http://everythingfla.com/quickies/native-mouse

:

+2

, .

10.0 SWF, 10.2 SWF, 10.2, 10.2 SWF, Flash- - ?

I'm not sure if this will work. In FP6, FP7, FP8 days, the root SWF controlled what functions are really available, regardless of which Flash player you used. For example, if the root was for FP6, subswf for FP7 and works in Flash Player 8, you will still be (mostly) limited to the functionality of FP6. Some FP7 features will work, but not all. It has been several years since I had to do this, so I don’t know how this works with the AS3 engine.

+1
source

Source: https://habr.com/ru/post/1783762/


All Articles