AS3 MC to timeline?

Hi!
Having problems with a game I'm creating in as3.
After leaving the main game screen(the corridor in this case) the user comes to facing a door.
Here, the user can click the door and enter a room.
But, the problem is, the user in this case can't click the door again after leaving the main gamescreen.
I don't know why, searched for problems and errors in the code, but found none.
Here's the code for the main gamescreen:
[AS]stop();
import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.MouseEvent;
var musDoor1:Boolean;
var musDoor2:Boolean;
var musDoor3:Boolean;
var musDoor4:Boolean;
var musDoor5:Boolean;
var musDoor6:Boolean;
var musDoor7:Boolean;
var musDoor8:Boolean;
var musDoor9:Boolean;
var doors:Array = [door_mc,
                   door_mc1,
                   door_mc2,
                   door_mc3,
                   door_mc4,
                   door_mc5,
                   door_mc6,
                   door_mc7,
                   door_mc8];
this.addMouseEventListenerToEachDoor();
super.stage.addEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
function addMouseEventListenerToEachDoor():void
    var i:int = doors.length;
    while (i--)
        doors[i].addEventListener(MouseEvent.MOUSE_DOWN, this.mouseDownHandler);
function enterFrameHandler(event:Event):void
    if (musDoor1) { door_mc && door_mc.callMe();
    door_mc && door_mc.addEventListener("timeLineFinished", onDoorPlayed);}
    else if (musDoor2) { door_mc1.callMe();
    door_mc1.addEventListener("timeLineFinished", onDoorPlayed1);}
    else if (musDoor3) { door_mc2.callMe();
    door_mc2.addEventListener("timeLineFinished", onDoorPlayed2);}
    else if (musDoor4) { door_mc3.callMe();
    door_mc3.addEventListener("timeLineFinished", onDoorPlayed3) }   
    else if (musDoor5) { door_mc4.callMe();
    door_mc4.addEventListener("timeLineFinished", onDoorPlayed4)  }
    else if (musDoor6) { door_mc5.callMe();
    door_mc5.addEventListener("timeLineFinished", onDoorPlayed5) }
    else if (musDoor7) { door_mc6.callMe();
    door_mc6.addEventListener("timeLineFinished", onDoorPlayed6) }   
    else if (musDoor8) { door_mc7.callMe();
    door_mc7.addEventListener("timeLineFinished", onDoorPlayed7) }
    else if (musDoor9) { door_mc8.callMe();
    door_mc8.addEventListener("timeLineFinished", onDoorPlayed8) }
    else stop();
function mouseDownHandler(event:MouseEvent):void
    switch(event.target)
        case door_mc  : musDoor1 = true; break;
        case door_mc1 : musDoor2 = true; break;
        case door_mc2 : musDoor3 = true; break;
        case door_mc3 : musDoor4 = true; break;
        case door_mc4 : musDoor5 = true; break;
        case door_mc5 : musDoor6 = true; break;
        case door_mc6 : musDoor7 = true; break;
        case door_mc7 : musDoor8 = true; break;
        case door_mc8 : musDoor9 = true; break;
        default: break;
function onDoorPlayed(e:Event):void
     gotoAndPlay(3);
function onDoorPlayed1(e:Event):void
    gotoAndPlay(4);
function onDoorPlayed2(e:Event):void
    gotoAndPlay(5);
function onDoorPlayed3(e:Event):void
    gotoAndPlay(6);
function onDoorPlayed4(e:Event):void
    gotoAndPlay(8);
function onDoorPlayed5(e:Event):void
    gotoAndPlay(9);
function onDoorPlayed6(e:Event):void
    gotoAndPlay(10);
function onDoorPlayed7(e:Event):void
    gotoAndPlay(11);
function onDoorPlayed8(e:Event):void
    gotoAndPlay(12);
}[/AS]
The code for the movieclip which is the first door is this:
[AS]
stop();
function callMe():void
    play();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void
    if (currentFrame == totalFrames)
        dispatchEvent(new Event("timeLineFinished"));
}[/AS]
And the code for "facing" the door after clicking it in the corridor:
[AS]
stop();
import flash.display.MovieClip;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.MouseEvent;
var dörr:Boolean;
var papper:Boolean;
var döpp:Array = [door_btn,
                  paper_btn];
this.addEvents();
super.stage.addEventListener(Event.ENTER_FRAME, FRAME);
function addEvents():void
    var i2:int = döpp.length;
    while(i2--)
        döpp[i2].addEventListener(MouseEvent.MOUSE_DOWN, clickhandle);
function FRAME(event:Event):void
    if(door_btn) { door_btn && door_btn.callMe();
    door_btn && door_btn.addEventListener("timeLineFinished", onDoorPlay)}
    else if(paper_btn) { paper_btn && paper_btn.callBtn();
    paper_btn && paper_btn.addEventListener("timeLineFinished", onBtnPlay)}
    else stop();
