mouse X/Y coordinates: Javascript to Actionscript

  • sprouletopia
  • Born
  • Born
  • No Avatar
  • Joined: 13 Jun 2006
  • Posts: 3
  • Status: Offline

Post June 13th, 2006, 2:34 pm

Hello Everyone,

I am taking a value from javascript and want to use it in actionscript. I know how to pass the value (mouse X/Y coordinates) in to a dynamic text box but am stumped when it comes to reading that value when it changes and then using the new value in actionscript.

I would like to move an object’s (“ a car”) when the “X” value changes.

So I have Source files.
1. One is of a car that will move back and forth with the mouse, but only if the cursor is over the SWF.Example

2. The second is html with JavaScript that will read in x/y and display it. Example

3. The third is an example my attempt of getting the X in to a dynamic text box. Now I can do that but how do I reference the value of that text box and use it again in the Actionscript. Example

Link for source files

Can someone please take a look and help me with this?

thank you,
Jason
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 13th, 2006, 2:34 pm

Post June 13th, 2006, 2:43 pm

1) when use URL=some link, dont use "some link"
use simply: [URL=http://some ...
2) why you need the x, y coordinates to be passed from javascript into flash?
if you tell me the end point of your work, then there might be other ways to do it, so stop asking for what you think you need and better ask for what you want to achieve.
“All you need in this life is ignorance and confidence, and then success is sure. ”
  • sprouletopia
  • Born
  • Born
  • No Avatar
  • Joined: 13 Jun 2006
  • Posts: 3
  • Status: Offline

Post June 13th, 2006, 2:51 pm

Well what i need to happen is :

the car has to follow the cursor whether the cursor is on the movie or on the browser window. it also needs to use as little javascript as possible.

thank you,

Jason

Post June 13th, 2006, 3:07 pm

well then, i see that you know how to move the car to follow the cursor when it`s in the movie.
next step, when it`s in the browser, i see that you have:
document.onmousemove = getXY;
so .. in getXY function, after you get the x and y of the mouse, send them to flash. This way, when mouse is moved, the new coordinates will be sent. I dont know how fast the new values will be updated, but i dont think will take too much time.
just test and see
“All you need in this life is ignorance and confidence, and then success is sure. ”
  • sprouletopia
  • Born
  • Born
  • No Avatar
  • Joined: 13 Jun 2006
  • Posts: 3
  • Status: Offline

Post June 13th, 2006, 3:24 pm

well how i get the x in now for the text box is:
flashMovie.SetVariable("test", nx);

i have got the car to move through javascript with:
flashMovie.SetVariable("mycar._x", nx);

but if i do it that way then all if statments and control for the cars X have to be done in javascript (I think). I can do it that way. the meat of the code has to be after it hits actionscript.

Post June 13th, 2006, 4:00 pm

no no no no no
in actionscript you would have something like:
onEnterFrame = function()
{
        tweenEaseIn(crtMouseXPosition);
}

onMouseMove = function()
{
    crtMouseXPosition = this._xmouse;
}


then, in javascript, you just set the variable crtMouseXPosition.
and ... ye, that`s all.
“All you need in this life is ignorance and confidence, and then success is sure. ”

Post Information

  • Total Posts in this topic: 6 posts
  • Moderator: Moderator Team
  • Users browsing this forum: No registered users and 127 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2008. Driven by phpBB © 2001-2008 phpBB Group.

 
 
 

Join Ozzu for Free