Hi guys and gals, I’m having trouble working out how to do some ‘basic’ coding with, well i guess variables.
To summarise, I have some code that works, which randomly inserts a picture from a list of 3 i provided, but i want to make it that, if picture1.png is randomly chosen then door_right is correct and door_left is incorrect (door_right and door_left being swf’s (because they are animated to move in the breeze)).
A random picture out of the 3 given is inserted in the middle of the screen, depending on the picture the left or right door is the correct door to enter, to progress.
If it helps, here is my code for inserting a random picture!
[SIZE=2]***
var imageLoader:Loader = new Loader();
var _pictureArray:Array = ["***[/SIZE] picture1.png[SIZE=2]***", “***[/SIZE] picture2[SIZE=2]***.png”, “***[/SIZE] picture[SIZE=2]***3.png”];
var _whatPicture:Number = Math.floor(Math.random()*3);
trace("_whatPicture = "+_whatPicture);
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
imageLoader.load(new URLRequest(_pictureArray[_whatPicture]));
function onComplete(e:Event):void{
var _image:Bitmap = Bitmap(imageLoader.content);
_image.x=180;
_image.y=82;
var _bitmap:BitmapData = _image.bitmapData;
addChild(_image);
} ***[/SIZE]
Thanks so much, I hope this isn’t really complicated and too much to ask, if anyone has a link to a tutorial or similar question, it would be greatly appreciated!! Thankyou!!