Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-04-2012, 09:45 PM   PM User | #1
ted.johnson0988
New Coder

 
Join Date: May 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
ted.johnson0988 is an unknown quantity at this point
How can I make an image slide across the screen when another object loads?

Alright, this is REALLY convoluted but I think it would be cool

I have a music player on my blog:
Code:
<!--SCM Music Player by Adrian C Shum - http://scmplayer.net-->
<script type="text/javascript" src="http://scmplayer.net/script.js" ></script>
<script type="text/javascript">
SCMMusicPlayer.init("{'skin':'skins/black/skin.css','playback':{'autostart':'true','shuffle':'true','volume':'40'},'playlist':[{'title':'2Spooky Battle','url':'http://a.tumblr.com/tumblr_mbdoptQ5LT1rte8jio1.mp3'}],'placement':'bottom','showplaylist':'false'}");
</script>
<!--End of SCM Music Player script-->
And I also have two pictures:
Code:
<html>
<head>
<style type="text/css">

#img1{
  position: fixed;
  right: 10px;
  bottom: 100px;
  z-index: 10;
}

#img2{
  position: fixed;
  left: 10px;
  top: 10px;
  z-index: 10;
}

</style>
</head>

<body>
  <img src="IMAGE1.png" id="img1">
  <img src="IMAGE2.png" id="img2">
</body>
</html>
I want img1 to slide from the left side of the screen to its fixed position on the right over the span of 2.6 (or 3, if decimals aren't possible) seconds. But this should only happen after the music starts playing (so it should domino after its loaded and autoplays). (From there, if possible, I'd like img1 to just hover up and down but I can live without that.)

Then I'd like img2 to just appear AFTER img1 has finished its initial animation (the slide across the screen). That needs to do nothing but just stay there.

The final and most important piece of the puzzle is that this can only happen ONCE. This is a blog so I don't want the pictures to re-load if someone goes to the next page. The music player has this property already but I'd like it for the pictures.


This is horribly complicated, I know, and I'm sorry to even be asking. But I think it would be really cool to get done.
ted.johnson0988 is offline   Reply With Quote
Old 10-04-2012, 10:32 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,461
Thanks: 52
Thanked 457 Times in 455 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
you would have to look at your audio plugin to see if there is a "playback start" event listener. Most have this.

You would then set an interval to move your image1 pixel by pixel across the screen until it reaches its final position (you can divide the amount of pixels it needs to move by the seconds it should take to get there and set your values accordingly). Once it reaches that position you would change image 2 from display:none to display:inline.

None of it's that complicated, but finding that event listener would be my first step.
xelawho is offline   Reply With Quote
Old 10-04-2012, 11:05 PM   PM User | #3
ted.johnson0988
New Coder

 
Join Date: May 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
ted.johnson0988 is an unknown quantity at this point
Quote:
Originally Posted by xelawho View Post
you would have to look at your audio plugin to see if there is a "playback start" event listener. Most have this.

You would then set an interval to move your image1 pixel by pixel across the screen until it reaches its final position (you can divide the amount of pixels it needs to move by the seconds it should take to get there and set your values accordingly). Once it reaches that position you would change image 2 from display:none to display:inline.

None of it's that complicated, but finding that event listener would be my first step.
I looked and found
Code:
{if(elm.addEventListener){elm.addEventListener(evType,fn,useCapture);return true;}
as the only mention of an event listener

Also, what you see in my first post is basically the extent of my knowledge of HTML and coding in general so I'm not really sure of how to implement anything else you said..
ted.johnson0988 is offline   Reply With Quote
Old 10-04-2012, 11:24 PM   PM User | #4
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,461
Thanks: 52
Thanked 457 Times in 455 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
hmm, I don't really know - from the documentation it seems to be made from 3 other libraries. You could try adding an onplay alert, by replacing that line with this:
Code:
SCMMusicPlayer.init("{'skin':'skins/black/skin.css','playback':{'autostart':'true','shuffle':'true','volume':'40'},'playlist':[{'title':'2Spooky Battle','url':'http://a.tumblr.com/tumblr_mbdoptQ5LT1rte8jio1.mp3'}], 'onplay': function() {alert('playing');},'placement':'bottom','showplaylist':'false'}");
and seeing if it alerts when playback begins
xelawho is offline   Reply With Quote
Old 10-05-2012, 01:54 AM   PM User | #5
ted.johnson0988
New Coder

 
Join Date: May 2012
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
ted.johnson0988 is an unknown quantity at this point
Quote:
Originally Posted by xelawho View Post
hmm, I don't really know - from the documentation it seems to be made from 3 other libraries. You could try adding an onplay alert, by replacing that line with this:
Code:
SCMMusicPlayer.init("{'skin':'skins/black/skin.css','playback':{'autostart':'true','shuffle':'true','volume':'40'},'playlist':[{'title':'2Spooky Battle','url':'http://a.tumblr.com/tumblr_mbdoptQ5LT1rte8jio1.mp3'}], 'onplay': function() {alert('playing');},'placement':'bottom','showplaylist':'false'}");
and seeing if it alerts when playback begins
I've done that and the player still works but how would I link the appearance of the images to the "onplay" feature?
Forget everything about it moving; I can take care of that myself through use of .gifs but I just want it to appear when the music starts.

Thank you so much for your help, by the way.
ted.johnson0988 is offline   Reply With Quote
Reply

Bookmarks

Tags
css, java, moving picture, music player

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:54 AM.


Advertisement
Log in to turn off these ads.