CS3 Help with action script needed!
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Help with action script needed!

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Location
    Atlanta, GA
    Posts
    5

    Help with action script needed!

    Hello people,

    I need a little help completing a project where one .swf will send forward and back commands to another .swf. These files will be running from a laptop where the control file is visible only to host on a laptop and the display file will be projected over a video system using an A B converter.

    This is just the start of this project and I am sure I will need some help with other options on the control panel as I design it.

    I will provide very simple .fla files for you to code and I will then place the code in the actual working files and test.

    I can afford to pay someone for this if it is not too expensive and will compensate this person more once the project is done and bringing in income!
    I can also trade graphic design work if desired.

    Anyone interested please contact me and I will send you the .fla files and please give me a price for your time!

    Thanks in advance for any and all help.

    Jim

  2. #2
    Is the best Alloy Bacon's Avatar
    Join Date
    Apr 2011
    Posts
    367
    What do you mean by forward and back commands just curious

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Location
    Atlanta, GA
    Posts
    5
    Quote Originally Posted by Basses6 View Post
    What do you mean by forward and back commands just curious
    Go forward one frame or back one frame

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,808
    I've posted the solution for you over at Actionscript.org, but here's my response anyways:

    Hi,

    If both are running on the same local computer, then this can be achieved with LocalConnection Class. In your first Flash file, have this on your Frame Actions:

    Actionscript Code:
    var sendMessage:LocalConnection = new LocalConnection();
    sendMessage.send("transferName", "onMessageReceived", "this message was sent");

    and on your Second Flash File, create a Dynamic Textfield, give it an instance name of, txt, and have this on your Frame Actions:

    Actionscript Code:
    var receiveMessage:LocalConnection = new LocalConnection();
    receiveMessage.onMessageReceived = function(theMessage){
        txt.text = theMessage; // will display 'the message was sent'
    }
    receiveMessage.connect("transferName");

    Make sure you first open the SWF Flash file with the textfield, and THEN the send SWF file, because the sending signal will only be sent once, and we want our receiving SWF file to be present when the signal is sent, to catch it.

    Now, how does this work? Well, let's break it down, firs the sending code (the first code). We are creating a new LocalConnection object called sendMessage, and then we're using LocalConnection's send() function to send a message. This send() function's parameters are comprised of, send(the signal name, the function's name, additional parameters)

    the signal name - this is important, and can be named whatever you want, because this is the unique ID of the signal you're sending. Whichever flash file which wants to receive the message, must specify the signal's name, because there are certainly other SWF file's open, and the signal can't be sent to every single one.

    the function's name - this is the function's name, which the receiving SWF file can receive and its corresponding parameters. Say, if you wanted to categorize your message sent to another SWF file, like, you'd like to send a color, a car, and a cake (sorry for lack of better example:P), then you could send 3 functions, one for each item.

    additional parameters - this is where the real message is sent, as the above function's parameters. Continuing on the bad example from above, you'd probably like to know what color, what car and what kind of cake was sent, so you send parameters with the function, which the receiving SWF can utilize.

    Let's create a new sending SWF from the bad example from the above explanation (lol:P). We'd like to send a color, a car's brand name and color, and a type of cake with its fruit topping and main content. Let's write the code:

    Actionscript Code:
    var sendMessage:LocalConnection = new LocalConnection();
    sendMessage.send("uniqueID", "getColor", "Green");
    sendMessage.send("uniqueID", "getCar", "Ferrari", "Red");
    sendMessage.send("uniqueID", "getCake", "Chocolate Cake", "Strawberries", "Chocolate");

    Now, let's move on to the receiving SWF, and while having 3 Dynamic Textfields with the instance names, txt1, txt2, txt3, let's write the receiving code on our Frame:

    Actionscript Code:
    var receiveMessage:LocalConnection = new LocalConnection();

    receiveMessage.getColor = function(theColor){
        txt1.text = "The sent color is: "+theColor;
    }

    receiveMessage.getCar = function(brandName, carColor){
        txt2.text = "I have a "+brandName+", and its color is "+carColor;
    }

    receiveMessage.getCake = function(cakeType, fruitTopping, mainContent){
        txt3.text = "I just baked a "+cakeType+", and decorated it with "+fruitTopping+" on top. Did you know that "+cakeType+" is coated with "+mainContent+"?";
    }

    receiveMessage.connect("uniqueID");

    So, we're creating a new LocalConnection instance, and then we're creating 3 functions in it, getColor, getCar, and getCake, the 3 functions we declared in our sending SWF, remember? In the brackets after the keyword, function, you declare the number of parameters sent for that particular function, and you can name them whatever you want. For instance, for getColor, we only sent 1 string, which was the color name, thus in the getColor function in our receiving SWF, we specify 1 parameter for the received color and we can name whatever we want it. Then, we can use the named parameter inside the function to refer to the sent value. In this case, we sent "Green" as the parameter's value, and in the receiving SWF, we've named that parameter, theColor. Now, in our getColor function, we can use, theColor, to refer to the sent string, which is "Green". If you created 3 textfield, then in the first textfield, you'll read, "The sent color is: Green". The same goes for the 2 other functions and their parameters.

    The last code tells the receiving LocalConnection instance that it will catch the signal named, uniqueID, and all of its sent messages (functions and their parameters).

    Hope this helps
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,808
    For your Forward and Backward problem, just use this for the sending SWF:

    Actionscript Code:
    var sendMessage:LocalConnection = new LocalConnection();

    // when you want to go forward on the other SWF
    sendMessage.send("uniqueID", "goForward");

    // when you want to go backward on the other SWF
    // sendMessage.send("uniqueID", "goBackward");
     

    and in the receiving SWF:

    Actionscript Code:
    var receiveMessage:LocalConnection = new LocalConnection();

    receiveMessage.goForward = function(){
        // it will go to next frame if goForward is sent from sending SWF
        nextFrame();
    }

    receiveMessage.goBackward = function(){
        // it will not go backwards automatically, this code will just be
        // executed if goBackward function is sent in the signal
        prevFrame();
    }

    receiveMessage.connect("uniqueID");
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  6. #6
    Junior Member
    Join Date
    Jul 2012
    Location
    Atlanta, GA
    Posts
    5
    Thank you!!! I will def try this later today... gotta design a bar menu this morning. Can you possibly send me working samples of this??? I would like to find someone to help me complete this project and I think we can def make some good money on an on going basis. I have 4 DJs waiting to use this as I type this!!!

  7. #7
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,808
    I made my own sample out of the example I posted, yesterday, here they are:

    SENDING FLA
    RECEIVING FLA

    Compile both of them so you have 2 SWF files, then go to your folder where the SWF files are, FIRST open the Receiving SWF, and then open the Sending SWF, this is important!!!
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  8. #8
    Junior Member
    Join Date
    Jul 2012
    Location
    Atlanta, GA
    Posts
    5

    This may work!

    That is pretty cool!!! See if you can take the following fla files and have one move the other forward and back.

    http://www.jukebox-mobiledj.com/control.rar

    http://www.jukebox-mobiledj.com/display.rar

    Do you have a PayPal account??? I don't believe in anyone doing what they are good at for free!

  9. #9
    Junior Member
    Join Date
    Jul 2012
    Location
    Atlanta, GA
    Posts
    5
    You can see a couple screen shots of the Trivia Module at http://www.jukebox-mobiledj.com/ also.

  10. #10
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,808
    Hi,

    I was busy for a week or so, so I haven't been able to check your file before today, but it seems like they've been removed. Would it possible for you to re-upload them?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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

Poll by Flashkit.com