A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: javascript > flash

  1. #1
    uhm
    Join Date
    Nov 2000
    Location
    Leeds(ish), UK
    Posts
    99
    is it possible to set the X and Y of the mouse in flash using javascript?

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    I think the short answer to this is, sadly, 'no' ;(

    however you could use a custom cursor in flash and pass the variables to position this cursor to the flash from javascript [either at loading time or using fscommand]. Would this do what you want it to do?

    - n.

  3. #3
    uhm
    Join Date
    Nov 2000
    Location
    Leeds(ish), UK
    Posts
    99

    hmm

    possibly.

    the thing i have to do is create an animation in a movie, which has a character in it, and his hand will move to point at the mouse (although it will be constraint to an arc).
    this is fairly simple if its all in flash, however the mouse will go off into other frames and off the flash movie.

    i can get someone to code the javascript that will find the mouse position on any frame, i just need to get the JS to tell flash where the mouse is, then maybe i can do something then...

    this is a toughy. any ideas?

  4. #4
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    aha!
    have been thinking about it a bit more. forget the previous comment about the fscommand - that won't get the variables back into the flash.

    I haven't been able to try anything but I don't think there is an easy answer. You can easily pass variables from javascript when the flash movie is first loading, so maybe it would be worth a try to reload the page with the flash movie every 1/2 second or something - it will be cached after this, so would be okay but you might get a lot of flashing [of the non-macromedia kind ]

    The only other way to get variables into the flash is using loadvariables but this always requests a page from the server.

    I seem to remember someone here saying that they were using the getUrl with javascript to do proper maths functions in Flash 4 but can't remember how they got the results back into the Flash.

    If you have the expertise, I think you should look at Director to solve this - this will enable you to get the mouse position anywhere on the screen and you might be able to pass teh variables to teh flash inside director [don't quote me on that though...]

    will keep thinking about it. we came across a similar problem a while ago but didn't find a solution, this brought some new life into it!

    let us know how you get on!

    - n.

  5. #5
    uhm
    Join Date
    Nov 2000
    Location
    Leeds(ish), UK
    Posts
    99

    on another project

    I need to know if javascript can do a tell target. from all i've seen it can't be done so i might have to make it set a variable instead and tell it to keep checking for the change.

    but can it be done?

    EDIT: ignore that i found out how. i used the following code:

    <script>
    function target3(){
    var movie = window.document.movie;
    movie.TGotoLabel("/movieclip", "three");
    }
    </script>
    [Edited by voodoo-wizard on 06-06-2001 at 09:55 AM]

  6. #6
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    hey wizard,

    nice one on the javascript 'tell target'.
    I had a quick look at the page at Macromedia on this [javascript interaction with flash player], hopeing that it would provide some info about solving your original problem.

    Can't see any way of passing a variable though - other than doing a 'gotoFrame' action a number of times like teaching a dog how to do sums - but then you would need to 'bark' 253 times to specify a mouse x pos of 253 - a bit ugly

    let me know if you find out something else...

    cheers - n.
    [Edited by enemem on 06-06-2001 at 12:56 PM]

  7. #7
    Junior Member
    Join Date
    Sep 2000
    Posts
    17
    Look guys easy...

    As a little example;

    Set up a Dynamic text box in you flash movie and name a variable ie myVariable.
    Then in the html code your movie is in give the <object> tag that the movie is in an id... and in the <embed> tag give it the same name and activate swLiveconnect
    Code:
    <object id="MyFlashMovie"
          classid="clsid:......"
          codebase="http:///down...." 
          width=200
          height=200
          <param name=movie value="MyFlashMovie.swf">
          <name=quality value=high>
          <embed name="MyFlashMovie"
                    src="MyFlashMovi.swf"
                 swLiveconnect=true
                    pluginspage="http://www.macromedia.com/
    
                    ...etc...
    
           </embed>
    </object>
    All I have done here is add the bold statments to the flash object (as generated by dreamweaver UltraDev).

    Then using a simple JavaScript function you can set the flash variable created.
    Code:
    function change_FlashVariable(){
       document.MyFlashMovie.SetVariable("myVariable","WhatYouWantToChangItTo");
    }
    To do what was origianly asked all you need to do is create a JavaScript loop to read mouse position and then pass that onto your flash variable in the same way!

    Saying all that I myself am having a little trouble. This works fine in IE5 but Netscape ignores it. Someone please please please let me know how to solve it. I also can't do this from window to window or frame to frame...

    martin

  8. #8
    uhm
    Join Date
    Nov 2000
    Location
    Leeds(ish), UK
    Posts
    99
    yes martin thanx for that although i've had succes passing a variable to it, i suppose its the only way to solve this problem.

  9. #9
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    yeah - that's great actually - nice one + thanks!

    I've been surfing round the macromedia site for a while now to find a definitive guide on all this but could only find one page about javascript interaction with the flash plugin which doesn't mention the SetVariable command and another page which mentions the SetVariable but no other commands.
    So I wonder what else I'm missing? Do you know of anywhere?

    that's a great help laughing () anyway - much appreciated!

    see ya - n.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center