A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [RESOLVED] onClick command

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    27

    resolved [RESOLVED] onClick command

    I have such onClick command in my php file:
    onClick="hideCol(4, true); hideCol(5, true);showDiv('2');return false;"

    I want the same command to be executed in flash, can I do such onClick command in flash so it will trigger some javascript in php? Basically do the onClick command above but the php file must catch the command.

    Thanks, Yan

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You can add an event listener for Mouse.CLICK to whatever object you want to respond to clicks. The function can use ExternalInterface to call javascript in the html page. None of that has anything to do with php.

  3. #3
    Junior Member
    Join Date
    Aug 2009
    Posts
    27
    I would like to have an example

  4. #4
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Code:
    ExternalInterface.call("hideCol(4, true); hideCol(5, true);showDiv('2');");

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Code:
    someClip.addEventListener(MouseEvent.CLICK, triggerJS);
    
    function triggerJS(event:Event):void{
      if (ExternalInterface.available){
         ExternalInterface.call("hideCol", 4, true);
         ExternalInterface.call("hideCol", 5, true);
         ExternalInterface.call("showDiv", '2');
      }
    }

  6. #6
    Junior Member
    Join Date
    Aug 2009
    Posts
    27
    1087: Syntax error: extra characters found after end of program.

    What does that mean? I've used your code 5TonsOfFlax, nothing else besides a movieClip.

  7. #7
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    That error message occurs if you have stuff after the closing brace in an external .as file. Are you using an external .as file, or frame script? I had assumed frame script.

  8. #8
    Junior Member
    Join Date
    Aug 2009
    Posts
    27
    Nothing, that was just an empty flash file.

  9. #9
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    If it was empty, you couldn't be using the code I posted. I'm guessing you put it in an actions layer, which makes it frame script.

    There's nothing in that code which would cause that error. But you will have to add
    Code:
    import flash.external.ExternalInterface;
    to the top.

  10. #10
    Junior Member
    Join Date
    Aug 2009
    Posts
    27
    Thanks, it worked!

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