Rename a file using onSaveEntry event craft()-&gt;on('entries.saveEntry', function(Event $event)
{
    // entry slug, will be used as image name
    $EntryTitle = $event-&gt;params['entry']['slug'];

    // Get attached image
    $entry = $event-&gt;params['entry']['imgdir'][0];

    craft()-&gt;assets-&gt;renameFile($entry, $EntryTitle);
    $entry-&gt;setAttribute('filename', $EntryTitle);
    craft()-&gt;assets-&gt;storeFile($entry);

});


This init() code gets the current entry title right after it was saved, and is supposed to use it to rename an attached file.
I used a method given by another developer in the context of a saveAsset, but it doesn't seem to work in this new context (→ see Change asset name on upload).

I'm not sure i've set the $entry variable to correct data. Fact is I'm able trough the path you see above, to get access to the asset. 
Please tell me where this code is wrong.
You probably just confused the entry model and the asset model, see if the code below works for you.
I guess the entries.onBeforeSaveEntry event is a better match in this case, and I also added some conditionals to
only do something for a specific entry section and type, and if there's exactly one asset selected. I hope this helps (code is untested)!

craft()-&gt;on('entries.beforeSaveEntry', function(Event $event)
{
    $entry = $event-&gt;params['entry'];

    if (($entry-&gt;section['handle'] == 'friends') &amp;&amp; ($entry-&gt;type['handle'] == 'friends'))
    {
        $title = $entry-&gt;slug;
        $assets = $entry-&gt;imgdir;

        if (count($assets) != 1)
        {
            $event-&gt;params['entry']-&gt;addError('imgdir', Craft::t('Exactly 1 asset has to be selected.'));
            $event-&gt;performAction = false;
        }
        else
        {
            $filename = $title.'.'.$assets[0]-&gt;getExtension();

            craft()-&gt;assets-&gt;renameFile($assets[0], $filename);
            craft()-&gt;assets-&gt;storeFile($assets[0]);
        }
    }
});