A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] can't get setInterval to work with non set variables

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    resolved [RESOLVED] can't get setInterval to work with non set variables

    Good morning,

    I've spent hours trying to send a repeated message from my input text field and have finally noticed that it works if I use set variables rather than passing the contents of my input text.

    In my sending side I have:

    Code:
    modPanel_mc.awayMsg_btn.onRelease = function():Void 
    {
    	if (_parent.smartfox.amIModerator)
    	{
    		_parent.sendAwayMsg();
    
                     // This way the message is sent but it is only sent once
    		//_parent.intervalId = setInterval(_parent.smartfox.sendPublicMessage(modPanel_mc.modPanelMsg_txt.text), 3000);
                    // This way it works
    		_parent.intervalId = setInterval(_parent.sendAwayMsg, 60000);
    	}
    };
    in the receiving side:

    // The message I'd like to substitute with my own from the input text field in the sending side
    Code:
    var awayMsg:String = "BRB   Ara torno  Enseguida vuelvo";
    
    function sendAwayMsg()
    {
    	smartfox.sendPublicMessage(awayMsg);
    }
    I tried solving it using local connection to send the variables from my text filed apart before calling the sendAwayMsg function and I was able to send and retrieve them but not to run it continuously.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap,

    you don't need this bit "if (_parent.smartfox.amIModerator)" as you will only see the mod panel if you are a mod!!

    try
    PHP Code:
    modPanel_mc.awayMsg_btn.onRelease = function()
    {
        
    _parent.input_txt.text modPanel_mc.awayMsg.text;
        
    _parent.sendChatMsg();
        
    _parent.intervalId setInterval(_parent.sendAwayMsg60000);
    };

    function 
    sendAwayMsg()
    {
        
    input_txt.text modPanel_mc.awayMsg.text;
        
    sendChatMsg();
    }

    modPanel_mc.BackMsg_btn.onRelease = function()
    {
        
    clearInterval(_parent.intervalId);
    }; 
    this is using the normal sendChatMsg();

    you might want to lower the 60000 for testing purposes, save having to wait so long each time, then change it back when working

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