Help Looping functions! : S

Hey there,

Can someone help out me once again hope. Really stuck on this, which im will she succeed to reach is to play a sound 2 times, wait a few seconds and then play again, repeat this process until a key is pressed.

my code:

function clickThatSays_Sound(event:Event):void

{

var sh_SoundLoopVar = 1;

while (sh_SoundLoopVar = 1)

{

shSound_Channel = sheepSound.play (0.2);

shSound_Transform.volume = 1;

shSound_Channel.soundTransform = shSound_Transform;

sh_SoundLoopVar ++;

shSoundLoop_Timer.start ();

shSoundLoop_Timer.addEventListener (TimerEvent.TIMER_COMPLETE, shSoundLoopTimer);

int shSoundLoopTimer(event:Event):void

{

shSound_Channel = shSound.play (0.2);

shSound_Transform.volume = 1;

shSound_Channel.soundTransform = shSound_Transform;

}

}

do not understand y it doesn't work I put in a trace, but even that appears not, it plays the sound 1 x and then stops.

Help, please

THX pavel

When a while loop, and the beginning of the loop for, they are running from end to end before anything else happens.  so, it's a problem.  You also have an inconsistency of the left and right bracket.  then things get worse with nested functions and a timer that don't do anything useful.

I don't see any way to correct your code.  but here's how I would do what you want:

var c:SoundChannel;

var t:Timer = new Timer (2000,1);
t.addEventListener (TimerEvent.TIMER, playF);

var s:Sound = new YourSound();

playF (null);

function f (e: Event) {}
t.Start ();
}

function playF(e:Event):void {}
c = s.play (0.2);
c.addEventListener (Event.SOUND_COMPLETE, f);
}

Tags: Adobe Animate

