PDA

View Full Version : Loader to a MovieClip



redline024
June 20th, 2008, 05:36 PM
I am pre loading images from an XML file in AS3 and then displaying them later. First I loop through the XML to get the images and then load them into a movieclip. Later when i make the swf image ive loaded visable i want it to play. The problem I'm having is that when i try to tell the swf to play by using the getChildByName its telling me it can't play because its a loader and not a movieclip. How can i convert this loaded swf to the movieclip it should be so i can tell the swf to play??!? Im all out of ideas.

where i grab the images, load them and name them:
var numImages = xmlData.content.*.image.length();
var sceneArray = new Array();
var imageArray = new Array();
var imageHolder = new Array();
var i;
for (i=0; i<numImages; i++) {
imageArray = xmlData.content.*.image.text();
sceneArray = xmlData.content.*.image.@s;
imageHolder = new MovieClip();
var theScene = new Loader();
theScene.load(new URLRequest(imageArray[i]));
imageHolder[sceneArray[i]] = theScene;
imageSpot.addChild(imageHolder[sceneArray[i]]);
imageHolder[sceneArray[i]].alpha = 0;
imageHolder[sceneArray[i]].name = "scene" + sceneArray[i];
}

where i try to make it play:

if (imageSpot.getChildByName("scene14") != null) {
imageSpot.getChildByName("scene14").alpha = 1;
MovieClip(imageSpot.getChildByName("scene14")).play();
fade:Tween;
fade = new Tween(imageSpot,"alpha",None.easeNone,0,1,1,true);
}

PLEASE SOMEONE HELP!! thanks.

Krilnon
June 20th, 2008, 06:08 PM
http://livedocs.adobe.com/flex/3/langref/flash/display/Loader.html#content

redline024
June 23rd, 2008, 09:25 AM
http://livedocs.adobe.com/flex/3/langref/flash/display/Loader.html#content

imageSpot.getChildByName("scene14").content.play();

when I try that I get:
1119: Access of possibly undefined property content through a reference with static type flash.display:DisplayObject.

redline024
June 23rd, 2008, 10:40 AM
Someone please help, i can't for the life of me figure this out. I've tried this in the beginning part:

for (i=0; i<numImages; i++) {
imageArray = xmlData.content.*.image.text();
sceneArray = xmlData.content.*.image.@s;
var url = imageArray[i];
var imageRequest = new URLRequest(url);
var loader = new Loader();
loader.load(imageRequest);
imageSpot.addChild(loader);
var theMovie:MovieClip = imageSpot.loader.content as MovieClip;
trace(imageSpot.theMovie);
imageSpot.theMovie.alpha = 0;
imageSpot.theMovie.name = "scene" + sceneArray[i];
}

and its telling me that imageSpot.theMovie is null

redline024
June 23rd, 2008, 10:51 AM
sorry for posting again, i switched around the code a bit. With this code imageLoader traces as an object loader. basically I just need to know how to convert this object loader into a movie clip so i can tell that swf to play later by using imageSpot.getChildByName("scene14").play() or a way of leaving it as a loader and telling the swf in the loader to play using getChildByName.

redline024
June 23rd, 2008, 11:07 AM
when trying to convert the loader to a movieclip later on i get this:
code: MovieClip(imageSpot.getChildByName("scene14")).play();

error: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@4018061 to flash.display.MovieClip.

Felixz
June 23rd, 2008, 04:51 PM
imageSpot.getChildByName("scene14").content.play();