problem with picture loading (jpg, png,...)

2 views
Skip to first unread message

sjwkzn

unread,
Nov 16, 2009, 11:36:21 AM11/16/09
to masapi
Hi,

I'm just starting to work with masapi. And I have a problem : I manage
to load pictures, but after the loading, it's impossible to display
them : it brings back a "TypeError".
More precisely, it works for ".swf " files, but not for the pitcures.

Here is my code (the same than in the user guide...)


import ch.capi.net.*;
import ch.capi.events.*;


var cml:CompositeMassLoader = new CompositeMassLoader();
var file1:ILoadableFile=cml.addFile("image.jpg");


file1.addEventListener(Event.OPEN, handleOpen);
file1.addEventListener(ProgressEvent.PROGRESS, handleProgress);
file1.addEventListener(Event.COMPLETE, handleComplete);
file1.addEventListener(IOErrorEvent.IO_ERROR, ioError);

function ioError(evt:IOErrorEvent):void {
trace("ioError");
}
function handleOpen(evt:Event):void {
trace("open");
}
function handleProgress(evt:ProgressEvent):void {
trace("progress");
}
function handleComplete(evt:Event):void {
trace("complete");
var rawData = file1.getData();

// and now I try to display the picture
addChild(rawData);
}

cml.start();



But thi Error is is displayed :

TypeError: Error #1034: Echec de la contrainte de type : conversion de
flash.utils::ByteArray@106609a1 en flash.display.DisplayObject
impossible.
at proto_massLoad_01_fla::MainTimeline/handleComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at ch.capi.net::AbstractLoadableFile/onComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()


Could you help me?

Thanks
Reply all
Reply to author
Forward
0 new messages