Solved

play movie event at click location cs3 flash

Posted on 2009-05-13
4
466 Views
Last Modified: 2013-11-11
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
Comment
Question by:shemp609
  • 2
  • 2
4 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24379675

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
 

Author Comment

by:shemp609
ID: 24401095
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
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 24401381

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
 

Author Comment

by:shemp609
ID: 24401515
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now