A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Can someone evaluate this for me?

  1. #1
    Senior Member
    Join Date
    May 2006
    Posts
    119

    Can someone evaluate this for me?

    with this script I am hoping to be pushing the variable "tile" that is being created with the sound "I" attached to it on press to and array called "soundSeq"
    Then with another MC acting as a button, play the contents of the array as Audio.
    This script IS pushing the variable to the array, but when the "playBTN" MC is released it does not play any audio.
    the sound "I" is in my library and it has the linkage name of "I" it plays on press. I just dont know how to make an array play...

    any thought??

    soundSeq = Array();

    _root.ball1.onPress = function (){
    startDrag(ball1);
    var tile = new Sound();
    tile.attachSound("I");
    tile.start();


    }
    _root.ball1.onRelease = function (){
    stopDrag();
    if(this.hitTest(_root.drop1)){
    soundSeq.push("tile");
    trace(soundSeq);
    trace("test");
    }
    }

    _root.playBTN.onRelease = function (){
    for (z=0; z<soundSeq.length.start();++z){//this probably isnt right
    }
    }


    regards

    Mark Hollas

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    to test your code, i have -
    movieclip - ball1
    button - playBTN
    linked sound - I
    and code -
    Code:
    soundSeq = new Array();
    
    _root.ball1.onPress = function (){
    this.startDrag(true);
    tile = new Sound(); // don't use var here / traps the scope
    tile.attachSound("I");
    tile.start();
    };
    
    _root.ball1.onRelease = function (){
    stopDrag();
    //if(this.hitTest(_root.drop1)){ // removed for testing
    soundSeq.push(tile);
    trace(soundSeq); // [object Object]
    //}
    }
    
    playBTN.onRelease = function (){
    for (z=0; z<soundSeq.length;z++){
    soundSeq[z].start(); // plays sound linkage - "I"
    }
    }
    
    /* List Variables shows -
    Variable _level0.soundSeq = [object #1, class 'Array'] [
        0:[object #2, class 'Sound'] {
          id3:[getter/setter] undefined,
          duration:[getter/setter] 4180,
          position:[getter/setter] 3808
        }
      ]
    */

  3. #3
    Senior Member
    Join Date
    May 2006
    Posts
    119

    Thank you.

    however, for some reason It will not release the drag, it just stays locked to the cursor.


    also I have a few questions
    //if(this.hitTest(_root.drop1)){ // removed for testing
    I still need this right? to achieve what I want from my app.

    and

    /* List Variables shows -
    Variable _level0.soundSeq = [object #1, class 'Array'] [
    0:[object #2, class 'Sound'] {
    id3:[getter/setter] undefined,
    duration:[getter/setter] 4180,
    position:[getter/setter] 3808
    }
    ]
    */
    this is commented out, but what is it? and do I need to un comment it?

    sorry...im not very AS saavy yet..

    Thanks again

    Mark

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    also I have a few questions
    //if(this.hitTest(_root.drop1)){ // removed for testing
    I still need this right? to achieve what I want from my app.


    so re-include it to your project. Remember I am only testing syntax

    this is commented out, but what is it? and do I need to un comment it?

    this is not Actionscript .. do NOT uncomment .. you will get errors
    this is the result of - Test Movie / List Variables
    Suggest you use this OFTEN to display the output from your movie

  5. #5
    Senior Member
    Join Date
    May 2006
    Posts
    119
    OK!!! I made it work.
    I was really close wasnt I..

    now I have a one more question if you or anyone would be so kind.

    I have 5 more droptargets each will have its own array. I want to play the array sound in a sequence when the button is presses.

    now, I am going to have about 50 objects to drag around and place on any drop target. the code could get real long here, is what im getting worried about. what would you suggest? is there any way to shorten this?

    I did add a array.pop so it when you clear the screen the array will reset ( i hope)

    thanks

    Mark

  6. #6
    Senior Member
    Join Date
    May 2006
    Posts
    119
    a_modified_dog, There is something I dont understand. I have been staring at this code that you corrected for me, but I have no clue as to why when "soundSeq" is traced, does it produce [object, Object] and not "tile"
    also, when I try to make a second if statement re-using the code but pushing to a different array, it doesnt work.... very confused. Im wondering if you could explain to me what you did. Thank you

  7. #7
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    why when "soundSeq" is traced, does it produce [object, Object] and not "tile"
    because you are pushing a sound object to the array ( clearly visible is you use List Variables, as in the example I gave )
    Code:
    /* List Variables shows -
    Variable _level0.soundSeq = [object #1, class 'Array'] [ // here is the array
    0:[object #2, class 'Sound'] { // here is the sound object
    id3:[getter/setter] undefined, // and its properties
    duration:[getter/setter] 4180,
    position:[getter/setter] 3808
    }
    ]
    */
    a second if statement re-using the code but pushing to a different array, it doesnt work
    can you show the exact code you have used

  8. #8
    Senior Member
    Join Date
    May 2006
    Posts
    119

    Thanks again

    OK, I think I understand that.. as mentioned before, im not very good with scripting yet..
    here is the script im working on. I will also include the .fla so you can get an idea of whats happening.
    ----------------------------------
    soundSeq = new Array();
    soundSeq1 = new Array();
    soundSeq2= new Array();
    soundSeq3= new Array();
    soundSeq4= new Array();

    _root.ball1.onPress = function (){
    startDrag(ball1);
    tile = new Sound();
    tile.attachSound("I");
    tile.start();
    };

    _root.ball1.onRelease = function (){
    stopDrag();
    if(_root.ball1.hitTest(_root.drop1)){
    soundSeq.push(tile);
    }
    if(_root.ball1.hitTest(_root.drop2)){
    soundSeq2.push(tile);
    }
    if(_root.ball1.hitTest(_root.drop2)){
    soundSeq3.push(tile);
    }
    if(_root.ball1.hitTest(_root.drop2)){
    soundSeq4.push(tile);
    }
    if(_root.ball1.hitTest(_root.drop2)){
    soundSeq5.push(tile);
    } else soundSeq.pop();
    }

    _root.ball2.onPress = function (){
    startDrag(ball2);
    tile2 = new Sound();
    tile2.attachSound("need");
    tile2.start();
    };
    _root.ball2.onRelease = function (){
    stopDrag();
    if(_root.ball2.hitTest(_root.drop1)){
    soundSeq.push(tile2);
    } else soundSeq.pop();
    }

    playBTN.onRelease = function (){
    for (z=0; z<soundSeq.length;z++){
    soundSeq[z].start();
    break;
    }
    for (z=0; z<soundSeq.length;z++){
    _2soundSeq[z].start();
    }
    }
    Attached Files Attached Files

  9. #9
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    "Unexpected File Format" on trying to open your .fla
    in MX version 6. Can you save as a Flash 6 file ?

  10. #10
    Senior Member
    Join Date
    May 2006
    Posts
    119
    sorry about that.
    Attached Files Attached Files

  11. #11
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try this file.
    some comments within.
    I'm working now till midnight.
    Back tomorrow

  12. #12
    Senior Member
    Join Date
    May 2006
    Posts
    119
    Millions of thanks! wow, it was exactly what I was looking to do....
    took me a week to get nowhere and you...just a matter of hours. Amazing

    Guess I will have to learn more!

    Thanks again!

    Mark Hollas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center