Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

play movie event at click location cs3 flash

New to flash,

I am creating a menu with buttons. The buttons will be linked to URL's with a second and a half delay for sound within the button located on the 'down' keyframe.

What I want is for a short (1 second) movie event to load, in the exact location of any click on any of the buttons in the menu. In other words, if the user clicks the upper left hand corner of the Contact Us button, I want my movie event to play in the upper left hand corner of the Contact Us button, a two second delay, and then redirect to a URL in the same window.

I am not even sure if I have been going about this the right way. I have created instances for the button and the movie event. I have been trying to insert in the first frame of an 'action script' layer, code that would direct the button to load the movie. Am I way off on the wrong track using combinations of the following commands (where btn is my button, and gunshot is my movie event):  
btn.addEventListener(onPress, gunshot.addASCuePoint);
onRelease.findCuePoint (gunshot);
gunshot.play
0
shemp609
Asked:
shemp609
  • 2
  • 2
1 Solution
 
rascalpantsCommented:

well you are using AS 3.0, but a bit wrong...

try the below instead...


and I am just assuming the following from the way you have it written..

- you have a function called findCuePoint, and you pass in the MovieClip "gunshot"
- gunshot has a function inside of it called "addASCuePoint" and it is called on click
- then you want the gunshot movieclip to play from the keyframe of where it is currently located

if any of this is wrong, then please explain a little better as to what you are trying to do...

and just an FYI... don't use buttons... only use movieclips, and controll everything with code from there...



rp / ZA





import flash.events.*;
 
btn.addEventListener( MouseEvent.CLICK, btn_OnClick);
 
function btn_OnClick( evt:MouseEvent ):void
{
  findCuePoint( gunshot );
  gunshot.addASCuePoint();
  gunshot.play();
}

Open in new window

0
 
shemp609Author Commented:
rascal-
thank you.
After a lot of trial and error I got the movie clip to load using the following script where cycle is my button, and gunshot is the movieclip that i want to load when the button is clicked:

cycle.onPress = function(){
            _root.attachMovie(gunshot, gunshot, _root.getNextHighestDepth());
            gunshot._x = 358;
            gunshot._y = 103;
            gunshot.play ();
            getURL("javascript:gunFire('http://**************.html')");
}

there are two things I still need to figure out:
1) I currently have the getURL directed to a javascript which creates a 2 second delay to allow for the gunshot movieclip to complete and then allows the page to redirect to the new URL associated with the cycle button.
I would like to use 'getURL("http*******", "_self", "GET") but I cannot figure out how to incorporate a 2 second delay in the actionscript 2 above.

2) I currently have X,Y cooridnates for the placement of the movieclip, gunshot. I would prefer for these coordinates to be generated by the location of the mouse-click. My best guess was to use the trace command, but it did not work:
gunshot._x = trace("X:"+cursor_mc._x);
gunshot._y = trace("Y:"+cursor_mc._y);

Any ideas on either of those two points?

Thanks!

0
 
rascalpantsCommented:

for the delay...

you can setup a function that gets run after a setInterval()...  something like the below...

I wasn't able to get it tested, but it should work for you...


for the mouse coordinates...  use this instead....

gunshot._x = _xmouse;
gunshot._y = _ymouse;


BTW...  trace(); is used to just show data in the output panel.

rp / ZA




function callGetUrl( clip:MovieClip )
{
    clearInterval( clip.intID );
    getURL("javascript:gunFire('http://**************.html')");
}
 
cycle.onPress = function(){
            _root.attachMovie(gunshot, gunshot, _root.getNextHighestDepth());
            gunshot._x = 358;
            gunshot._y = 103;
            gunshot.play ();
            cycle.intID = setInterval( callGetUrl, 2000, cycle );
}

Open in new window

0
 
shemp609Author Commented:
Rascal P-
Youre the man!
Thank you. That works like a charm. I was so close but sometimes you just have to see it!

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now