James Marsden landed a role in 'Hairspray' after a random encounter with Julia Roberts.

The 46-year-old actor explained how he was being interviewed by director Adam Shankman when the 'Pretty Woman' star came up and showered him with praise.

In an interview on 'The Ellen DeGeneres Show', James said: ''I had a tap on my shoulder and it was Julia Roberts just standing there and she said, 'Sorry I didn't mean to interrupt, but I just wanted to tell you you're in my favourite movie, 'The Notebook', and I loved what you do in the film and congratulations on it, bye nice to meet you.'''

James went on to play the role of TV host Corny Collins in the 2007 movie, and said that Julia's intervention convinced Shankman to cast him.

The 'Dead to Me' star said: ''Adam Shankman turns to me and says, 'If you didn't have the role already, I think that just kind of sealed it.'''

James recently starred in the 'Sonic the Hedgehog' movie and explained that he was convinced to appear in the video game adaptation by the clever script, which didn't ''underestimate the intelligence'' of youngsters.

The actor - who played the role of Tom Wachowski, a sheriff who befriends the titular blue speedster - said: ''There was a little bit of hesitation, but you can overthink things like that sometimes.

''You look at it and go, 'Do I like the director? Do I like the script? Is there some fun stuff in there? Is the script better than your run of the mill, average, cookie-cutter this type of movie?'

''And I didn't feel like that was the case with Sonic.

''I felt the writing was really sharp and skewed more towards teenagers and adults.

''Obviously, it's a family movie, but it doesn't underestimate the intelligence and the sense of humour of young people nowadays, which is far more advanced than I was, when I was young.

''The jokes were smart, they were clever, and there was heart to it.''