Similar Questions

  • Help: call function that calls another function

    public var sourceFile:File = File.applicationDirectory.resolvePath ("serverIP.txt");

    public var fstream:FileStream = new FileStream();

    public var svrAdd:String = ";


    private void readText(e:Event):void {}

    svrAdd = fstream.readUTFBytes (fstream.bytesAvailable);

    FileStream ();

    }


    public function get vrieniHttpURL (): String

    {

    {}

    fstream.addEventListener (Event.COMPLETE, readText); // I want the readText run before function

    fstream.openAsync (sourceFile, FileMode.READ);    / / because I want to get the new value of svrAdd

    } while(svrAdd == '')

    var v: String = "http://'+ svrAdd +'/ Zion/php /'; "

       return v;

    }

    PLEASE HELP ME

    Hello

    First of all, please go through the Flex documentation on what is aynchronous operation is... ? I think that you are not familiar with this concept... Well, let me explain...

    public function get vrieniHttpURL (): String

    {

    {}

    fstream.addEventListener (Event.COMPLETE, readText);

    fstream.openAsync (sourceFile, FileMode.READ);

    delay execution

    } while(svrAdd == '')

    var v: String = "http://'+ svrAdd +'/ Zion/php /';"

    Return to v;

    }

    In the function as you posted the closure is not necessary it will loop continuously and defenitely will enter an infinite loop because svrAdd remains empty string("") how long loop you... it is because fstream.openAsync (sourceFile, FileMode.READ); is that an asynchronous operation means that the function redaText is executed only when the text file is read completely until the application does not wait for the service to call at the place he will perform the following lines of code in the function vrieniHttpURL i.e;

    var v: String = "http://'+ svrAdd +'/ Zion/php /';"

    Return to v;

    lines executed and your return value will be "http://Zion/php /" instead of http://votre_domaine/Zion/php /.

    Use the code to get the solution below:

    Import mx.core.Application;
      
    public var sourceFile:File = File.applicationDirectory.resolvePath ("serverIP.txt");
    public var fstream:FileStream = new FileStream();
    public var svrAdd:String = ";

    private void readText(e:Event):void {}
    svrAdd = fstream.readUTFBytes (fstream.bytesAvailable);
    FileStream ();
    svrAdd = 'http://'+ svrAdd +'/ Zion/php /';
    }
    public function vrieniHttpURL (): void
    {
    fstream.addEventListener (Event.COMPLETE, readText); I want the readText function to run before
    fstream.openAsync (sourceFile, FileMode.READ);    because I want to get the new value of the svrAdd
    }

     

     

    So whats that the above code is once when the 'vrieniHttpURL' function is called you open the file in read mode, and you cannot get the value of the svrAdd within this service because the contents of the file have not yet read... the content in the file is read-only once the readText function is executed... so once your readText function performed you will have your svrAdd filled with the correct value... That is to say; It contains your exact address. If after this you can use the value of svrAdd... you can not return the value of svrAdd with in the function 'vrieniHttpURL' as you did in your code.

     

    Give it a try...

     

    In fact I am unable to understand why you are so much unnecessary things... you can simply save your domain address in a variable and access in your application as below.

     

    public var svrAdd:String = http://yourdomainname.com/;

     

    If your domain name will change dynamically...?

     

    Please mark as answer if it helped you...

     

    Thank you

    Jean Claude Chari.S

     

     

     

     

     

     

  • Problem with dynamically created in a loop function

    Hi, the project is to create a thumbnail image dynamically from a xml file and display an overview with the event delivery. My problem is that I dynamically create a delivery for each thumbnail and inside the function the name of the image to load. I get no error, but the loaded image is always the last of the loop. Where is my mistake? Is there a solution?
    Any help will be welcome. I work hard on it but not more idea. Thank you very much for you reply

    Thank you very much Pajaroplus, it works with your help!

  • Y480 Help! Function of Lenovo and OneKey feature keys

    Hello

    I am very frustrated. I performed a clean installation of windows 7 64 bit on my y480 after buying a new SSD. Later, I was able to install all the drivers. However, when I try to use the fn key to increase and decrease the volume, I have more see the volume bar animation.

    Even with the following:

    1. on the screen caps lock icon

    2. no feature for onekey theater button

    3 no animation to the button mute.

    I would like that all of these features in turn. I tried searching for Lenovo Energy Management Software, but couldn't find Installer for y570 and 470. Energy management has worked for only the animation volume, then stopped working all together.

    In addition, I tried to install onekey theater, but even if I manually open the icon 'start onekey theater', there is no functionality in any key.

    I can't find software for Lenovo Enhanced experience in the part of the drivers/software from the support site.

    Please help with this. Everything is resolved with this new facility except for this.


  • any other video player sansa have a loop function?

    Hello

    I'm considering buying one of the Sansa video players.  One of them have a function in a transparent manner, as is included on a DVD player video looping?

    Thank you

    Zach

    DVD players are bigger and smarter than little mp3 players.

    Video is really an add-on for the "rocket", which is actually a music player. You could investigate the new rocket +, which has a larger screen for video and may have a few more video features - it has just been introduced, so there is not much information on this subject.

  • Helps the function 'Running background PL/SQL'

    Hello everyone.

    I come here for assistance with the service running background PL/SQL within the APEX. Here's a background of what I have to do.

    Background:

    Currently, I have just a page with a button above and some display boxes. The button calls a process flow Oracle Warehouse Builder (OWB) named RUN_ADJ_VAR and does what he must do. That works fine if my button simply calls the PL/SQL code of

    BEGIN

    ETQUEW. RUN_ADJ_VAR;

    END;

    Now that I know that the process flow and the button are working fine, I need to make the page "intelligently" by limiting multiple submissions until the process ends.

    What I need:

    I need assistance with running background PL/SQL function. My work has been running for a while and I need to run in the background and provide a status of the user, while restricting another presentation by the user. From what I've read here:

    Advanced programming techniques

    According to me, that this DBMS wrapper function, it's what I use.

    What I have so far:

    Using the API and example, I made my own attempt at this and it does not work. Here's what I have so far:

    [code]

    DECLARE

    v_sql VARCHAR2 (32767).

    BEGIN

    v_sql: = '

    BEGIN

    ETQUEW. RUN_ADJ_VAR;

    APEX_PLSQL_JOB. () UPDATE_JOB_STATUS

    P_JOB = >: APP_JOB,.

    P_STATUS = > "done");

    END IF;

    END;

    ';

    : P1_JOB: = APEX_PLSQL_JOB. () SUBMIT_PROCESS

    p_sql = > v_sql,

    p_when = > sysdate,.

    p_status = > 'Submit');

    : P1_POST_DONE: = 'Y ';

    END;

    [/ code]

    What the code so far:

    The code seems to ignore the first part and does work through the underlined only section. The work never appears to run and the button can be clicked several times.

    Other Options:

    I don't know if the function from PL/SQL background running is the only way to do that. The work is performed for about 15 minutes so I can't use a javascript script wait indicator since that will expire because of the hours of work. I searched all over the internet and forums and I feel I have exhausted all my options. I am very new to the APEX and PL/SQL in general, so your help is very appreciated.

    Thank you!!!

    Hello Konrad B.!

    Try to rewrite the code as shown below:

    DECLARE

    v_sql VARCHAR2 (32767).

    BEGIN

    v_sql: = '

    BEGIN

    ETQUEW. RUN_ADJ_VAR;

    END;

    ';

    : P1_JOB: = apex_plsql_job.submit_process (v_sql);

    END;

    Assume that P1_JOB - question on the page. After submitting the job, this point will be containing number of jobs. The job number,
    username (can get APP_USER) and workspace id (can get WORKSPACE_ID) you can check the status
    view of working level (field SYSTEM_STATUS) APEX_PLSQL_JOBS:

    SELECT SYSTEM_STATUS
    FROM APEX_PLSQL_JOBS
    WHERE JOB = :P1_JOB
    AND ANDUSER = :APP_USER
    AND SECURITY_GROUP_ID = :WORKSPACE_ID
    

    So you can make conditional button, selected example condition "NOT Exists (SQL query returns no rows)" and in the expression type:

    Select 1 from apex_plsql_jobs

    where employment =: P1_JOB

    and end user =: APP_USER

    and security_group_id =: WORKSPACE_ID

    and system_status in ("in PROGRESS", "SUBMITTED")

    If you must run the job for the user, then button will not be returned.

  • Variable effects with Loop function.

    I need to create a code that take the following strings:

    
    "Scale"
    "Position"
    "Side"
    
    
    
    
    
    
    
    
    
    
    
    

    And each of them, put in a copy of this code:

    thisComp.effect(!!!STRING HERE!!!)("Layer").name;
    
    
    
    
    
    
    
    
    
    

    And after that, the three variables, each one, receive a complete code.

    
    var a;
    var b;
    var c;
    
    
    
    
    
    
    
    
    
    
    
    

    The result would be this:

    
    var a = thisComp.effect("Scale")("Layer").name;
    var b = thisComp.effect("Position")("Layer").name;
    var c = thisComp.effect("Side")("Layer").name;
    
    
    
    
    
    
    
    
    
    
    
    
    

    I try to do it like this:

    var strings = ["Scale", "Position", "Side"];

    var val = function (a, b, c) {}

    for (var i= 0; I <channels.length; i ++) {}

    effectof the var = thisComp.effect () ('Layer') .namestrings[i];

    Val (effect);

    }

    }

    But don't have experience with functions and loops For.


    And not whether it is the right way to do it.

    I need to do this because my code becomes too long for many repetitions.

    I think for this, will have to use loop and the function.

    Thank you.

    You might have better luck if you describe what it is you are trying to do, rather than how you try to do, because it is not obvious (to me at least) exactly what your code is supposed to accomplish.

    Dan

  • Helps the function of class of SMTP with authentication

    My server no longer supports the php mail() feature.  I need to use the SMTP class with the authentication function in my php code, and they suggested this to replace it: on-with-authentication-in-php-code http://www.yrhostsupport.com/index.php?/Knowledgebase/Article/View/101/2/smtp-class-functi

    So, I tried, but cannot make it work. This is my test form:

    < are method = "post" action = "forms/sendmail - test2.php" onsubmit = "return checkEmail (this);" >

    < script type = "text/javascript" language = "JavaScript" >

    < /script >

    < fieldset > < legend > news < / legend >

    < Label > name < / label >

    < input type = "text".

    name = "name" size = "30" maxlength = "40" / > < br / >

    < label > < span class = 'redText' > * </span > Email < / label >

    < input name = "email" type = "text" size = "30" maxlength = "40" / >

    < br / >

    < label > < span class = 'redText' > * </span > Message < / label >

    < textarea cols = "40" rows = "5" name = "message" type = "text" / > < / textarea > < br / >

    < / fieldset >

    < input type = "reset" value = "Reset" / >

    < input type = value = "submit" / >

    < / fieldset >

    < / make >

    It's sendmail - test2.php where going to the form. It will not be sent unless I have comment on the first 10 lines.

    <? PHP

    include ('Mail.php');

    //$to = " [email protected] "; "

    $name = $_REQUEST ['name'];

    $email = $_REQUEST ['email'];

    $message = $_REQUEST ['name'];

    $headers = "from: $email";

    $subject = "price quote";

    $fields = array();

    $fields {'name'} = 'Name ';

    $fields {'email'} = 'Email ';

    $fields {'message'} = 'Message ';

    $recipients = ' [email protected] '; //CHANGE

    $headers ['from'] = ' [email protected] '; //CHANGE

    ["to"] = $headers ' [email protected] '; //CHANGE

    $headers ['subject'] = 'Test Message';

    $body = "test message";

    Set the SMTP settings

    $params ['host'] = "levy.dnsbox25.com";

    $params ['port'] = '25';

    $params ["auth"] = "PLAIN";

    $params ["username"] = ' [email protected] '; //CHANGE

    $params ["password"] = "xxxxxx"; CHANGE

    / Next option allows the SMTP debug and will print the SMTP Protocol

    conversation on the page, it will help only with authentication problems. */

    $params ['debug'] = 'true ';

    Create the mail object using the Mail::factory method

    $mail_object = & Mail::factory ('smtp', $params);

    Print the parameters you use for the page

    {foreach ($params as $p)

    echo "$p < br / > ';

    }

    Send the message

    $mail_object-> send ($recipients, $headers, $body);

    ? >

    It used to work well when I used

    $send = mail ($ $subject, $body, $headers);

    $send2 = mail ($from, $subject2, $autoreply, $headers2);

    But they said I can't use it anymore. I'm good with HTML and CSS, but I don't know much about php. Thanks for any help integrating one of in this new code!

    It is to be expected. When you assign a value to a variable that was already assigned, you replace the previous value. You must add. Try this

    $body = "name:". "." $name. "\r\n". "e-mail:". "."  $email. "\r\n". $message

  • Helps blur function

    I just come to terms with the help of first 12 items to edit my videos. I used the blur function to disseminate background images which divert the relevant parts of my video. However, when I visited the finished project to save to my computer and burn to a DVD, the blurred parts appear in the wrong part of my video and interfere with the parts that I DON'T want to keep. Can someone tell me what I am doing wrong?

    KCP1954

    Thanks for the details that I found very useful. I am familiar with the approach, but have not seen this particular video tutorial you mention. But I'll watch it all the same when I do a run through of what you described.

    What predefined project that you use for your project?

    Once I know the predefined project used, I'll give you what you have described a run through to determine all vulnerable points which would result in the issue of the export.

    Thank you.

    RTA

  • Need help: loop of pl/sql with UTL_FILE reading and analysis of file text 2

    Hello, I am working on a new project using the UTL_FILE utility in oracle 11 g. and I was wondering if someone could help me with a pl/sql code, I can't understand.
    My goal is to open and then read a Type_de_fichier file1.txt
    copy a specific paragraph of the file1.txt where
    the first word in a specific line in the file1.txt starts with "foo" then when the last word in fichier1.txt ends in 'ZEN'
    write to file2.txt only the analysis section in my where statement.
    I don't know if it's possible, but any guidance will greatly appreciate!

    My code example:

    CREATE OR REPLACE PROCEDURE my_app2 IS
    Utl_file.file_type inFile;
    OutFile utl_file.file_type;
    buffer VARCHAR2 (30000);
    BEGIN
    -Open a file to read
    InFile: = utl_file.fopen ('TEST_DIR', 'mytst.txt', 'r');
    -Opens a file for writing
    OutFile: = utl_file.fopen ('TEST_DIR', "Out.txt", "w");

    -Check the file is open
    IF utl_file.is_open (InFile) THEN
    -lines in the file in loop
    LOOP
    BEGIN
    UTL_FILE.get_line (InFile, buffer);
    -Write to out.txt
    UTL_FILE.put_line (OutFile, buffer, FALSE);
    UTL_FILE.fflush (outfile);

    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    END IF;
    UTL_FILE.fclose (INFILE);
    UTL_FILE.fclose (outfile);
    EXCEPTION
    WHILE OTHERS THEN
    RAISE_APPLICATION_ERROR (-20099, "UTL_FILE Unknown Error");
    END my_app2l;
    /

    Hello

    According to the code should work-

    CREATE OR REPLACE PROCEDURE my_app2 IS
       infile              utl_file.file_type;
       outfile             utl_file.file_type;
       buffer              VARCHAR2(30000);
       b_paragraph_started BOOLEAN := FALSE; -- flag to indicate that required paragraph is started
    BEGIN
       -- open a file to read
       infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
       -- open a file to write
       outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
    
       -- check file is opened
       IF utl_file.is_open(infile)
       THEN
          -- loop lines in the file
          LOOP
             BEGIN
                utl_file.get_line(infile, buffer);
    
                IF buffer LIKE 'foo%' OR b_paragraph_started
                THEN
                   --write to out.txt
                   utl_file.put_line(outfile, buffer, FALSE);
                   b_paragraph_started := TRUE;
                END IF;
    
                IF buffer LIKE '%ZEN'
                THEN
                   b_paragraph_started := FALSE;
                END IF;
                utl_file.fflush(outfile);
    
             EXCEPTION
                WHEN no_data_found THEN
                   EXIT;
             END;
          END LOOP;
       END IF;
       utl_file.fclose(infile);
       utl_file.fclose(outfile);
    EXCEPTION
       WHEN OTHERS THEN
          raise_application_error(-20099, 'Unknown UTL_FILE Error');
    END my_app2l;
    /
    

    What I've done here is added a new Boolean variable. Loop in each iteration after reading one line, we check if the line starts with "foo". If yes then set the Boolean variable and writing out the startup file until we get a line that ends with "ZEN." That way even if there are several paragraphs in an input file starting with foo and ending with ZEN, then those should get copied to the output file.

    Hope this helps,

    -Gregory

  • Hide all subforms by using a loop function

    Hello

    I have a base control that displays or hides a subform if a box has been checked or not.

    If (checkbox.rawValue == 1) {}

    This.Presence = "visible";

    }

    else {this.presence = "hidden":}

    }

    Now, this check box controls the visibility of several subforms, so I would have a function in a script object that I can call each subform calculate event.

    I named the script object "common good".  At first, I tried just an if/then statement as above, but "this" is meaningless in function.

    So I resorted to the creation of a loop.  I tried to do a test loop to hide all subforms, but it does not work.   Once I have run, I can add an if/else statement that allows to hide currentElement if the box is checked, but for simplicity I didn't at that point.

    Any tips?  I derived this loop an example for the mistakes of control loop of Niall O'donovan.

    function HideSubforms (myParentObject) {}

    Declaring variables

    var allChildElements;

    var intNumElements;

    var currentElement;

    var i;

    Get all children nodes of the parent element

    allChildElements = myParentObject.nodes;

    Total number of items in the object

    intNumElements = allChildElements.length;

    Loop through all child elements

    for (i = 0; i < intNumElements; i ++) {}

    currentElement = allChildElements.item (i);

    If (currentElement.className = "subform") {}

    currentElement.presence = 'hidden ';

    }

    }

    } / / End of the function

    You must pass the subform to root as an argument to this function.

    Common.HideSubforms (this.parent.parent);

    On my screen, I was calling this function on the initialize event of the TextField1 inside Subform2.

    I need to go (Page1) rootnode property to this function to work.

    Thank you

    Srini

  • Help looping

    So, I have a function that draws a polygon size and any shape. I have a loop that draws a simple polygon. How can I do so that when he finishes this polygon, it starts a new one at a different angle. I have to be able to repeat the loop according to entry number for rehearsals. So if I have 5 entry he draws the polygon 5 times each different angles to each other, but each from the same Center (making what looks like a flower thing).

    the easiest way would be to use the new property a graphical object each time, and assign to the rotation property of the object i * 360 / Number (input_tf.text)

  • Help unload function

    I have a video training where I load another swf via a pop-up version. I have a button in the loaded swf where I need to unload and return to the video background popup. Im not very experienced in flash and have not build myself a bit lost if im. below is code first in my video background and then the code in my loaded swf file. I hope someone can help. The bits highlighted are those where I tried to have the swf to unload

    Video backgrounds:

    Import VideoBg;

    videos of the var: Array = new Array('videos/bird_short.f4v','videos/kanin.f4v');

    var num:uint = 1;

    var vid:VideoBg = new VideoBg (videos [index]);

    var int index = videos [Math.floor (Math.random () * videos.length)];

    addChild (vid);

    setChildIndex(vid,0);

    videobtn.buttonMode = true;

    Pictures.Visible = true;

    videobtn.addEventListener (MouseEvent.CLICK, toggleVideoF);

    function toggleVideoF(e:MouseEvent):void {}

    index = (index + 1) %videos.length;

    vid.playF = videos [index];

    videobtn.gotoAndStop (index + 1);

    }

    stage.scaleMode = StageScaleMode.NO_SCALE;

    internship. Align = StageAlign.TOP_LEFT;

    stage.addEventListener (Event.RESIZE, position);

    stage.addEventListener (MouseEvent.CLICK, startIgen);

    position (null);

    function position(Event=null):void {}

    var SH = stage.stageHeight;

    var SW = stage.stageWidth;

    }

    MinKnap.addEventListener (MouseEvent.CLICK, MinFunktion);

    function MinFunktion(e:Event):void {}

    e.stopImmediatePropagation ();

    VID.ns.pause ();

    MinKnap.visible = false;

    videobtn. Visible = false;

    popUp ('start2.swf', 'swf', null, 900, 700, 0);

    }

    pictures.addEventListener (MouseEvent.CLICK, picturesFunktion);

    function picturesFunktion(e:Event):void {}

    e.stopImmediatePropagation ();

    VID.ns.pause ();

    MinKnap.visible = false;

    videobtn. Visible = false;

    Pictures.Visible = false;

    popUp ('gallery_rabbit_picture.swf', 'swf', null, 900, 700, 0);

    }

    function startIgen (Event): void {}

    MinKnap.visible = true;

    videobtn. Visible = true;

    Pictures.Visible = true;

    VID.ns.Resume ();

    }

    function popUp(con,typ,tit=null,wid=550,hei=400,alp=0.7):void {}

    ExternalInterface.call("saveglobalscore",score) ("Shadowbox.open", {content: con, player: type, title: chickadee, width: wid, height: hei, options: {overlayOpacity:alp}});}})

    }

    function unloadFunction_rabit_gallery(event:Event):void {}

    popUp.unload ();

    MinKnap.visible = true;

    videobtn.visible = true;

    pictures.visible = true;

    vid.ns.resume ();

         }


    popUp.addEventListener ("UnloadMe", unloadFunction_rabit_gallery);

    Loaded SWF:

    back03_btn.addEventListener (MouseEvent.Click, back_rabit)

    function back_rabit(event:MouseEvent):void

    {

    MovieClip (parent.parent) .gotoAndStop ("frontpage2")

    parent.dispatchEvent (new event ("UnloadMe", true));

    }

    I do not use shadowbox but it seems that you use javascript to open this popup, so you'll need to use javascript to close.   take a chance and try:

    back03_btn.addEventListener (MouseEvent.Click, back_rabit)

    function back_rabit(event:MouseEvent):void

    {   

    ExternalInterface.call("saveglobalscore",score) ("Shadowbox.close");

    }

        

    }

  • How to do a loop function?

    I looked through the documentation on a loop, but I do not understand.  I'm doing this function loop, until the user stops it:

    function playMusic(evt:MouseEvent):void
    {
    Channel.Stop (); to prevent users to start the file several times above the other - is there a better way to do it?
    Channel = myMusic.play (songPosition);
    myTimer.start ();
    }

    I'm new to flash, as well as near terms of wailing as possible would be appreciated.

    I have a crew a bit. The main thing was to listen to the SOUND_COMPLETE event. So, here's something that works mainly (I tested) - just pasted the code like this:

    stop();
    import flash.events.MouseEvent;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.media.SoundChannel;
    import flash.media.SoundTransform;
    import fl.events.SliderEvent;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.media.SoundLoaderContext;
    import flash.events.Event;
    
    var soundFile:URLRequest = new URLRequest("1.mp3");
    var soundFile1:URLRequest = new URLRequest("2.mp3");
    
    var song:Sound;
    var channel:SoundChannel;
    
    var s_Transform:SoundTransform = new SoundTransform();
    var myTimer:Timer = new Timer(250);
    myTimer.addEventListener(TimerEvent.TIMER, updateTime);
    
    var songPosition:Number = 0;
    var myContext:SoundLoaderContext = new SoundLoaderContext(5000);
    
    // both buttons call the same function
    btn_play.addEventListener(MouseEvent.CLICK, playMusic);
    btn_play1.addEventListener(MouseEvent.CLICK, playMusic);
    btn_stop.addEventListener(MouseEvent.CLICK, stopMusic);
    sld_volume.addEventListener(SliderEvent.CHANGE, changeVolume);
    btn_pause.addEventListener(MouseEvent.CLICK, pauseMusic);
    
    function pauseMusic(e:MouseEvent):void {
         myTimer.stop();
        songPosition = channel.position;
        channel.stop();
    }
    
    function onSoundComplete(e:Event):void {
         channel = song.play(0);
    }
    
    function convertTime(ms:Number):String {
        return new Date(ms).toUTCString().replace(/(\w+\s){2}+\d+\s{1}\d+\:|\s\d+\s\w+/g, "");
    }
    
    function updateTime(e:TimerEvent):void {
        LBL_songtime.text = convertTime(channel.position);
    }
    
    function getSongLength(e:Event):void {
        LBL_songtotal.text = convertTime(song.length);
    }
    
    function changeVolume(e:SliderEvent):void {
        s_Transform.volume = sld_volume.value;
        channel.soundTransform = s_Transform;
    }
    
    function stopMusic(e:MouseEvent = null):void {
         myTimer.stop();
         if(channel) channel.stop();
         songPosition = 0;
    }
    
    function playMusic(e:MouseEvent):void {
         stopMusic();
         song = new Sound();
         switch(e.currentTarget) {
              case btn_play:
                   song.load(soundFile, myContext);
              break;
    
              case btn_play1:
                   song.load(soundFile1, myContext);
              break;
         }
         channel = song.play(0);
         channel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
         myTimer.start();
    }
    
    txt_area.htmlText = "

    testing

    ";
  • Need help timed function

    Hello world.

    I'm trying to figure out how to perform a function after 5 seconds.

    What I'm trying to do is make a list drop-down text after a defined time period.

    Here is my code so far:

    Code:
    import fl.transitions.easing.*;
    import fl.transitions.Tween;

    var myText:TextField = new TextField();
    var myFormat:TextFormat = new TextFormat();
    var dropText:Tween;
    var dropTextTimer:Timer = new Timer(5000, 2);
    addChild(myText);

    myFormat.size = 14;
    myFormat.color = 0x0000FF;
    myFormat.font = "Helvetica";

    myText.text = "Hello World";
    myText.autoSize = TextFieldAutoSize.LEFT;
    myText.setTextFormat(myFormat);


    dropTextTimer.addEventListener(TimerEvent.TIMER_COMPLETE, dropTextFunc);
    dropText = new Tween(myText,"y",Bounce.easeOut,myText.y,200,5,true);

    function dropTextFunc(event:TimerEvent):void
    {
         dropText;
    }

    At present the text falls as soon as it is loaded.

    Any help would be great

    Thank you

    use:

    Code:
    import fl.transitions.easing.*;import fl.transitions.Tween;
    
    var myText:TextField = new TextField();var myFormat:TextFormat = new TextFormat();var dropText:Tween;var dropTextTimer:Timer = new Timer(5000, 1);addChild(myText);
    
    myFormat.size = 14;myFormat.color = 0x0000FF;myFormat.font = "Helvetica";
    
    myText.text = "Hello World";myText.autoSize = TextFieldAutoSize.LEFT;myText.setTextFormat(myFormat);
    
    dropTextTimer.addEventListener(TimerEvent.TIMER, dropTextFunc);dropTextTimer.start();
    
    function dropTextFunc(event:TimerEvent):void{     dropText = new Tween(myText,"y",Bounce.easeOut,myText.y,200,5,true);}
    

Maybe you are looking for