Frame action between MovieClips
Hello Everyone,
I have a little problem with actionscript/behaviors. What I
want to do is create a frame action or behavior that takes you from
one frame in a MovieClip to a label in the scene 1 timeline.
Any Ideas?
Thanks,
Todd
I tried that but I can only get it to work if the action is
in the same timeline. I'm trying to go from a frame in a
movieclip's timeline to a frame in the scene 1 timeline, separate
timelines.
Can I do this using frame action of gotoandplay?
Similar Messages
-
Cant duplicate action or movieclips for my scrollbar
hi
i have some script to scroll my content in movieclip
i use this tutorial :
there are two movieclip : content_mc & mask_mc
and this is my script :
var rect:Rectangle;
var scrollerMinY:Number = scrollbar_mc.scroller_mc.y;
var contentMaxY:Number = content_mc.y;
var padding:Number = 40;
scrollbar_mc.scroller_mc.buttonMode = true;
scrollbar_mc.scroller_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
function dragIt(e:MouseEvent):void {
rect = new Rectangle(4, 3, 0, 309);
scrollbar_mc.scroller_mc.startDrag(false, rect);
stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
scrollbar_mc.scroller_mc.addEventListener(Event.ENTER_FRAME, scrollIt);
function dropIt(e:MouseEvent):void {
scrollbar_mc.scroller_mc.stopDrag();
scrollbar_mc.scroller_mc.removeEventListener(Event.ENTER_FRAME, scrollIt);
function scrollIt(e:Event):void {
var scrollerRange:Number = rect.height;
var contentRange:Number = content_mc.height - mask_mc.height + padding;
var percentage:Number = (scrollbar_mc.scroller_mc.y - scrollerMinY) / scrollerRange;
var targetY:Number = contentMaxY - percentage * contentRange;
content_mc.y = targetY;
everything works well ...
but now i want to use this script in another frame with another Movieclips ( content )
i set another instance name for my content movie clip for example : newcontent_mc
copy all actions , scrollbar movieclip and mask_mc in the same
and i replace content_mc with newcontent_mc in my script !!
i get no error in compiler when test it but the content not scrollable any more !!
i try to change instance name of mask_mc and scrollbar_mc and scroller_mc and change it in script too !!
but not success at all
in output i get this error when test the movie :
TypeError: Error #1010: A term is undefined and has no properties.
at RAHAPharmOrgin_fla::ampouleproducts_49/frame1()
whats my mistake ?? what can i must do to use scrollbar for my various movieclip contents in my project ??change your code to:
// put this on the first keyframe that contains content_mc
var target_mc:MovieClip=content_mc;
put this on the first keyframe that contains newcontent_mc
target_mc=newcontent_mc;
// put this on the first keyframe that contains your scroller
var rect:Rectangle;
var scrollerMinY:Number = scrollbar_mc.scroller_mc.y;
var contentMaxY:Number = content_mc.y;
var padding:Number = 40;
scrollbar_mc.scroller_mc.buttonMode = true;
scrollbar_mc.scroller_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
function dragIt(e:MouseEvent):void {
rect = new Rectangle(4, 3, 0, 309);
scrollbar_mc.scroller_mc.startDrag(false, rect);
stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);
scrollbar_mc.scroller_mc.addEventListener(Event.ENTER_FRAME, scrollIt);
function dropIt(e:MouseEvent):void {
scrollbar_mc.scroller_mc.stopDrag();
scrollbar_mc.scroller_mc.removeEventListener(Event.ENTER_FRAME, scrollIt);
function scrollIt(e:Event):void {
var scrollerRange:Number = rect.height;
var contentRange:Number = content_mc.height - mask_mc.height + padding;
var percentage:Number = (scrollbar_mc.scroller_mc.y - scrollerMinY) / scrollerRange;
var targetY:Number = contentMaxY - percentage * contentRange;
target_mc.y = targetY; -
How do you run loop functions on specific frames of nested Movieclips?
I'm still pretty new to AS3 and I've run into a problem that I never had with AS2. I have a project where the 1st frame of the main timeline is the loading screen and the second frame has buttons and a title bar that I want to be on every "page" of my project. There are 7 buttons that take the user between 7 different "pages", which consist of 7 frames of a movieclip I have filling the content area on frame 2 of my main timeline. I'll call this movieclip "pages_mc".
The problem is that frame 6 of the pages_mc movieclip has the following code:
var moving = 0;
var xmoved;
var xbegin = pano_cont.pano_image.x;
parts_mc.addEventListener(Event.ENTER_FRAME, moveImage); // constantly moves the image 1 pixel left or right depending on the button pressed
btn_left.addEventListener(MouseEvent.MOUSE_DOWN, moveLeft); //changes the variable "moving" to 2 on mouse down
btn_right.addEventListener(MouseEvent.MOUSE_DOWN, moveRight); //changes the variable "moving" to 1 on mouse down
btn_left.addEventListener(MouseEvent.MOUSE_UP, stopMoveLeft); //changes the variable "moving" to 0 on mouse up
btn_right.addEventListener(MouseEvent.MOUSE_UP, stopMoveRight); //changes the variable "moving" to 0 on mouse up
function moveImage(e.Event):void{
xmoved = xbegin - pano_cont.pano_image.x;
if(moving == 1)
pano_cont.pano_image.x -= 1;
if(moving == 2)
pano_cont.pano_image.x += 1;
if(xmoved < -(pano_cont.pano_image.width/2)+180)
pano_cont.pano_image.x = -2538;
if(xmoved > (pano_cont.pano_image.width/2)- 180)
pano_cont.pano_image.x = -2178;
function moveRight (e:MouseEvent):void
btn_right.gotoAndStop("down");
moving = 1;
function moveLeft (e:MouseEvent):void
btn_left.gotoAndStop("down");
moving = 2;
function stopMoveLeft (e:MouseEvent):void
moving = 0;
btn_left.gotoAndStop("active");
function stopMoveRight (e:MouseEvent):void
moving = 0;
btn_right.gotoAndStop("active");
This is all just some code to allow users to move a panaromic image around on the screen. But when I navigate to a different page from of my pages_mc movieclip I get the following output message:
TypeError: Error #1099: Cannot access a property or method of a null object reference.
at SampleProject_fla::Content_MC_1/moveImage()
I'm thinking this is happening because the "parts_mc" movieclip I referenced for the ENTER_FRAME event listener no longer exists (unless you go back to frame 6 of pages_mc). I'm not sure how to remove this event listener when the user moves to another frame of pages_mc.
Any help would be greatly appreciated.kglad wrote:
what's parts_mc.parts_mc???
Not sure where you see that. I see pages_mc.parts_mc which is just because the parts_mc movieclip is nested on the 6th frame of the pages_mc movieclip.
At any rate, I was able to get it working by moving all the code onto frame 2 of the main timline and declaring all of my vairables on frame 1 of the main timeline. I then added an ENTER_FRAME event listener onto one of my movieclip buttons (main_btn) on the main timeline and had it check what frame the pages_mc movieclip was on. If it was frame 6, I then executed the moveImage function and had it remove the event listener from the main_btn movieclip if the frame changed away from frame 6.
Seems to be working so far.
Here's the code:
Frame 1
/* Declaring variables. */
var pagenumber:Number;
var moving:Number = 0;
var firstTime:Number = 0;
var xmoved:Number;
var xbegin:Number;
Frame 2
pages_mc.addEventListener(Event.ENTER_FRAME, pageNum);
pages_mc.addEventListener(Event.ENTER_FRAME, BtnSelParts);
/* Keeps track of current page. */
function pageNum(e:Event):void
pagenumber = pages_mc.currentFrame;
title_bar.gotoAndStop(pages_mc.currentFrame);
function BtnSelParts(e:Event):void
if(pagenumber == 6)
btn_parts.gotoAndStop("current");
if(firstTime == 0)
btn_main.addEventListener(Event.ENTER_FRAME, moveImage); //moves the panorama image left or right
else
if(btn_parts.currentFrame == 32)
btn_parts.gotoAndStop(1);
function moveImage(e:Event):void
if(pagenumber==6)
if(firstTime == 0)
pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_OVER, overLeft); //animates left arrow button on rollover
pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_OVER, overRight); //animates right arrow button on rollover
pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_DOWN, moveLeft); //changes the variable "moving" to 2 on mouse down
pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_DOWN, moveRight); //changes the variable "moving" to 1 on mouse down
pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_UP, stopMoveLeft); //changes the variable "moving" to 0 on mouse up
pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_UP, stopMoveRight); //changes the variable "moving" to 0 on mouse up
pages_mc.btn_left.addEventListener(MouseEvent.MOUSE_OUT, rollOutLeft); //animates left arrow button on rollout
pages_mc.btn_right.addEventListener(MouseEvent.MOUSE_OUT, rollOutRight); //animates right arrow button on rollout
xbegin = pages_mc.parts_mc.pano_image.x;
firstTime = 1;
xmoved = xbegin - pages_mc.parts_mc.pano_image.x;
if(moving == 1)
pages_mc.parts_mc.pano_image.x -= 1;
if(moving == 2)
pages_mc.parts_mc.pano_image.x += 1;
if(xmoved < -(pages_mc.parts_mc.pano_image.width/2)+180)
pages_mc.parts_mc.pano_image.x = -2538;
if(xmoved > (pages_mc.parts_mc.pano_image.width/2)- 180)
pages_mc.parts_mc.pano_image.x = -2178;
if(pages_mc.parts_mc.pano_image.pano1.currentFrame == 1)
pages_mc.btn_sel.gotoAndStop(1);
if(pages_mc.parts_mc.pano_image.pano1.currentFrame == 2)
pages_mc.btn_sel.gotoAndStop(2);
if(pages_mc.parts_mc.pano_image.pano1.currentFrame == 3)
pages_mc.btn_sel.gotoAndStop(3);
else
btn_main.removeEventListener(Event.ENTER_FRAME, moveImage);
firstTime = 0;
} // controlls the panaromas
Let me know if you see any problems with this.
Thanks again. -
How do I create a frame action to launch an HTML document?
I have searched the forums repeatedly and can find no reference to this what so ever.
It was incredibly simple to do this w/ AS2, but I cannot figure out how to do it in AS3.
PLEASE HELP!
I need to have a frame action launch a .html file (call it "time-crunched.html"), and then the flash window should close. That's it. It seems like it should be easy (and it WAS easy in previous versions).
I have already tried using the gotourl feature from AS2, but I keep being told that the functionality has been disabled in the current version.
I am on Windows XP, but I need the Windows projector file to work on XP, Vista, and 7, and the Mac projector file to work on 10.0 forward.
Thanks,
LauraThank you for your prompt reply!
Sorry - meant "GetURL." =)
In any case, your solution did not work.
I copied it exactly as you suggested - do I need any additional commands in there?
FSCommand or anything? Or just the single line?
When it "does not work," it simply does not launch anything. The flash .EXE file opens, but nothing else happens. I've tried switching my the defaults on HTML files so they open w/ Firefox, but that did not help either.
Any ideas??
Laura -
I have buttons in a movie clip which are placed on the main
time line. I also have movieclips placed on single frames (25, 30,
35, etc) on the main time. When a button is released I want two
things to happen -
- the playhead to go to a frame on the main time line where
the movie clip is placed - which I can do with this code -
on (release) {
this._parent.gotoAndStop("25");
- then I'd like it to target a certain frame inside the
movieClip with a var number (var number already generated). This is
where I'm stuck. What is the path I use to target the frame inside
the movie clip???
Thanks for any help,
DaveIt's still not working....
I named my movieClip (classifieds_mc) and my Var (collapse -
which is a Number). I attached this code to the button (note:
button inside movieClip than placed on main time line) -
on (release) {
//Movieclip GotoAndPlay Behavior
this._parent.classifieds_mc.gotoAndStop("collapse");
//End Behavior
Nothing hapens when the button is releases. If I just target
the frame on the main time line with this code it works
on (release) {
this._parent.gotoAndStop("25");
But I'd like to also target a a frame inside the movieClip
with a var Number.
Any help on what I'm doing wrong???..??
Thanks,
Dave -
Goto next frame in a movieclip from main timeline button
So what I have is a button (named Next) on the main timeline. I have a movie clip on that frame (on the main timeline) and the movie clip has 3 frames that I want to be able to cycle through using the "Next" button that is on the main timeline. How can I go about doing this?
Thank you,Thanks kglad! Works like a charm. :-)
I had already named the instance of the movieclip and button so I just needed to change the code to match and it's working great.
One other issue I've come up with now is that when it goes to the 3rd frame of the movieclip and I click next, it doesn't do anything. shouldn't it go back to frame 1 of the movieclip? -
How to get addm report if there were shutdown actions between 2 snapshots?
addmrpt.sql can get the addm report.
but, this needs a requirement:
if there were shutdown actions between 2 snapshots.
The point is:
the database has a shutdown and startup actions between 2 snapshots.
What can I do to get the addm report?In terms of awrrpt?
can I get awrrpt if there were shutdown actions between 2 snapshots? -
GetURL:javascript blocked when called from a frame action in flash?
Hi,
I'm wrapping a load of flash/html eLearning content into air
packages - or at least I was!
The content is really old - flash 6 - and part of how it
works is once it has loaded, it calls a javascript function, via a
frame action. Each eLearning module relies on this call getting
made...
Sadly, this javascript call is never received - and having
done a test it is purely down to the call being from a frame rather
than a button (or other user interaction).
eg. a movie with 10 frames. frame 10 has this action:
(remember this is flash 6!)
stop();
getURL("javascript:foo());
foo is never called.
But put a button in with:
on(release){
getURL("javascript:foo());
that works fine. Same call, but via a button.
So really the question is - with air (or even is it something
in new flash security?) - is there some reason why a frame action
cannot call javascript? And if so - is there a parameter that can
be set (like allowScriptAccess type thing - although tried that!)
that will allow it again? Basically with over 1000 different flash
movies, I'm not really in a position to re-code (eg.
ExternalInterface does work! But can't recode 1000 movies to use
that!).
I've searched and can't see anything saying specifically a
frame action call to javascript will be ignored, but clearly it
is...
Any idea, anyone?
Thanks.You are calling the script while the mouse button is still
down-- a
hijacking truck.
While it still works in older/unpatched IE, Microsoft has
disabled
resizeBy/To and moveBy/To while the mouse button is down.
Obviously, when
you have to click the Alert dialog's OK button, the mouse is
no longer down.
You'll need to take a different approach. -
Whatever happened to call frame action
Flash contintues to get worse with every improvement to the
point where it's almost as useless as the online manual whiich
takes half an hour to open and finds trillions of results for every
keyword and none for what I want to know. I spent ages learning
Flash a couple of versions ago and its so different its like a new
program. I really hate it.
So what the bleep happened to the bleeping "call frame"
action. And what do I do now, except throw out this bleeping
program.dkd;alkje;oihp[oihjl,
> Flash contintues to get worse with every
> improvement to the point where it's almost
> as useless as ...
So use an older version, right? Or go outside and play
badminton or
something. ;) Take a jog, maybe; clear your head.
> I spent ages learning Flash a couple of versions
> ago and its so different its like a new program.
> I really hate it.
Honestly, I'm sorry to hear you're so upset by it. In truth,
the
program has become a lot more powerful. It does so much
*more* than it ever
used to, which means it allows *me* to do so much more than I
ever used to.
I can't think of another program that does cartoons, web
stuff, CD-ROM
stuff, titling and overlays for video, rich Internet
applications, games,
and the list goes on. Thanks to Flash, I was able to quit my
day job,
believe it or not, and make even more money working from
home.
> So what the bleep happened to the bleeping "call
> frame" action. And what do I do now, except
> throw out this bleeping program.
Well, you mentioned the documentation that "takes half an
hour to open,"
but all I had to do was hit the F1 key. The Help files opened
in less than
a second. I searched the word "call" and found the "call
function" entry
right away. According to the documentation, this action was
deprecated in
favor of the function statement since Flash 5. You can still
use it, of
course, and the details are right there at your finger tips.
David
stiller (at) quip (dot) net
Dev essays:
http://www.quip.net/blog/
"Luck is the residue of good design." -
Transferring Photoshop actions between versions
I just switched from CS3 to CS6. Can I somehow transfer the actionas I wrote or purchased in CS3 to my CS6 version?
Loaded Actions ones saved and unsaved are stored in your user id Photoshop Preferences for each release of Photoshop. I have been able to transfer loaded action between release of Photoshop even before the migrate script was written. Warning on Microsoft and Apple OS these files are stored in hidden locations. before replacing you current preferences always backup first or rename the current file so you do not loose it in case the some incompatibility. Current loaded actions are stored in a preference file named "Actions Palette.psp". If you destroy Photoshop preferences its no big deal. You can delete Photoshop preferences folder and the next time you start Photoshop it will create a new default tree for your user. Action are not Photoshop release dependant. Actions should work from release to release. Photoshop CS4 introduces some bugs that can effect some action that add adjustment layers they may produce error messages, operate incorrectly or work correctly depending on Photoshop settings and how the setps were recorded. CS6 added additional bugs that effect the action recorder steps like save for web may record wrong. CS3 has fewer bugs then the releases that followed.
-
Change Stage Frame From Inside MovieClip?
How Do I Change Stage Frame From Inside MovieClip?
Heres my code so far:
hh.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
gotoAndStop(2);
i tried (root).gotoAndStop(2); but i got an error , #1061 ..
Thanks in Advance...
ASAP would be nice..well your a smart *** now arnt you Haha..
I missed 1 painful word in that line of code thanks heeps.. -
Stopping mouse out action between certain frames
Hi everyone,
I would like to stop mouse out action on an object between certain time frames. How can I achieve that?
let me tell you a little about my scene;
I'm creating a web page with pop-up pages. I have mouse in and out and click actions on buttons which lead to pop-up screens.
So when I click on buttons pages open, but if I move my mouse out of that button pop-up pages close.
I would like to keep them open even if i move my mouse out of that button.
Thanks in advance.Thanks, but I actually solved it by using symbols instead of trying to code everything on the timeline.
-
How can I pass a var value between MovieClips?
New week, new question.
I haven't been able to find the answer to this: I'm working with a var defined in the main timeline var score:int; , wich I use in 10 different movie clips using var score = MovieClip(this.root).score;
Everything works perfect on the first MovieClip, but when the next one plays score does not keep the value assigned in the previous MovieClip therefore the score is lost.
The clips are questions and they are place on the main time line in different frames and main time line actions layer which only contains this:
stop();
var score:int;
nextQuestion.addEventListener(MouseEvent.CLICK, newQuestion);
function newQuestion(evt:MouseEvent):void {
nextFrame();
covers each frame with every different MovieClip.
What I need to know is how to make that value pass to the next Movie Clip?Hi Ned,
I had defined the score var in the time line but to add the score from each question (MovieClips) I have to call it to the each MovieClip and I assume that whe I call the score var in the second MovieClip will keep the score from the first, but is not the case:
This is the time line actions layer:
stop();
var score:int;
nextQuestion.addEventListener(MouseEvent.CLICK, newQuestion);
function newQuestion(evt:MouseEvent):void {
nextFrame();
and this is the code from the first question (MovieClip)(all the questions will have the same code except for some specific things like the value that each answer adds to the score and stuff like that)
stop();
var score = MovieClip(this.root).score;
var answersArray:Array = new Array();
var strikeCount:int;
var sucessCount:int;
var messageBox:TextField = new TextField();
messageBox.text = "" + score;
addChild(messageBox);
messageBox.textColor = 0xFF0000;
messageBox.width = 200;
messageBox.height =100;
messageBox.x = 285.5;
messageBox.y = -32.9;
this.strikeOne.visible = false;
this.strikeTwo.visible = false;
this.strikeThree.visible = false;
this.flipQ1One.visible = false;
this.flipQ1Two.visible = false;
this.flipQ1Three.visible = false;
this.flipQ1Four.visible = false;
function answListener(evt_obj:Event){
if((strikeCount >=3) || (sucessCount ==4)) { nextFrame();
}else if (answersArray.indexOf(answ_input.text) < 0){
if(answ_input.text == "5"){
score = score + 61;
messageBox.text = ""+ score;
this.flipQ1One.visible = true, flipQ1One.play();
sucessCount = sucessCount +1;
answersArray.push(answ_input.text);
answ_input.text = "";
else if (answ_input.text == "3"){
score = score + 25;
messageBox.text = ""+ score;
this.flipQ1Two.visible = true, flipQ1Two.play();
sucessCount = sucessCount +1;
answersArray.push(answ_input.text);
answ_input.text = "";
else if (answ_input.text == "4"){
score = score + 8;
messageBox.text = ""+ score;
this.flipQ1Three.visible = true, flipQ1Three.play();
sucessCount = sucessCount +1;
answersArray.push(answ_input.text);
answ_input.text = "";
else if (answ_input.text == "2"){
score = score + 3;
messageBox.text = ""+ score;
this.flipQ1Four.visible = true, flipQ1Four.play();
sucessCount = sucessCount +1;
answersArray.push(answ_input.text);
answ_input.text = "";
else {answ_input.text = "";
strikeCount = strikeCount + 1;}
answ_input.addEventListener("enter", answListener);
function strikesListener (evt_obj:Event) {
if ((strikeCount == 1) && (answ_input.text != "5", "4" , "3" , "2")) {this.strikeOne.visible = true;
else if ((strikeCount == 2) && (answ_input.text != "5", "4" , "3" , "2")) {this.strikeTwo.visible = true;
else if ((strikeCount == 3) && (answ_input.text != "5", "4" , "3" , "2")) {this.strikeThree.visible = true;
else {}
answ_input.addEventListener("enter", strikesListener) -
Sharing Actions between GUI Components
Hi,
i have an MyPanels (JPanels) as tabs in JTabbedPane.
Each of MyPanels instances has own Actions (save, copy, paste, cut).
I want to put this actions in the toolbar of a JFrame.
The way i do it so far, is creating "dummy" Actions for a toolbar, and setting them each time the selected tab changes. I never use the "dummy" Actios, i just need them in toolbar, even when no tab selected ...
The first problem is i have to reset the actions for components each time as well (because the buttons configure from actions, don't use them. ..)
Is there any other solution for it?
I put all actions of MyPanel to an extra ActionMap, and get it to the parent frame.
I don't think it is the best solution ...
And i create actoins in Jframe, which i never use really ...
For now i have following solution in my JFrame class:
jTabbedPane.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
m_currentPane = getCurrentMyPane();
updateTabsActions();
private void updateTabsActions(){
if(m_currentPane!= null){
ActionMap actions = m_currentPane.getActions();
saveFile_action = actions.get(saveFile_action.getValue(Action.NAME));
jButton_Toolbar_SaveFile.setAction(saveFile_action);
jMenuItem_FileSave.setAction(saveFile_action);
copy_action = actions.get(copy_action.getValue(Action.NAME));
jButton_Toolbar_Copy.setAction(copy_action);
jMenuItem_EditCopy.setAction(copy_action);
else{
saveFile_action.setEnabled(false);
copy_action.setEnabled(false);
}Has anybody a good solution to general share actions beteween components?
Thx for any answers, ideas, codes
KatieWhy dont you try interfacing?
make each panel ot tabbed pannel implemet this interface
public interface MyActions{
public void save();
public void cut();
}Then when the save button is pressed, the action should be :
JButton save=new JButton("Save");
save.addActionListener(new ActionListener(ActionEvent e){
getCurrentOrSelectedPanel().getMyActions().save();//
// I dont remmeber how to swap between panels, but I think you got the idea!!
//you dont need to change the actions after that!!
//Do the same for every button. :
getCurrentOrSelectedPanel().getMyActions().cut();//
getCurrentOrSelectedPanel().getMyActions().paste();//This way the save Button for example, will have different save operations depending on the current displayed panel. -
Frame actions, basic navigation
Hi
I've recently started using CS4 and am having a problems
trying to put actions into a frame. i used MX years ago so i
thought i has a slight understanding of creating a simple website
but am having a few lil problems.
I have a scene which has an intro animation, and an outro
animation. What id like to be able to do is to have buttons that
when pressed will play the outro animation then automatically goto
a scene.
is it possible to make a button play the outro animation then
goto scene 2, and have another button on the same stage that will
play the outro animation then goto scene 3?
im sure this is real noob teritory but maybe im not seeing
the wood for the trees?
many thanks in advanceCyman666,
> i got my idea of having an action on a frame at the end
of the
> reversed animation to work!
Great! Yes, it's important to realize that your code and be
associated
with any keyframe on any timeline, and depending on your
needs, multiple
keyframes is often a useful way to gol.
> but would still like to know if theres a better way to
do it?
>
> i guess it would be some type of variable?
Yes, you could certainly declare a variable to hold whatever
information
you like, such as where the playhead just came from.
> " if printwork button is pressed then goto and play
frame 20
> then goto scene 2"
> " if illustration button pressed then goto and play
frame 20
> then goto scene 3"
You've got the right idea. Here's a quick test that should
provide you
with a useful proof of concept. Create a new ActionScript 3.0
FLA file and
enter the following code into frame 1:
var myVar:String = "Scene 1 timeline";
this.gotoAndPlay(1, "Scene 3");
You don't have a Scene 3 yet, but you're about to create
one. So far,
this code simply declares a variable named myVar, types it as
a String
(because that's what it's going to be), and then set it to
the String value
"Scene 1 timeline," which is where you are. After that, the
MovieClip.gotoAndPlay() method is invoked on the main
timeline (which is, in
fact, a movie clip), instructing this timeline to go to Scene
3 and play
frame 1 of that scene.
Pretty straightforward, right? Now open your Scene panel
(Window >
Other Panels > Scene) and create two new scenes, which
will by default be
named Scene 2 and Scene 3. Select Scene 3 and enter the
following code in
frame 1:
trace("Just came from: " + myVar);
myVar = "Scene 3 timeline";
this.gotoAndPlay(1, "Scene 2");
When you eventually test this SWF, it's going to create the
myVar
variable, then jump to Scene 3. When the playhead hits frame
1 of Scene 3,
the trace() function will output the message "Just came from:
Scene 1
timeline," because the value of myVar at this point is "Scene
1 timeline".
Does that make sense? You'll see this message in the Output
panel, which
will open for you automatically if it isn't already open.
After the trace()
function, the value of myVar is set to "Scene 3 timeline,"
and the playhead
is sent to Scene 2.
Select Scene 2 from the Scene panel and enter the following
final code
in frame 1:
trace("Just came from: " + myVar);
myVar = "Scene 2 timeline";
trace("Stopped at: " + myVar);
this.stop();
Study that code a bit, but it should probably make sense by
now. Test
your SWF, and you should see the following messages in your
Output panel:
Just came from: Scene 1 timeline
Just came from: Scene 3 timeline
Stopped at: Scene 2 timeline
So, in AS3, variables carry over from scene to scene. In
your case, you
may want to declare a variable in frame 1 of Scene 1 that
describes the
timeline most recently visited. In your button code, you can
use an if()
statement to check if the value of that variable is one
thing, another, or
something else, and perform various actions based on the
variable's value.
Use the first frame of each new scene to update that
variable's value as
appropriate.
Note: If all of this setup code occurs in frame 1 of Scene
1, make sure
not to have your other scenes send the playhead back to Scene
1's frame 1
... otherwise you might accidentally "reset" whatever you
code into that
first "entry" frame. (You can always have the other scenes
return you to
frame 2 (or frame 100, or whatever) of Scene 1.
> ps your site is very helpful David!
Thanks! I'm always glad to hear that. :) Just make sure,
whatever
blog entry you're reading pertains to the version of
ActionScript you have
in mind.
David Stiller
Co-author, ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design."
Maybe you are looking for
-
I updated to iOS7 and my deleted photos came back. How do I make sure this doesn't happen again? I want to get rid of the ones I already got rid of, but if they just keep coming back that will be a waste of time. Can anyone help? When I sync with
-
ITunes only plays one song at a time ... help please
All of my songs are checked, but iTunes only plays one song at a time. I can't figure out why. Any suggestions? It just started doing this.
-
I have only had this mac for about 4 months and I bought it new, I have never used i cal and now that I would like to I can not get it to open. Can anyone help me on this one?
-
Retired server still showing in Storage Resources
We removed a old server from Edir and it continues to show in storage resources with "Unable to read attribute value; Result = 15".. any idea on how to get it out of the list ???.. I did do a storage rebuild and its still there
-
Youtube player missing from apple TV 2 ios 5.1.1
i have just updated my apple tv 2g to ios 5.1.1 and jailbroke it using season pass and installed xbmc. My problem is that youtube and all other apps which were there are not coming please help on how to get it back.