Functions on a timeline

So i have some bars that move up and down randomly when a
song is being played. the bars movieclip is located at
_root.iphone.body.bars
i have a mute button that makes all the bars go to height 0
and stop the music
the button for that is located
_root.iphone.body.mute
the actions for the function to make the bars move (function
heightt() ) is on the bars movieclip timeline
the actions for the function to make the onRelease of the
mute button is also inside the bars movieclip timeline
the actions to make a song play when u click a song button
are located on _root.iphone
so what i want to do is access function heightt() when u
click one of the song buttons.
so far i have
song1_btn.onRelease = function() {
body.bars.heightt();
that makes the bars move from their 0 height, but they dont
animate.
why?
here is the function to make the bars move
myInterval = setInterval(heightt, 200);
function heightt() {
for (i=1; i<=5; i++) {
set("newHeight"+i, Math.floor(Math.random()*57));
var motion:Object = new Tween(eval("b"+i), "_height",
Strong.easeOut, eval("b"+i)._height, eval("newHeight"+i), .2,
true);
so i want to call that function from clicking the music
buttons, but i cant seem to get it right cuz they are on different
timelines, or maybe it has to do with the interval, im not
sure.

Write this function in your iphone.body.bars mc.
function callHeight() {
myInterval = setInterval(heightt, 200);
Write this function in your iphone mc.
song1_btn.onRelease = function() {
body.bars.callHeight();
This is what you required?
If not, try to send the .fla file to my id. I'll try to fix.
My id is
[email protected]

Similar Messages

  • Call function in main timeline from class file

    Hi all, How can a function in main timeline be called from class file?

    Hi all, How can a function in main timeline be called from class file?
    You can, but you really shouldn't.
    Classes shouldn't "talk" to the outside directly.
    Use Event dispatching to get things done.
    "root" (i just threw up by just typing that word) should be avoided at all cost, especially in AS3.

  • Use button on mc  to perfrom function on main timeline

    I Was wondering how (or if it is posiible) to use a button I
    have in a movie clip to perform a function on the main timeline.
    Specifically, I want the button in the movie clip to gotoAndStop on
    a frame in the main timeline. Any suggestions?

    Hi,
    Then you would target the movie clip.
    So you would give the mc an instance name (like myClip_mc )
    then just add this into your code ....
    button1.onRelease = function() {
    _root.myClip_mc.gotoAndStop(20);
    This would tell the myClip_mc to stop on frame 20. Providing
    the mc is located in the main timeline that is.
    You can see from the code that we are going to the _root and
    looking for the myClip_mc. If it is held within another mc (say
    Holder_mc) then the code would change to
    _root.Holder_mc.myClip_mc.gotoAndStop(20;
    for cs3 (actionscript 3) it would be this
    button1.addEventListener(MouseEvent.CLICK,clickHandler);
    function clickHandler(event:MouseEvent):void{
    _root.myClip_mc.gotoAndStop(20);
    Hope this helps
    Alan

  • Ref functions on main timeline within MC

    Does any one know of a way I can call a function thats set up on the main timeline using AS in movie clip thats a child of the timeline?
    IE:
    I have a function called setName(); on the main timeline.... I also have a movieclip called contact_mc and I need to add EventListeners within the contact_mc that would some how call the setName(); function thats in its parent timeline... Any advise you can offer is apperciated!

    try:
    MovieClip(this.parent).setName();
    to reference the movieclip.  i'm not sure what events you want to trigger that function call.

  • Conditional "time function" to play timeline

    Hello everyone:
    I'm having trouble doing something I thought would be simpler. I have done this in AS/Flash but it doesn't seem to work in Edge. I have a small animation in the timeline (1s animation of alpha 0 to alpha 100 of group of objets) and I would like it to play specifically at a given time.
    I created a funcion called updateClock() that checks the system time and gets hours and minutes and I call this function every second so it updates with setTimeout. I have a conditional to play the animation at a given time (you might need to change this line) that starts at frame 1000, or else, that it freezes the timeline at that very same frame. Finally I call the function.
    Right now this code is in .compositionReady, but I also tried a trigger at 1000 ms. Any help with this would be appreciated. At 1000 ms the trigger sym.stop() works. Right now not even that works and the animation plays by itself.
    function updateClock() {
        var now = new Date(); // current date
                var m = d.getMinutes();
                var h = d.getHours();
        // call this function again in 1000ms
        setTimeout(updateClock, 1000);
        if(h== 20 && m== 56) {
    //run the animation
    sym.play(1000);
      else {
      sym.stop(1000);
    updateClock(); // initial call
    Thank you in advance for any help you can provide.

    You have to use a global variable (sym.updateClock). Here is a case.
    1) compositionReady panel:
    function updateClock() {
      var now = new Date();
      var m = now.getMinutes();
      var h = now.getHours();
      console.log(h,":",m);
      sym.updateClock = setTimeout(updateClock,1000);
    updateClock();
    2) With a click event or a trigger:
    clearTimeout(sym.updateClock);

  • Handling a function on the timeline vs. button

    * never mind * forget this post... it actually does work... I
    was calling enabled = false and then enabled = true further down in
    the code without realizing it... duh...
    this is working...
    on(release){
    _root.QuitButton.enabled = false;
    this is not working...
    button script:
    on(release){
    mDisableQuitButton();
    timeline script:
    function mDisableQuitButton(){
    trace("disable function called");
    _root.QuitButton.enabled = false;
    the trace is visible, but the '_root.QuitButton' is still
    enabled... ???
    thanks for any feedback

    why not just put _root.QuitButton.enabled = false on the
    timeline?
    Dan Mode
    *THE online Radio*
    http://www.tornadostream.com
    *Must Read*
    http://www.smithmediafusion.com/blog
    *Flash Helps*
    http://www.smithmediafusion.com/blog/?cat=11
    "NodeNode" <[email protected]> wrote in
    message
    news:e69k56$a87$[email protected]..
    > this is working...
    >
    > on(release){
    > _root.QuitButton.enabled = false;
    > }
    >
    > this is not working...
    > button script:
    >
    > on(release){
    > mDisableQuitButton();
    > }
    >
    > timeline script:
    > function mDisableQuitButton(){
    > trace("disable function called");
    > _root.QuitButton.enabled = false;
    > }
    >
    > the trace is visible, but the '_root.QuitButton' is
    still enabled... ???
    >
    > thanks for any feedback :)
    >

  • Search/Find Function in Timeline?

    In the project panel there are several different ways to search through all of your media to find specific clips. Is there anything similar for the timeline?
    For example - I have a 30 minute sequence with 7 tracks of dialogue. Each clip of dialogue is labeled with a line number from a script. When a producer comes over and asks "Can you quickly go to line 416?"...I'd like to be able to quickly do that.
    Avid has a function where you can perform a find in the timeline for specific file names - does Premiere have anything like that? If someone could help me out that would be great!

    Peru Bob wrote:
    Right click > Reveal in project
    Hi Peru Bob,
    I believe myhar is looking for a search function for the Timeline. She wants to search for a specific clip name and have the playhead jump to that clip, if I am not mistaken. Reveal in Project is when you know where the item is in the Timeline, but you want to find it back in the Project panel.
    Cheers,
    Kevin

  • How to add button inside move clip and call it from main timeline?

    Hi,
    On the main timeline I  have a movie clip called clock_mc and playBtn
    playBtn is  placed in the center of clock_mc
    When you press playBtn clock_mc starts playing
    playBtn.addEventListener(MouseEvent.CLICK, playClock);
    function playClock(event:MouseEvent):void
        if (event.target == playBtn)
            clock_mc.play();
            playBtn.visible = false;
            trace ("play button was clicked");
    This is working fine for me.
    But I want to add replayBtn to the last frame of clock_mc and set up the function on main Timeline.
    Another words when the clock_mc rich last frame you see replayBtn.
    code example:
    replayBtn.addEventListener(MouseEvent.CLICK, playClock);
        if (event.target == replayBtn)
            clock_mc.play();
            replayBtn.visible = false;
            trace ("replay button was clicked");
    I've tryed to placed the replayBtn on the stage on the main timeline and I've set it up to replayBtn.visible = false;
    And then I add replayBtn.visible = true; to last AS frame of clock_mc but it wont work
    Even when I put the button physically to the last frame of clock_mc it will not work either.
    Please help

    I've solved the problem:-)
    I've set replayBtn.visible = false; on first frame of clock_mc
    and  replayBtn.visible = true; at the last frame
    and than as you sugested I'v add:
    clock_mc.replayBtn.addEventListener(MouseEvent.CLICK, replayClock);
    function replayClock(event:MouseEvent):void
            clock_mc.play();
            trace ("replay button was clicked");
    I couldn't see replayBtn at the firs stage because I have clockTween assosiated with clock:
    clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
    and I had replyBtn in the wrong place so when clock_mc was coming up on the stage replayBtn was on the left side of the stage :/
    Now I have to solve only one thing.
    Maybe you would have any suggestions please.
    I've set up stop(); in a first frame of clock_mc
    that when you see clock_mc sliding in it has to wait for playBtn to be clicked
    because I have two tween:
            clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
            playTween = new Tween(playBtn, "x", Regular.easeOut, -720,514, .5, true);
            playBtn.visible = true;
    so when you click on playBtn:
    function playClock(event:MouseEvent):void
        if (event.target == playBtn)
            clock_mc.play();
            playBtn.visible = false;
            trace ("play button was clicked");
    everythink is working fine except when I clik on replayBtn it play for I sec because there is stop(); on the first frame of clock_mc

  • Running a function in a parent at the end of a child.swf

    question: How do I call a function that is inside a
    parent.swf from a child external swf (class Loader)?
    In my menu.swf, there is a child (Loader class) of a
    content.swf that gets loaded below it on run. Then when a button is
    clicked, it makes a string that contains the name of the content
    file to load next, then initiates an ending function on the child,
    which does some outro animation.
    function buttonClick(event:MouseEvent):void
    nextContent = event.target.name + ".swf";
    MovieClip(newContent.contentLoaderInfo.content).endSequence();
    after the ending sequence has executed in the ccontent.swf I
    need to know how to make a call to a function back in the menu.swf
    so that I can load the nextContent

    quote:
    Originally posted by:
    abeall
    Where is the function, on the timeline? You could try:
    MovieClip(parent).functionName()
    Thank you for the help.
    It compiles but I get a runtime error: TypeError: Error
    #1034: Type Coercion failed: cannot convert
    flash.display::Loader@248b5791 to flash.display.MovieClip.

  • Components .as file vs component timeline

    Is there any way of accessing a custom(what I mean is that
    you`ve created it) component`s .as file from the component`s
    timeline and vice-versa?
    More specificaly, my problem is:
    I have made my own CheckBox component, with an animation when
    you check it. The problem is I can still click it and change it`s
    selected state while the animation is playing, and if I
    where to click twice before the animation is done, the checkbox
    would be checked, but the
    selected state of the component would be... false(or the
    other way around). What I need is to
    removeEventListener(MouseEvent.CLICK, onClick) the second
    frame of my checkbox animation, and then
    addEventListener(MouseEvent.CLICK, onClick) back when the
    animation reaches a
    stop() frame. However, I have declared the
    onClick function inside the component`s .as file, and so I
    get an error that there is no
    onClick function in the Timeline of my animation... And,
    yes, there isn`t, but there is on in the .as file. I need to relate
    to THAT one. Of course, I could solve this problem by other means,
    but I`m just curious if it could be solved this way...
    Thank you for your time :)

    It depends on how complex your swf is. If you are doing
    mostly design work with a hint of ActionScript, creating external
    AS files is probably more clutter than it's worth.
    Use external AS files if:
    - You are doing a lot of scripting. It can be a huge pain
    navigating an FLA to find the right frame of the right object. It
    also gives you more redundancy in case Flash crashes, you don't
    lose a bunch of work. Lastly, external editors like FlashDevelop,
    SEPY, and Eclipse are much nicer to work with than Actions palette
    is.
    - You have different objects talking to one another. You can
    open the class files side-by-side and work on them together.

  • Insane duration of audio rerender in Multicam Timeline - is there a workaround? (CS6)

    I am using the Multicam function (CS6) on timelines with a duration of 60 to 120 minutes. Sometimes I have to cut out a small portion of the video, and then Premiere needs to rerender the audio - which is quite annoying because it takes several minutes to do so.
    But now it has grown even worse. I cut a small portion of the timeline, marked and copied it, undid the cuts and inserted the copied part at the end of the timeline. Then I wanted to continue editing but Premiere still started the audio rerender process - but it says it would need more than 8 hours for this?!? Seriously? (It finally rerenders a lot faster (25 minutes), but still that is more than annoying, just because I did a cut and undone it... .
    So is there a way to work around this behavior or can it be avoided at all? Needless to say that an 8 hours pause in my working schedule is not acceptable at all.

    Hi Discover-Truth,
    So is there a way to work around this behavior or can it be avoided at all? Needless to say that an 8 hours pause in my working schedule is not acceptable at all.
    I've seen this happen to users when their sequence settings for audio sample rate do not match the clip settings for audio sample rate. Can you check on that?
    Thanks,
    Kevin

  • Trying to call a root level function from within a loaded swf

    I'm not very familiar with AS3... I'm trying to have a loaded swf file call a function from the parent to unload itself when it comes to the end (on the timeline, not as a button). I'm assuming I need to be calling the function (that is used for the close button) from the loaded swf (perhaps I'm mistaken though?).
    Here's the code from one of my buttons that loads an swf. I'm guessing I need to call the closeSWF function from the timeline of my loaded movie but having no luck figuring out how to do that.
    Any help would be appreciated.
    // 01 ------------------------------------------------------
    function loadWeaving(ev:MouseEvent):void {
      // load SWF
      var movieClip:MovieClip = new holder_mc;
      //add it to the stage
      addChild(holderSWF);
      holderSWF.x=0;
      holderSWF.y=0;
      var requestEN:URLRequest = new URLRequest("WhatIsWeaving_Eng.swf"); // english
      holderSWF.load(requestEN);
      close_bt.addEventListener(MouseEvent.CLICK, closeSWF);
      function closeSWF(infoObject:Object):void {
      trace("close SWF");
      removeChild(holderSWF);
      // reset switch
      close_bt.visible = false;
      showAllButtons();
      infoObject.currentTarget.removeEventListener(infoObject.type, closeSWF);
      setChildIndex(close_bt,numChildren - 1);
      close_bt.visible = true;
      hideAllButtons();
      // - start timer last
      myTimer.addEventListener(TimerEvent.TIMER, closeSWF);

    You're exactly right. If you attach an event listener to the Loader before you add it to the stage, you can then use event.currentTarget to refer to the loader. And this is definitely the better way to do it if you're planning to use the loaded swf from multiple places or could ever need to do this in the future.
    So:
    protected function initLoader():void {
         var loader:Loader = new Loader();
         loader.addEventListener('closeMe', closeLoader);
         loader.load(new URLRequest(...));
         addChild(loader);
    protected function closeLoader(e:Event):void {
         var loader:Loader = e.currentTarget as Loader;
         if (loader) {
              loader.unloadAnstop(true);
              loader.removeEventListener('closeMe', closeLoader);
              removeChild(loader);

  • OnRelease function "catches" (disables) buttons rollovers

    Hello,
    This must be a simple one but...
    I need to have buttons with a "selected" state, so I made a
    two frame mc
    with actual button on frame 1 and selected state on frame 2.
    To switch state, I added a onRelease function on the timeline
    myButton.onRelease = function() {
    Everything works fine, except buttons don't react anymore
    when mouse is
    over, like if this function was "catching" every mouse event
    (which it
    may do, actually).
    Do I have to add a kind of "pass" command ?
    Do I have to rewrite rollover for EACH button ?
    Thanks in advance.
    PJ

    DLMAES a écrit :
    > When you say put a button on the stage, your adding a
    button instance to the
    > stage then wrapping it in a movie clip? If that is the
    case, just make a movie
    > clip and use that as the button. It doesn't make sense
    to use a button clip
    > instance then wrap it in a movie clip... Maybe I'm just
    not understanding your
    > process. Sorry if I'm not clear.
    >
    I completely see your point but...
    Actually, I had my whole interface done with nice buttons and
    then they
    came with the "buttons should stay selected" thing ;-)
    I've already done that "2 frames trick" in the past, but I
    think code
    was on the button itself to switch from frame 1 to 2 (you
    could not
    directly address buttons at the time). It's so easy this way
    and I don't
    have to rewrite rollover state.
    Plus, my "selected" state must be unselectable, so I put
    another button
    with a different color in frame 2, it's more clear to the
    user this way
    (selected button is visibly active).
    I just don't understand why the onRelease function traps ALL
    mouse
    events and how to let them "pass" afterwards... I'm afraid
    you just can't...
    Thanks.
    PJ

  • Two basic functions

    I have always used two basic functions to navigate timelines
    in flash. Examples:
    stop();
    this.btn_Continue.onRelease = function(){
    _parent.gotoAndPlay("P02");
    I've been reading the help section and cannot seem to find a
    simple explanation for this simple functionality in AS3.

    Thank you.
    Something weird though.
    Now I'm trying:
    this.stop();
    It will not stop the playhead in my movie. Except, I created
    a new file and it works there.
    ??

  • Can a socket connection be created inside a Timeline to port 23?

    Is there a security restriction or some other reason why I always get a java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method)
    when I try to open a socket inside a function in a Timeline to port 23? The connection works fine to the host if the code is not is not inside a Timeline. It also seems that a socket connection to port 80 works okay too.
    Thanks for any help in advance.
    Regards,
    Richard

    Here is the Timeline code:
    var addr:InetSocketAddress;
    var sConn:Socket;
    var reader:BufferedReader;
    var s:String;
    Timeline {
    repeatCount: Timeline.INDEFINITE
    keyFrames: [
    KeyFrame {
    time: 10s
    action: function() {
    try {
    addr = new InetSocketAddress("somehost",23);
    sConn = new Socket();
    sConn.connect(addr);
    reader = new BufferedReader(
    new InputStreamReader(sConn.getInputStream()));
    // reader.readLine(); // throw away first line
    s = reader.readLine();
    bindTemp = response.getResponse("$0001").getTemperature();
    bindVolt = response.getResponse("$0001").getVoltage();
    } catch (e:Exception) {
    System.err.println(e);
    }.play();
    The ConnectionRefused error occurs only when the NetBeans Project Application Properties "Draggable Applet" checkbox is checked ( which is the default ). Once I uncheck it, the error goes away.
    -Richard

Maybe you are looking for