I am new to AS3 and I need some help with the Senocular Transform Tool开发者_Python百科 (AS3 version)
I'm having trouble with loading in an external image such that I can transform with the Senocular Transform Tool class.
I have managed to load in the picture but the transform class doesn't seem want to grab it.
var fileRef:FileReference = new FileReference();
MovieClip(root).loadBtn.addEventListener(MouseEvent.CLICK, openClick);
function openClick(evt:MouseEvent):void {
fileRef.addEventListener(Event.SELECT, selectHandler);
fileRef.addEventListener(Event.COMPLETE, completeHandler);
var fileFilter:FileFilter = new FileFilter("Images","*.jpg;*.jpeg;*.gif;*.png");
fileRef.browse([fileFilter]);
}
function selectHandler(event:Event):void {
fileRef.load();
}
function completeHandler(event:Event):void {
var image:Loader = new Loader();
var imgSprite:Sprite = new Sprite();
image.loadBytes(fileRef.data);
imgSprite.addChild(image);
addChild(imgSprite);
imgSprite.addEventListener(MouseEvent.MOUSE_DOWN, select);
imgSprite.x=200;
imgSprite.y=200;
}
I'm trying to load the image from my HD into a loader, then a sprite, then an empty container movieClip on the stage...
Can anyone point me in the right direction?
I think you should wait for LOADER to load complete byte before adding them to sprite, because huge file takes time to load in App,
like that
var image:Loader = new Loader();
image.contentLoaderInfo.addEventListener(Event.COMPLETE, imageloaded);
image.loadBytes(fileRef.data);
and event handler as
private function imageloaded(event:Event):void
{
var image:Loader = event.currentTarget.loader as Loader;
var imgSprite:Sprite = new Sprite();
imgSprite.addChild(image);
addChild(imgSprite);
}
you may also used its Fault handler to manage faults
Hopes that helps
精彩评论