Skip to main content
gardo
Participating Frequently
July 29, 2014
Question

Could someone help me out? ActionScript

  • July 29, 2014
  • 1 reply
  • 266 views

import flash.display.MovieClip;

var clip:clip01 = new clip01;

var clip2:clip02 = new clip02;

var clip3:clip03 = new clip03;

var clip4:clip04 = new clip04;

var clip5:clip05 = new clip05;

var files:Array = [clip,clip2,clip3,clip4,clip5];

function randomizeArray(array:Array):Array

{

    var newArray:Array = new Array();

    while (array.length > 0)

newArray.push(array.splice(Math.floor(Math.random()*array.length), 1));

    return newArray;

}

var RandomArray:Array = randomizeArray(files);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

trace(RandomArray[0]);

trace(clip);

var c:MovieClip = MovieClip(RandomArray[0]);

addChild(clip); // it’s OK

addChild(c); // I get the error msg bellow:

Scene 1, Layer 'movies', Frame 1, Line 29              1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.

Could someone help me out?

I cannot add MovieClip on the stage from the array.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 29, 2014

use:

addChild(DisplayObject(c));

gardo
gardoAuthor
Participating Frequently
July 29, 2014

I have tried these with no success

#1

var c:MovieClip = MovieClip(RandomArray[0]);

addChild(DisplayObject(c));

#2

addChild(DisplayObject(RandomArray[0]));

kglad
Community Expert
Community Expert
July 29, 2014

attach a screenshot of the error message, and your code so we can see the code line numbers, and the timeline so we can see that there is code in only 1 layer of frame 1.