# Simple variables (if this, then this is true)

**URL:** https://forum.kirupa.com/t/simple-variables-if-this-then-this-is-true/322903
**Category:** flash
**Created:** [June 8, 2011, 9:03am UTC](https://forum.kirupa.com/t/simple-variables-if-this-then-this-is-true/322903 "2011-06-08T09:03:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![govjmal](https://avatars.discourse-cdn.com/v4/letter/g/839c29/32.png) [@govjmal](https://forum.kirupa.com/u/govjmal)
#### Post date: [June 8, 2011, 9:03am UTC](https://forum.kirupa.com/t/simple-variables-if-this-then-this-is-true/322903/1 "2011-06-08T09:03:26Z")

</div>

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!!
