How do you add a mouse trailer in Flash CS4?
Printable View
How do you add a mouse trailer in Flash CS4?
The code works but it displays in the background. Here's my code below.
The rest of the html file loads a Flash movie and when you move the mouse you can only see it behind the flash movie.Code:<html>
<head>
<title>Mouse Test Trailer</title>
<style>
.spanstyle {
position:absolute;
visibility:visible;
top:-50px;
font-size:10pt;
font-family:Verdana;
font-weight:bold;
color:black;
}
</style>
<script>
/*
Cursor Trailor Text
*/
var x,y
var step=20
var flag=0
// Your message. Important: the space at the end of the sentence!!!
var message="Indian Queen Elementary School! "
message=message.split("")
var xpos=new Array()
for (i=0;i<=message.length-1;i++) {
xpos[i]=-50
}
var ypos=new Array()
for (i=0;i<=message.length-1;i++) {
ypos[i]=-50
}
function handlerMM(e){
x = (document.layers) ? e.pageX : document.body.scrollLeft+event.clientX
y = (document.layers) ? e.pageY : document.body.scrollTop+event.clientY
flag=1
}
function makesnake() {
if (flag==1 && document.all) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("span"+(i)+".style")
thisspan.posLeft=xpos[i]
thisspan.posTop=ypos[i]
}
}
else if (flag==1 && document.layers) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("document.span"+i)
thisspan.left=xpos[i]
thisspan.top=ypos[i]
}
}
var timer=setTimeout("makesnake()",30)
}
</script>
</head>
<body onLoad="makesnake()" style="width:100%;overflow-x:hidden;overflow-y:scroll">
<script>
<!-- Beginning of JavaScript -
for (i=0;i<=message.length-1;i++) {
document.write("<span id='span"+i+"' class='spanstyle'>")
document.write(message[i])
document.write("</span>")
}
if (document.layers){
document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = handlerMM;
// - End of JavaScript - -->
</script>
</body>
</html>
Thank you
Follow the below advice, it's the best you can do without recompiling the .swf, which is usually not required. But be aware that when the mouse is over the Flash object, the Flash object may still take control of the mouse cursor. But at least when the mouse isn't over the Flash object, the trailer effect should show over the Flash object. Some Flash objects will not even allow this, but most do.
Loosely from:
http://www.macromedia.com/cfusion/kn...fm?id=tn_14201
Add in this language to your object/embed tag(s) -
Add the following parameter to the OBJECT tag:
Add the following attribute to the EMBED tag:HTML Code:<param name="wmode" value="transparent">
Or, if you are using two object tags, as can and is sometimes done, add the param tag to both of them.Code:wmode="transparent"
If you are using script to generate the tags, the wmode transparent must be passed to the script. This is easily accomplished but, varies depending upon the sort of script one uses. Some scripts do it automatically.
Thank you for your response, however the trailer is still being displayed behind the flash object.
Please post a link to a page on your site that contains the problematic code so we can check it out.
Here's the link
"http://www.soaring-technologies.com/indianqueen/test6.html"
Change this (highlighted as shown):
Oh, and if you want this to work in other browsers besides IE, use this version of the trailer script:Code:<script language="JavaScript" type="text/javascript">
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
'width', '850',
'height', '1200',
'src', 'iqes',
'quality', 'high',
'pluginspage', 'http://www.adobe.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'transparent',
'devicefont', 'false',
'id', 'iqes',
'bgcolor', '#ffffff',
'name', 'iqes',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'iqes',
'salign', ''
); //end AC code
</script>
Code:<script>
/*
Cursor Trailor Text
*/
var x,y
var step=20
var flag=0
// Your message. Important: the space at the end of the sentence!!!
var message="Indian Queen Elementary School! "
message=message.split("")
var xpos=new Array()
for (i=0;i<=message.length-1;i++) {
xpos[i]=-50
}
var ypos=new Array()
for (i=0;i<=message.length-1;i++) {
ypos[i]=-50
}
function handlerMM(e){
e = e || event;
x = typeof e.pageX === 'number'? e.pageX : document.body.scrollLeft+event.clientX
y = typeof e.pageY === 'number'? e.pageY : document.body.scrollTop+event.clientY
flag=1
}
function makesnake() {
if (flag==1 && document.all) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("span"+(i)+".style")
thisspan.posLeft=xpos[i]
thisspan.posTop=ypos[i]
}
}
else if (flag==1 && document.layers) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = eval("document.span"+i)
thisspan.left=xpos[i]
thisspan.top=ypos[i]
}
}
else if (flag==1 && document.getElementById) {
for (i=message.length-1; i>=1; i--) {
xpos[i]=xpos[i-1]+step
ypos[i]=ypos[i-1]
}
xpos[0]=x+step
ypos[0]=y
for (i=0; i<message.length-1; i++) {
var thisspan = document.getElementById('span' + i).style;
thisspan.left=xpos[i]+'px';
thisspan.top=ypos[i]+'px'
}
}
var timer=setTimeout("makesnake()",30)
}
</script>
When I change wmode to "transparent" the only thing you see is the mouse trailer and nothing else.
Works fine here:
http://home.comcast.net/~jscheuer1/side/flash_2_h.htm
I'm not sure what's going on but it's still not working. When I move the mouse over the flash object the object begins to wipe itself out. Do you have any links on creating text mouse trailer inside of Flash?