By installing a custom class as a 'fake resource', I could successfully
use a drawview based cursor in swf10. I've attached an example application.
I think the application is pretty self explanatory except for line where
I add the entry for the 'fake resource':
LzResourceLibrary['mycursor'] = {assetclass: CursorSprite};
LzResourceLibrary is an internal map which holds all resources by name.
Each entry in that map is an object referring to a class for the
resource, in our case we want to point to the custom class CursorSprite.
After changing the global cursor to 'mycursor' by calling
lz.Cursor.setCursorGlobal('mycursor'), a new instance of CursorSprite is
created and used for the cursor.
- André
Hi all,
I need to be able to paramaterize some components of a cursor. I can set
the cursor by first declaring a named resource this:
<resource name="waitcursor" src="lzwaitcursor_rsc.swf"/>
... then setting the cursor globally by calling:
lz.Cursor.setCursorGlobal('waitcursor');
Rather than using an image for the cursor, I'm thinking of drawing it
with the drawview, then using SWF9 APIs to extract the BitmapData
object. I can do this already in OL and set the BitmapData object to a
view, to display it. But in this case, I'd need to somehow set the data
for a named resource.
Any ideas on how to go about this?
Thanks,
Antun
<canvas>
<script when="immediate">
public class CursorSprite extends Sprite {
#passthrough(toplevel:true) {
import flash.display.Graphics;
import flash.display.Sprite;
}#
public static var sourceGraphics:Graphics = null;
public function CursorSprite () {
super();
this.mouseEnabled = false;
this.mouseChildren = false;
// copyFrom() is swf10 only, for swf9 a different API needs to be used,
e.g. beginBitmapFill()
this.graphics.copyFrom(CursorSprite.sourceGraphics);
}
}
</script>
<drawview id="dview" width="30" height="30">
<handler name="oncontext">
this.rect(5,5,25,25);
this.fillStyle = "#abc";
this.fill();
</handler>
</drawview>
<button x="50" >
<handler name="onclick"><![CDATA[
// install CursorSprite class as fake resource
LzResourceLibrary['mycursor'] = {assetclass: CursorSprite};
// make drawview context accessible for CursorSprite
CursorSprite.sourceGraphics = dview.context;
// set custom cursor
lz.Cursor.setCursorGlobal('mycursor');
]]></handler>
</button>
</canvas>