function clickhandle(event:MouseEvent):void
    switch(event.target)
        case door_btn : dörr = true; break;
        case paper_btn : papper = true; break;
        default: break;
function onDoorPlay(event:Event):void
    gotoAndPlay(2);
function onBtnPlay(event:Event):void
    stop();
[/AS]
And the codes for the door & paper in that screen is approx. the same as for the doors.
Any ideas?

EDIT: changed the "facing the door" frame to if(dörr) and if(papper), but it still doesn't work.
EDIT2: It works clicking the door.
But now the timeline won't stop at where the room actually is.
It just keeps repeating and repeating..
EDIT3: Can click the door, but when the timeline reaches the frame where the input textfield is to be created, it isn't.
The framescript doesn't run.. :S

Similar Messages

  • How do I create a play button for movie clip using AS3

    Hello.
    Bit new to this and have been searching the adobe forums and google. I am trying to create a button that will play an imported MovieClip.
    I have a movie clip that I've imported into it's own layer (Layer1) Frame 1.  I've given the MovieClip an instance name of foundationMovie.
    I've created a button and have that on its own layer(Layer2) above layer1, it is also in Frame 1.
    I've added a
    stop (); action to layer2
    The video is not set to autoplay.
    I want the video to start playing when the viewer clicks the button.  I know I've got to put some kind of event listener using AS3 in my timeline somewhere.
    I've found some code and I've been trying to work with it.  I'm sure I've mutilated it beyond usability but this is what I've got.
    stop ();
    player.addEventListener(MouseEvent.CLICK,play);
    function play(event:MouseEvent)
    gotoAndPlay("foundationMovie");
    If someone could point me the right direction or help me with my code I would really appreciate it.  Thanks.

    First, you need to clear up what you are working with... a movieclip and a video are usually entirely different things.
    Next, your code may get you started on your way with some changes.   You shouldn't use "play" as a function name due to there already being a play() method/function in Flash.
    If the movieclip is a movieclip and has an instance name of "foundationMovie", and your button has an instance name of "player" then the following adjusted code would normally work...
    stop ();
    player.addEventListener(MouseEvent.CLICK,playMovie);
    function playMovie(event:MouseEvent)
         foundationMovie.play();

  • Open a PDF file embedded in my app ?

    Hi,
    In the resources of my application, I can easily embed a PDF file just like I would embed a large mp3 file , video or photo's
    But.... can I somehow call some code in as3 which then opens that PDF file on the ipad ? So for example I have a book (in PDF) containing +- 20 pages and when I click on a button of my air app, I want to have the ipad open the pdf file and show it onscreen.
    Possible ???
    Kind regards,
    Bart

    Sir,
    import flash.media.StageWebView;
        public class Main extends MovieClip
            private var swv:StageWebView = new StageWebView();
            public function Main()
                swv.stage = stage;
                swv.viewPort = new Rectangle(0, 0, 1024, 768);
                swv.loadURL('http://www.google.com');
    This seems to load up and display google.com website fullscreen on my ipad (have to test tonight),
    But you talk about getting the nativepath of my file. Since my file will be included as a resource inside my IPA, I cannot access it over HTTP://
    If my file is called "mybook.pdf" and is included in the root folder of my IPA, just besides the Default.png file, then could you please tell me how I can get that nativepath ?
    Kind regards,
    Bart
    PS And Do I have to create this using an external class or can I just as well include the lines below in a flash as3 on the timeline ?
    import flash.media.StageWebView;
    var swv:StageWebView = new StageWebView();
    swv.stage = stage;
    swv.viewPort = new Rectangle(0, 0, 1024, 768);
    swv.loadURL('http://www.google.com');

  • How to stop and resume the animations of nested movieclips

    Hi
    I have many nested movieclips  in different positions of the main timeline.
    I have 2 buttons, play_btn and pause_btn.
    I'd like when the user click pause_btn, the animations on the main timeline and in nested movieclips stop.
    Whe he click play_btn the animations resume in both the main timeline and nested movieclips.
    I have created array of nested movieclips on the main timeline.
    var arr:Array = new Array(mc1, mc2, mc3, mc4, mc5);
    play_btn.addEventListener(MouseEvent.CLICK, on_play_btn);
    pause_btn.addEventListener(MouseEvent.CLICK, on_pause_btn);
    function on_play_btn(e:MouseEvent):void
         gotoAndPlay(currentFrame);
         for(var i:Number = 0; i < arr.length; i++)
             if(arr[i] != null)
                 arr[i].play();
    function on_pause_btn(e:MouseEvent):void
         gotoAndStop(currentFrame);
         for(var k:Number = 0; k < arr.length; k++)
             if(arr[k] != null)
                 arr[k].stop();
    but it only stops the animations on the main timeline and dosen't stop the animations in the nested movieclips.
    Help me Please.

    I'm having the same issue.I have a main timeline, which has nested movieclips with there own timelines and motion tweens. Using the new motion tween, and not the classic tween, which may or may not be the problem.
    Was having a similar issue with stopping the timeline, the main timeline would stop, but the nested movieclips would keep going. Found this blog post that helped.
    http://blog.nobien.net/2009/02/05/as3-stopping-all-timeline-animations/
    Used the code below to stop everything by passing the stage as the displayObject. Worked great, but now i'm having the reverse issue. When I resume play, the nested movieclip timeline stays exactly where I stopped it, and the main timeline resumes play. If there are a 100 frames in the nested movieclip, once it reaches the 101st frame, the main timeline kicks in again.
    function stopAllChildMovieClips(displayObject:DisplayObjectContainer):void{
            var numChildren:int = displayObject.numChildren;
            for (var i:int = 0; i < numChildren; i++) {
                var child:DisplayObject = displayObject.getChildAt(i);
                if (child is DisplayObjectContainer) {
                    if (child is MovieClip) {
                        MovieClip(child).stop();
                        stopAllChildMovieClips(DisplayObjectContainer(child));

  • Getting the server Host name in Action Script?

    Good Morning --
    Is it possible in a flash movie (CS3/AS 3.0) to get the host
    name of the
    server running the flash movie?
    For example, if the URL is
    http://www.domain.com/movie.swf,
    I would like to
    be able to read a variable / function and have the result be
    "domain.com"
    Thanks
    Rich

    Excellent! Thank you. I will give this a shot.
    Rich
    "David Stiller" <[email protected]> wrote in
    message
    news:ff57ge$hj2$[email protected]..
    > Rich,
    >
    >> Is it possible in a flash movie (CS3/AS 3.0) to get
    the host name
    >> of the server running the flash movie?
    >
    > In AS2, it was a simple matter of checking
    MovieClip._url against the
    > root, since the main timeline is, after all, a movie
    clip ...
    >
    > trace(_root._url);
    >
    > ... then manipulating the string -- say, with
    String.substr() -- to format
    > it how you need.
    >
    > In AS3, it's a simple matter of checking the LoaderInfo
    instance
    > associated with the root. In AS3, the main timeline is
    an instance or
    > subclass of DisplayObject (such as Sprite or MovieClip),
    and
    > DisplayObject's have a loaderInfo property that refers
    to the necessary
    > associated LoaderInfo instance, which has a loaderURL
    property that points
    > to what you're after:
    >
    > trace(root.loaderInfo.loaderURL);
    >
    > If you pop a quick dynamic text field in the main
    timeline and give it
    > the instance name output, you could put this line of
    code in a script
    > layer:
    >
    > output.text = root.loaderInfo.loaderURL;
    >
    > ... and you'd see the info you're after. Again, use
    String methods to
    > chop off whatever part of the string you don't need.
    >
    >
    > David Stiller
    > Co-author, Foundation Flash CS3 for Designers
    >
    http://tinyurl.com/2k29mj
    > "Luck is the residue of good design."
    >

  • Replay button

    hello,
    i've got a pretty simple CS3 animation. Just about at the end
    of the timeline a replay button appears. However, so far I can't
    get it to work.
    In the replay button's timeline, I have defined keyframes for
    up, over and down states. (the button is changing images properly
    when I hover the mouse over it, and press down.) For the hit state,
    I've created a keyframe. I've also tried to insert some Action
    Script there. The window for the Action Script says "Current
    selection cannot have actions applied to it." So, my first question
    is: Does CS3 allow for Action Script to appear in the timeline of a
    button? I keep reading how people are applying AS3 in button
    timelines, but I can't put my AS3 in the "hit" frame's keyframe.
    So, i've tried to get the button to work using the main
    timeline. I've given the button an instance name: btnReplay. In the
    first frame of the timeline, I've got AS that says:
    function replayClick(event:MouseEvent):void
    trace('inside onClick');
    gotoAndPlay(1); // plays the current timeline from 1
    } // end of onClick
    btnReplay.addEventListener(MouseEvent.CLICK, replayClick);
    Unfortunately, i get a compiler error with the first line.
    (I've changed my AS version to 1-2, it still gives me the error.
    So, I'm currently running AS3.)
    The compiler error says '{' expected. I've compared this
    first line (i.e., "function...") with other examples that I've
    found, and I don't see what the source of the compiler error is.
    does anyone have any advice? Thanks.

    Ned,
    thanks for looking at my FLA file. I sent it to your email.
    However, here's some comments:
    1. when I run it, I get an error on frame 103, line 1. It
    says '{' expected with this statement:
    function replayClick(event:MouseEvent):void
    2. frame 109 has some AS3 that doesn't work. Here's the code:
    var request="
    http://www.Adobe.com"
    try {
    flash.net.navigateToURL(request, "_self");
    catch (e:Error) {
    // handle error here
    // trace('e:Error: ' + e:Error);
    I'm trying to give the user about 5 seconds to hit the
    "replay" button. If the person doesn't do this, then I want the
    flash to force the calling page to load a new page. (So that the
    calling page functions as a splash page.)
    3. the replay button doesn't work.
    Thanks again for looking at my FLA. I appreciate it.

  • Launching an external swf?

    I am using Flash professional CS5. I would like to know how to script a button in my flash AS3 site's timeline to launch an external  swf file into a browser window.

    THere are a variety of ways to design portfolio/gallery functionalities.  Your approach of opening a separate browser is probably the least technically challenging as far as coding goes.  The alternative would be to have the swf's load into the same file that you are using as a menu for them, either as a separate section or as a section of the page with the thumbnails.
    Whichever way you go, you will need to upload all of the files that end up needing to be loaded.

  • Buttons with nested movies clips...

    Hi guys
    I'm a flash newb. Have just read some tutorials on creating
    flash buttons that contain nested movie clips for the different
    states. So I went and made 5 of them for my site, all seems great
    the rollover effects are just as planned, and I thought I could add
    URL link to them in Dreamweaver but thats not working out. Been
    googling my *** off to add URL via actionscript (of which I
    understand VERY little) , found some code (add the following to key
    frame :on(release) {
    getURL('
    http://www.generic.com',
    '_parent');
    Major problem is, when I try to add AS to the frame/button,
    I'm getting told I 'current selection cannot have actions applied
    to it' If I persist and add the script anyway, funnily enough it
    doesn't work.
    I did an experimental button, consisting of diff coloured
    boxes, and AS will apply to that no problem.
    I'm tearing my hair out, as I already posted the flash links
    on my site and have had to add a note for visitors to use static
    links in the interim.
    I would love to post the .fla file but I don't see an option
    anywhere here to do so.
    If some wise soul can help my dumb *** out of this bind it
    would be greatly appreciated.

    You were using AS2 code, which will not work in AS3. That
    particular code is placed on an object, which AS3 does not allow
    for, which is why it wouldn't let you... all code in AS3 goes into
    timeline frames.
    For mouse interctive objects (buttons, movieclips, etc) you
    assign event listeners to the object. Let's say your button has an
    instance name of "btn", here's a variety of the possible event
    listeners avaiable, and I've assigned them to the button....
    btn.addEventListener(MouseEvent.CLICK, clickHandler);
    btn.addEventListener(MouseEvent.DOUBLE_CLICK,
    doubleClickHandler);
    btn.addEventListener(MouseEvent.MOUSE_DOWN,
    mouseDownHandler);
    btn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
    btn.addEventListener(MouseEvent.MOUSE_OVER,
    mouseOverHandler);
    btn.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    btn.addEventListener(MouseEvent.MOUSE_WHEEL,
    mouseWheelHandler);
    All of those "...Handler" things at the end are the names of
    functions you create to take action when the listener hears
    something it's assigned for... you can name them anything you want,
    and here's and example of how the function might look for the CLICK
    event...
    function clickHandler(event:MouseEvent):void {
    trace("clickHandler");
    Again, you can name the function anything you want, and the
    code within the function can be whatever you need done when the
    button is clicked... just be sure to include the argument
    "event:MouseEvent" because the listeners throws an argument to the
    function and the function needs to expect it. The "event" part of
    that is a variable name, so you can name it whatever you like, such
    as "e", which is commonly done. The MouseEvent defines the class,
    and should be exactly what it is.... a MouseEvent, caps and
    all.

  • Advantage and Disadvantags of ActionScript 3

    Hi professionals of ActionScript 3!
    I just started flash animation and learning ActionScript. But
    I found one thing that there existing ActionScript 1, 2, 3 versions
    and ActionScript 2 components is using only ActionScript 2 code.
    Please tell me advantages and disadvantages of both ActionScript.
    Please advise which is powerful and has more info and sources. What
    kind of links between then existing.
    Thanks in advance!
    Said Babanli

    Said,
    > Please tell me advantages and disadvantages of both
    > [versions of] ActionScript. Please advise which is
    > powerful and has more info and sources.
    ActionScript 1.0 and 2.0 both run on the same virtual
    machine (AVM1)
    inside Flash Player. As of Flash Player 9, the player runtime
    features two
    virtual machines (AVM1 and AVM2), the second of which runs
    ActionScript 3.0.
    Right off the bat, this tells you that Flash Player 9 or
    higher is required
    if you want to program with ActionScript 3.0. In one sense,
    that's a
    potential "disadvantage" of AS3: if your users have Flash
    Player 8 or lower
    installed, you simply can't use that version of the language.
    Instead,
    you'll have to use AS2 (as far back as Flash Player 6) or AS1
    (as far back
    as Flash Player 5), or slash-notation proto-ActionScript if
    you need to go
    even further back than that. Ultimately, then, the version of
    ActionScript
    you use depends on the version of Flash Player you expect
    your users to have
    installed.
    AS2 is the first version of ActionScript to officially
    support custom
    classes (external text files structured in a particular way,
    using folders
    for classpaths and the "class" keyword). For more information
    on
    classpaths -- written for AS2, but basically applies to AS3
    -- see this URL:
    http://www.quip.net/blog/2006/flash/understanding-classpaths
    For many people (myself included), custom classes provide a
    powerful way
    to organize code into reusable objects -- just like the given
    objects in
    ActionScript's native API. Be aware, however, that custom
    classes are *not
    a required workflow* in AS2 or AS3. If you prefer, you may
    place your AS2
    or AS3 code into timeline keyframes, just like with AS1.
    Contrarily, even
    though true classes are not officially supported by AS1, you
    can mimic many
    of the benefits of classes by following the instructions here
    (an incomplete
    resource, but very useful):
    http://www.debreuil.com/docs/
    It would take pages and pages of notes to give you a
    thorough list of
    the benefits (and disadvantages!) of every version of
    ActionScript. Even
    then, it would be difficult to demonstrate that such a list
    was complete, so
    to keep things simple: as a general rule, each new version of
    ActionScript
    is presumed to be better than its predecessor. AS1 was more
    powerful than
    Flash 4-era ActionScript because it provided a considerably
    larger API. AS1
    also made it easier to target objects with dot notation than
    with slash
    notation and cumbersome getProperty() and setProperty()
    functions. AS2 was
    more powerful than AS1 because it provided native support for
    classes. It
    introduced variable typing, which helped with code completion
    and
    compile-time error checking. (AS2 also coincided with an even
    larger API,
    but that's a parallel benefit due to increased functionality
    in subsequent
    versions of Flash Player.) AS3 is more powerful than AS2
    because the syntax
    of custom classes has become more strict. I personally find
    that stricter
    syntax helps a programmer avoid "lazy" or "sloppy" practices,
    encouraging
    the programmer to code with purpose.
    For more thoughts along these lines, here's a free excerpt
    from a book I
    recently co-authored for O'Reilly (bear in mind, these are
    largely
    subjective opinions, but they work for me):
    http://www.communitymx.com/abstract.cfm?cid=16D76
    I'll probably start repeating myself soon, but to sum up:
    AS2 has
    advantages over previous versions because it provides
    numerous options and
    improvement in ease of use. AS3 improves even further by
    "cleaning up" the
    language by making it more strict and by providing a stronger
    internal
    consistency.
    Here are a few quick examples.
    In AS2, to create an instance of the Sound class (that is,
    an object you
    can use for programming audio), you simply use the "new"
    keyword:
    // AS2
    var mySound:Sound = new Sound();
    Most classes can be instantiated in this way, but in AS2,
    there are
    notable exceptions, including movie clips and text fields.
    // AS2 -- this does NOT work!
    var myMC:MovieClip = new MovieClip();
    var myTF:TextField = new TextField();
    This can be confusing to a newcomer, because it seems so
    arbitrary.
    (Someone new might well think, "Why can't instances be made
    the same way
    across the board?") In AS3, instantiation is more consistent:
    // AS3
    var mySound:Sound = new Sound();
    var myMC:MovieClip = new MovieClip();
    var myTF:TextField = new TextField();
    This is also true for event handling. In AS2, there are four
    or five
    ways to do it: the on() and onClipEvent() functions, their
    dot notation
    equivalents, addListener(), and addEventListener(). They're
    all valid in
    AS2, but not all interchangeable. Some work for components,
    some for other
    sorts of objects. It takes effort to memorize which objects
    work with which
    approach. In AS3, outside of a very small number of
    exceptions, most event
    handling is done with a single, consistent approach:
    addEventListener().
    For a newcomer, this is easier to learn because once the
    technique is
    understood, it works in nearly every scenario.
    As far as performance is concerned, AS3 trumps AS2
    significantly. AS3
    performs better and faster than all previous versions of
    ActionScript -- but
    you'll only notice this with complex applications, especially
    those
    involving a high volume of number crunching.
    Here are a few more links that may prove helpful to you:
    ActionScript 3.0 Overview
    http://www.adobe.com/devnet/actionscript/articles/actionscript3_overview.html
    Tips for Learning ActionScript 3.0
    http://www.adobe.com/devnet/actionscript/articles/actionscript_tips.html
    ActionScript 3.0: Is it Hard or Not?
    http://www.insideria.com/2008/01/actionscript-30-is-it-hard-or.html
    You also asked which version of the language has more "info
    and
    resources." By that, I assume you mean online resources, such
    as blogs,
    tutorials, and so on. That question is hard to answer, but my
    *guess* is
    that there are still more resources online about AS2 than AS3
    ... but AS3
    will probably catch up soon.
    David Stiller
    Co-author, Foundation Flash CS4 for Designers
    http://tinyurl.com/5j55cv
    "Luck is the residue of good design."

  • I need to make a task with less as3 code and more timeline structure and event dispatcher !

    I went to an interview in a big company. I had to make a  task in which there is a wall with 3 lines and 5 columns filled with bombs.When you click on a bomb the bomb changes its scale, a robot enters, goes under the bomb and takes it, then goes to a smaller wall, makes the bomb smaller and place it at the same place it had been in the previous wall.I made the task with tween througout as3 code.The interviewer told me it was good but i need to make it with the less code possible and with more complex timeline structure and to use event dispatcher.What is the best way to do this ?

    The immediate thing that comes to mind is they might want to see that you can balance work between design teams and development teams.
    To do that, the robots movements (pick up bomb, bomb grows/shrinks, arms/treads/legs moving, sequences of 'doing things') can be timeline based so animators can work on those separate from code.
    Developers would be working on the logic of keeping score, moving the robot around to the correct spot with path detection, collision detection, etc.
    It's very similar to thinking in simple factories (which Flash is good at being automatically with timelines), and a bit of MVC (or just VC in some cases).
    Big companies have lots of different types of employees so you'll probably be very specific in your role so you're efficient.

  • AS3 plays all Movieclips in timeline before a given frame?!?

    Ok, I am going to try to explain this problem as best I can,
    but it is kind of hard to put into words... It seems like a bug to
    me, but I could be wrong, maybe this is the way AS 3 supposed to
    work.
    I have 4 movieClips in my library named
    "MC1","MC2,"MC3","MC4" Each with 2 layers and 2 frames, on Layer 2
    is just a textfield that says what movieclip it is, Like "MC1"
    which spans 2 frames, on layer 1 I have trace commands...
    On frame 1
    trace("MC1 Start") //this obviously changes to MC2
    Start...etc with whatever movieclip i am in
    on Frame 2
    trace("MC1 Stop")
    On the Stage timeline here is what I have
    Frames 1-4 -- Blank
    Frames 5-10 -- MC1
    Frames 10-14 -- MC2
    Frames 15-19 -- MC3
    Frames 20-24 -- MC4
    If in frame one I say--
    gotoAndStop(15)
    which is where MC3 resides, here's what I get in the output
    window:
    MC1 Play Start
    MC2 Play Start
    MC3 Play Start
    MC3 Play Stop
    If I put:
    gotoAndStop(20)
    Which is where MC4 resides, heres what output says:
    MC1 Play Start
    MC2 Play Start
    MC3 Play Start
    MC4 Play Start
    MC4 Play Stop
    So in AS3 if you go to a frame number each and every
    movieclip before that given frame is loaded into memory and the
    first frame plays?!? Is this how it is supposed to work?
    The reason I even started examining this, is because if you
    have an embedded sound in any of those movieclips and you go to
    frame 20, all embeded sounds before that clip will play as well. Am
    I missing something here, or is this a bug? Please let me know. If
    there are any questions about the problem, I will be happy to
    provide an .fla.
    Thanks

    Thanks for the reply, but this makes no difference. The
    results are still the same.

  • AS3 and Timeline

    envrionment: FlashPro CS6 (12.0.0.481) on Windows 7
    This might be a bit of a newbie question, but I am struggling to understand how I can more efficiently load and display external swf to the stage without using the timeline.
    I have created 4 external swfs that load dynamic data from XML, assignes them to variables and then displays the data.
    (RMStats.swf)
    var xmlData:XML = new XML();
    var theURL_ur:URLRequest = new URLRequest("RMStats.xml");
    var loader_ul:URLLoader = new URLLoader(theURL_ur);
    loader_ul.addEventListener("complete", fileLoaded);
    function fileLoaded(e:Event):void
       xmlData = XML(loader_ul.data);
       RMDates_txt.text = xmlData.Dates;
       RMLostTime_txt.text = xmlData.LostTime;
       RMModifiedWork_txt.text = xmlData.ModifiedWork;
       RMMedicalAid_txt.text = xmlData.MedicalAid;
       RMFirstAid_txt.text = xmlData.FirstAid;
       RMIncidents_txt.text = xmlData.Incidents;
    then I created a swf to load each of the individual swfs in sequence,
    (movie.swf)
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("RMStats.swf");
    myLoader.load(url);
    addChild(myLoader);
    but I find it cumbersome that the only way I can find to sequence the swfs is to create a timeline and call each from the actionscript at the beginning.
    I looked for code snippets from others that have done this but couldn't find anything specific.
    Is there any way to create one AS3 procedure that loads each external swf, waits the equivalivent of the time on the time line and then loops to the next?
    In essence, can I replace the timeline with AS3?
    example
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("RMCurrent.swf");
    myLoader.load(url);
    addChild(myLoader);
    wait(60):
    var my2ndLoader:Loader = new Loader();
    var url2:URLRequest = new URLRequest("RMPrevious.swf");
    my2ndLoader.load(url2);
    addChild(my2ndLoader);
    wait(60):
    etc
    I would probably create an array of the swf and call them in a loop if i could.

    you can either use a callback function in the last frame of your external swfs (that triggers the load and/or display of the next swf) or use an enterframe loop that repeatedly checks the currentFrame of the current swf and triggers the load/display of the next swf when currentFrame==totalFrames of the current swf.

  • As3 in timeline and class

    Hi folks.
    I'm trying my best in a game project, but just can't do it right.... I'm a complete noob in as3 (have done my share of simple as2 though, possibly that's my problem..), but have managed to get to a certain point in the project where I have game functionality, but now i stumble where I thought would be no problem at all. I made a game where all the "gaming" code is in the external .as file, and it all works fine, but when I add a code to the timeline from code snippets, it all stops working.
    Is it possible that .as code and timeline code don't work together?
    Thnx in advance

    Ok, this is the class:
    package
        import flash.display.MovieClip;
        import flash.events.MouseEvent;
        public class Spajalica extends MovieClip
            private var xPos:int;
            private var yPos:int;
            private var correctCount:int = 0;
            private var totalCount:int = 1;
            public function Spajalica():void
                addListeners(s1);
            private function getPosition(target:Object):void
                xPos = target.x;
                yPos = target.y;
            private function dragObject(e:MouseEvent):void
                getPosition(e.target);
                e.target.startDrag(true);
            private function stopDragObject(e:MouseEvent):void
                if (e.target.hitTestObject(getChildByName(e.target.name + "Target")))
                    e.target.x = getChildByName(e.target.name + "Target").x;
                    e.target.y = getChildByName(e.target.name + "Target").y;
                    //deactivate object
                    e.currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, dragObject);
                    e.currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, stopDragObject);
                    //increment correct count;
                    correctCount++;
                    // totalCount is the amount of solutions the user must solve to proceed
                    if (correctCount == totalCount)
                        nextFrame();
                else
                    e.target.x = xPos;
                    e.target.y = yPos;
                e.target.stopDrag();
            private function addListeners(... objects):void
                for (var i:int = 0; i < objects.length; i++)
                    objects[i].addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
                    objects[i].addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
    and this is the button code in my frame 2 (it's from code snippets):
    back.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_2);
    import fl.display.ProLoader;
    var fl_ProLoader_2:ProLoader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad_2:Boolean = true;
    function fl_ClickToLoadUnloadSWF_2(event:MouseEvent):void
        if(fl_ToLoad_2)
            fl_ProLoader_2 = new ProLoader();
            fl_ProLoader_2.load(new URLRequest("http://www.helpexamples.com/flash/images/image1.jpg"));
            addChild(fl_ProLoader_2);
        else
            fl_ProLoader_2.unload();
            removeChild(fl_ProLoader_2);
            fl_ProLoader_2 = null;
        // Toggle whether you want to load or unload the SWF
        fl_ToLoad_2 = !fl_ToLoad_2;
    In frame 1 in my actions layer i have stop(); and it works until I ad the above code to frame 2

  • How to _root in as3 (buttons in movie clip referencing to main timeline)

    Hi, I created buttons within a movie clip that i placed in the main timeline.I am  a novice to as3. I just wanted the button to go to the frame label of the main timeline. i used to do this with _root in the old flash. how do i do this?
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        gotoAndPlay("slide2");

    Thanks for the quick reply!
    somehow i must be doing something wrong though. It's not working...
    I added a stop to the "slide02" labeled section of the main timeline.
    and I also added a stop to the beginning and end of the movieclip. Am I doing something wrong? attached is my file....thanks!!
    stop();
    thumb02_btn.addEventListener(MouseEvent.CLICK, buttonClicked);
    function buttonClicked(event:MouseEvent):void
        MovieClip(this.root).gotoAndPlay("slide2");
    stop();

  • Stoping a timeline for set durations at various frames (AS3) ?

    Hi Guys,
    I'm wondering how to stop the root timeline at a given frame using action script 3 in flash CS4
    With AS2 I used this kind of script that worked all the time.
    this.createEmptyMovieClip ("timer",50);
    timer.onEnterFrame = function () {
        if (this.startTime > 0) {
            var difference = getTimer () - this.startTime;
            if (difference > this.timerLength) {
                this.target.play ();
                this.startTime = 0;
    function pauseFor (theTime) {
        stop ();
        timer.timerLength = theTime;
        timer.startTime = getTimer ();
        timer.target = this;
    And I called the pause duration from the frame that needed it, etc.
    Any ideas for AS3? (I've been away from flash for a year and it shows...ouch! but I'm a n00b to as3)
    Thanks in advance!!

    Hi Thali-Hoo,
    What you're going to want to do is take advantage of the timer class here, use a document class for your FLA and use an undocumented method addFrameScript. I've written up a sample of how to do all of this and posted it in a zip file. Basically here's what I've done though:
    package
        import flash.display.MovieClip;
        import flash.events.Event;
        import flash.events.TimerEvent;
        import flash.utils.Timer;
         * @author Jesse Nicholson
        public class PauseTimeline extends MovieClip
            public function PauseTimeline()
                if (stage) {
                    init();
                }else {
                    addEventListener(Event.ADDED_TO_STAGE, init);
            private function init(e:Event = null):void
                trace(totalFrames);
                addFrameScript(30, frame30);
            private function frame30():void
                //The playhead has just hit frame thirty. This is the same as having a script on a frame icon in the IDE
                trace("Hello, frame thirty");
                stop();
                var delayTimer:Timer = new Timer(5000, 0);
                //It's not the best thing to throw a function right into the handler reference but in this case it's short and sweet. See below on how you'd write the function out proper
                //This is how you would do the listener normally
                //delayTimer.addEventListener(TimerEvent.TIMER, frameThirtySleepTimerExpired);
                delayTimer.addEventListener(TimerEvent.TIMER, function(TimerEvent):void { gotoAndPlay(1); } );
                delayTimer.start();
            private function frameThirtySleepTimerExpired(e:TimerEvent):void
                //Check and see if the timer listener is on the currentTarget (the delayTimer object) and remove it if exists
                if(e.currentTarget.hasEventListener(TimerEvent.TIMER) == true){
                    e.currentTarget.removeEventListener(TimerEvent.TIMER, frameThirtySleepTimerExpired);
                //Do whatever you want to do in here (when your timer has expired/completed)
                 gotoAndPlay(1);
    So, to explain. The FLA has 50 frames on the root timeline. On init (which is when the stage is present, which means that the class has fully initialize and the constructor has been processed etc blah blah) I use addFrameScript and attach the method frame30 to frame 30 on the root timeline. This is the same as just going to frame 30 in the IDE, making a keyframe and writing on the timeline.
    So when the play head lands on frame 30, it calls the frame30 function. Inside that function we stop the playing of the timeline, create a timer object with a delay of 5 seconds and instead of passing in a reference to a handler function I just write a function on a single line right in there. Not the best way but for this example it's short and clean, but I still included a sample of how to do it normally commented out.
    When the timer is started, the clock starts ticking. When the timer has finished counting through it's delay, it will fire an event to the listener handler function which only has the code "gotoAndPlay(1)" to restart playing from frame 1, looping the whole process. I think this is what you're looking for but if not or if you have any questions let me know. In my job I try to work with AS3 as much as I can but sometimes (like today) they force me to go back to AS2 and.. well basically I can sympathize with you so let me know if you need any other help transitioning to AS3! lol Hope this works for ya,
    Jesse
    PS - DL The example here! http://ascensionsystems.ca/Pause Timeline.zip

Maybe you are looking for

  • How can I change the language of my German copy of Master Collection CS6

    Hi there, The full Master Collection Suite v6 I installed this weekend is in German, how do I change that to english for all 20+ applications? it's driving me bonkers trying to find a fix so if anyone can help big hugz to yoU! Eva

  • How to get a copy of my final bill?

    Just ported our two VZ numbers to T-Mobile on 02/01/14.  Our VZ billing cycle ends on 02/23/14.  If I understand correctly, my current payment scheduled for 02/18/14 takes care of my bill through the end of the current cycle ending 02/23/14 and the E

  • How can I run a SQL script file...

    How can I run a SQL script file from a location on my computer without providing the whole path? Is there some way I can set a "Working folder" in SQL Plus?? Thanks! Tom

  • Open Hub 3rd party tool - API not returning data table

    I am implementing a 3rd party tool to get data from BI using the Open Hub Service. I have my server running and the API functions are working somewhat, but I have two problems. When I get notified by BI (RSB_API_OHS_3RDPARTY_NOTIFY), the REQUESTID fi

  • MI07,Physical Inventry posting can hit dual G/L or Double Entry posting

    HI Experts, At the time of Physical Inventry posting, we are using Tcode-MI07. After that normally two documents are generated. One is accounting document and another is material posting document. Then we hit two G/L in Accounting document, one is In