# Passing parameters to a function help

**URL:** <https://forum.kirupa.com/t/passing-parameters-to-a-function-help/285883>\
**Category:** Uncategorized\
**Created:** [April 7, 2009, 3:54pm UTC](https://forum.kirupa.com/t/passing-parameters-to-a-function-help/285883 "2009-04-07T15:54:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scarjoh](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@scarjoh](https://forum.kirupa.com/u/scarjoh)\
**Post date:** [April 7, 2009, 3:54pm UTC](https://forum.kirupa.com/t/passing-parameters-to-a-function-help/285883/1 "2009-04-07T15:54:43Z")

</div>

i am loading an image with a loader, and in \*\*onComplete \*\*function i would like to call \*\*calculateRatio \*\*function and pass it **Loader.content.width** and **Loader.content.height** so it can compare it with the current stage width and height and resize image proporcionally to fit the screen.  
how would i go about passing that parameters?

```php
function callHomePage() {
    bgLoader = new Loader();
    bgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    bgLoader.load(new URLRequest(bgArr[2]));
}
function onComplete(e:Event) {
    bg_mc.addChild(bgLoader);
    calculateRatio();
    
    bg_mc.x = (stage.stageWidth / 2) - (bg_mc.width / 2);
    bg_mc.y = (stage.stageHeight / 2) - (bg_mc.height / 2);
    TweenLite.to(bg_mc, 3, {alpha:1});
}
function calculateRatio():void{
    var destinationRatio:Number = stage.stageWidth / stage.stageHeight;// stage ratio
    var targetRatio:Number = bgLoader.content.width / bgLoader.content.height;// body ratio

    if (targetRatio < destinationRatio) {
        bgLoader.content.height = (stage.stageWidth / bgLoader.content.width) * bgLoader.content.height;
        bgLoader.content.width = stage.stageWidth;
    } else {
        bgLoader.content.width = (stage.stageHeight / bgLoader.content.height) * bgLoader.content.width;
        bgLoader.content.height = stage.stageHeight;
    }
}

```
