Using LoadVars sendAndLoad instead of WebService when calling web services with Flash ActionScript

by filip 14. August 2008 17:53

I've ran into issues using the WebService object in Flash.  The thing is incredibly buggy.  In certain cases, it works just fine, but in other cases, it flat out does not work. In my last case, the web service loaded perfectly fine (onLoad was called), but the PendingCall would not return anything.  The onFault method was never called after I invoked my web service call, but the web service never returned either.  Examining the outgoing messages from Flash (using HTTP headers in Firefox) revealed that Flash was never even attempting to call the web service.  Flash did correctly acquire the crossdomain.xml file (which allowed access from all domains), and it did load the WSDL.  But, for whatever reason, it did not call the web method like it was supposed to.

Well, after a few hours or attempging to make this work, I gave up with the WebService object.  Instead, I went to the LoadVars object, something I'm more confident in than the WebService class, simply due to the fact that it has been around much longer and has had more attention from the Adobe / Macromedia team.

Using the WebService object, my code looked like the following:

var _wsdl:String = "http://www.bloodforge.com/webservice.asmx?WSDL"; // <- this is fake for the purpose of this blog 
var MailService:WebService = new WebService(_wsdl);
MailService.onLoad = function()
{
  var MailServiceResult:PendingCall = MailService.MyMethod("my parameters");
  MailServiceResult.onFault = function(fault)
  {
    trace("it never gets here even though it fails!");
  }
  MailServiceResult.onResult = function(result)
  {
    trace("it never got here either!");
  }
}

The above was replaced with the code below, and it works perfectly fine:

var result_lv:LoadVars = new LoadVars();
result_lv.onData = function(responseStr:String)
{
  if(responseStr == undefined)
  {
    trace("Error occurred!");
  }
  else
  {
    trace("Success... parse my data below...");
  }
}
var send_lv:LoadVars = new LoadVars();
send_lv.myWebServiceParam1 = "param 1";
send_lv.myWebServiceParam2 = "param 2";
send_lv.sendAndLoad("http://www.bloodforge.com/webservice.asmx/MyMethod", result_lv, "POST");

 
Oh, and make sure that if you do this with your web service, that you have the following line in your web.config file.  Otherwise, you won't be able to access it using these methods (you should be familiar w/ it anyways if you use Ajax to call web services).

<webServices>
  <
protocols
>
    <
add name="HttpGet"
/>
    <
add name="HttpPost"
/>
  </
protocols
>
</
webServices>

Tags: , ,

Web Development

Can electronic drums be classified as drums?

by filip 22. July 2008 02:12

We had a rather silly argument at work today. A co-worker claimed that electronic drums are not drums, but something entirely different. Now, I generally don't post about all the silly arguments we have at work (there's a new one every day it seems), but this one just is way over the top in my mind.

My first method of argument was, basically, that the term "electronic" (or electric, I consider those to be the same in this particular context) is simply an adjective that describes something.  So, just like all red robins are a subset of robins, electronic drums are a subset of drums.  However, this was not satisfactory, and the co-worker brought up the term "straw man".  He stated that a straw man is not actually a man.  Fine, I'll give him this, although it is certainly a rather weak argument since the context must be entirely different for this to be valid.

Next up was dictionary.com's definition of a drum (his source, not mine, but I'm more than happy to work with that).  There are several definitions for drums on that page, but my co-worker decided that the first one must be used (never mind the fact that if we took the first definition of "straw man" would actually mean that "straw man" are a subset of "men"*).  Well, electronic drums fit basically the entire definition, with one possible exception: with a tightly stretched membrane, or head.  Now, if you would assume that a drum head must be a tightly stretched membrane, then that definition would exclude electronic drums.  However, that's a rather silly assumption.  I suppose that would mean that the drum heads that guitar center sells for electronic drums must be imaginary - or something like that.  Not to mention that many other drums, such as slit drums, log drums, etc, would not actually be drums.

Why is it so important to exclude every other definition of a drum other than the first one from dictionary.com?  Because if you were to take other definitions into account, electronic drums would most certainly be covered.  There are also other places that support the concept that drums are not simply something that must have a membrane, but instead may be something which is designed to resemble a drum. But, of course, these definitions must be ignored for some reason.

There's a very good saying that's worth bringing up: If a bird looks like a duck, swims like a duck and quacks like a duck, then it probably is a duck. Apply that to electronic drums, and its pretty obvious if they're drums or not.

 * note to self: in the future, when someone randomly decides to pick certain definitions out of a dictionary and randomly rejects others, just stop the argument there, because it will go nowhere

Tags:

Work Discussions

nJoy Electronic Cigarette Review (Part 2)

by filip 15. July 2008 02:21

It has been 6 days since my nJoy Electronic Cigarette Review (Part 1). My biggest complaint in that review was the price of the refill cartiges.  Thanks to some help from very kind people at the e-cigarette-forum.com, I found out that e-liquid (smoke juice, whatever you want to call it) is actually available for purchase.  A couple sites that offer it, such as ePuffer and e-cig; however, both were out of stock (after researching this some more, I found out that e-cig.com has temporarily suspended shipping due to the Olympics and tightened security for sending liquids - they're based in China).  Well, fortunately, we have eBay, and I was able to purchase my very first bottle of the liquid.

njoy2 
My smoke juice refill station

I've taken a picture (courtesy of my brand new Nikon D40 ) of the whole setup.  Basically, refilling was pretty simple.  I just put on some latex gloves, took out the little filter-like things and put some liquid on them.  I tried not to put too much, because I certainly don't want to be drinking the stuff as it could possibly leak through the little hole.  Just make sure you do this on something that doesn't stain, as this stuff doesn't look like it would come out easily.  Granite countertops worked just fine for me.  After refilling the cartiges, I just wiped off the mouthpiece and placed the refills into the little cases that they originally came in.

As for the electronic cigarette itself, I've found that the high nicotine cartiges work best for me.  Keep in mind, I'm not all that into nicotine - I've gotten poisoned from patches before - but the medium and low refills just don't have that much at all.  Also, the claim that these things last as long as a pack of cigarettes is rather silly.  I go through more than one of these per day, and I didn't even smoke a pack of cigs that quickly.  Theoretically, I suppose it is possible for these to last for that long, but it would just not be enjoyable to try to get that last puff of smoke from a cartige (something that does seem to work is flipping the filter insert around when smoke starts to decrease, but it still doesn't last too long after that).

When I started this little adventure, I had about half a pack of cigarettes left.  I've basically cut down to 1-2 cigs per day, and I ran out of smokes two days ago.  I haven't really had the need to buy another pack, as this electronic cigarette is doing its job for me so far.  I have noticed that my smoking habits are slightly different than before with the electronic cigarette, however.  Whereas before I would generally smoke at some intervals (like once every 90 min or so), I find myself taking a few puffs of this cigarette every 10-20 min.  So, basically, not as much at once, but since this doesn't burn out, there's nothing I need to "finish".

In a week and a half I'll be going to Europe for a couple weeks for vacation.  I don't have a charger for this thing that works with European plugs + voltage, so I'm kind of hoping that I can take this thing on the plane, and then I can use my spare battery for the trip back.  While abroad, I'll just buy my cigarettes over there. I feel kind of comfortable doing that considering how easy it was for me to basically cut down (and maybe even stop) smoking real cigarettes in the last few days.  Also, my favorite cigarettes are sold everywhere over there (L&M Lights), and I can't find these anywhere where I live in Cincinnati.

Tags:

Personal

nJoy Electronic Cigarette Review (Part 1)

by filip 9. July 2008 15:37
 njoy1
from left to right: Marlboro Ultra Light 100, pen, nJoy cigarette, pencil

A week or so ago I ordered the nJoy electronic cigarette.  I've tried to quit smoking before, and although I had no problems stopping (apart from the 1-2 day nicotine withdrawal), I've always felt like starting up again because the thing I was really addicted to doing was the action of smoking.  Well, over lunch one day I heard someone talking about electronic cigarettes, so I decided to look it up.  The fact that these seem to be relatively harmless (no tobacco, tar, carcinogens, etc.) was very appealing, and I could fulfill my desire to actually inhale something. In the past, I've tried nicotine patches (I actually got poisoned from one), but as I pointed out before, the thing I miss most when I stop smoking is the actual action of smoking, not the nicotine itself, so, needless to say, the patch didn't work.

After doing some reading online, I decided on ordering the nJoy cigarette and a pack of medium refills. The first thing that really struck me was how big this thing was.  I've taken a picture of the device with some things to compare it to, since I didn't really find that anywhere online before I placed my order.

Apart from the size, the other thing I didn't really like was my color choice.  If I were to order again, I would probably choose the black model.  When I ordered, I thought I would get white since it would match the white Marlboro Ultra Lights 100s that I smoked.  Well, since this thing doesn't even closely resemble a cigarette, I would suggest going with the black instead.  But, of course, everyone has their own preferences.

Besides the looks of this thing, I do have to say I'm pretty pleased with it.  It actually gives you the sensation of smoking, and the fact that I can do it indoors without bothering anyone is a very nice plus.  I still like to go outside and "smoke" sometimes since it provides a nice break from the desk, but at least when it is raining (and in the winter, when it is cold), it is good to know that I can remain indoors.

The taste of the smoke is not too different from the Ultra Lights I smoked, but that's really not saying much, since these certainly lack the taste of stronger cigarettes.  I haven't tried the "High" refill yet ( my nJoy package came with a high, medium, low, and "no" nicotine refill), so I can't really comment on the taste of that, but I can say that if you smoke Marlboro Ultra Lights (or anything similar), you probably won't be terribly disappointed with the taste.  It isn't exactly the same, but it certainly is a better replacement than nothing.

 

I've gone back to my cigarettes a few times, mostly out of habit, but I can see myself quitting smoking actual cigarettes by using this as a replacement.  It, in my opinion, is a suitable alternative to smoking if your addiction was to doing something with your hands and inhaling smoke.

My biggest complaint with the nJoy cigarette is the price of the refills.  Although they try to make it slightly less than buying regular cigarettes, it still seems like a rip-off.  Basically, the refill consists of the mouthpiece, along with some cotton (or plastic fibers, I'm not sure what it is) soaked in their nicotine-containing substance.  There's really no reason why we shouldn't be able to purchase a bottle of this substance and do our own refills this way.  There would be several advantages to doing this, such as being able to adjust the taste ourselves, and of course the price.  Since there isn't too much liquid in each refill, a bottle should last for a very long time, and it could come out to be significantly cheaper than paying $25 for a week's' worth of refills.

** UPDATE ** - nJoy Cigarette Review Part 2

Tags:

Personal

IE8 and AjaxControlToolkit - Visibility bug

by filip 18. June 2008 17:08

Well, I finally downloaded IE8 to see how some of the sites I've worked on behave.  Most things work just fine, however, I did find a pretty significant problem with the AjaxControlToolkit.

I've been using the Tab control quite a bit, and I noticed that, when switching between tabs, the new tab was not showing up.  The old tab was hiding, though... 

Debugging has led me to the setVisible method located in "Common/Common.js" in the AjaxControlToolkit.  Specifically, the problem existed in the following code:

if (element && value != $common.getVisible(element))
{
  if (value) 
  {
    if (element.style.removeAttribute)
    {
      element.style.removeAttribute("display"
);
    }
    else

   
{
     
element.style.removeProperty(
"display"
);
   
}
 
}
 
else
 
{
    
element.style.display
= 'none'
;
 
}
 
element.style.visibility
= value ? 'visible' : 'hidden';
}

In the above code, removeAttribute() was being called, but the display attribute remained (display=none).  I looked up the removeAttribute method, and it does return a boolean value indicating if the method was successful or not.  Well, as it turns out, the method (for whatever reason) is not successul in IE8!

I'm not sure why this fails in IE8, but it does cause a problem.  Fortunately, there's a pretty quick fix to this:

if (element && value != $common.getVisible(element))
{
  if
(value) 
  {
    if
(element.style.removeAttribute)
    {
            if(!element.style.removeAttribute("display"))
            {
               element.style.display
= ''
;
            }

    }
   
else
   
{
     
element.style.removeProperty(
"display"
);
   
}
 
}
 
else
 
{
    
element.style.display
= 'none'
;
 
}
 
element.style.visibility
= value ? 'visible' : 'hidden';
}

Tags: , ,

Web Development

About Filip Stanek

Death Note Pic I'm a developer at ACG in Cincinnati, OH. I like ASP.NET, Flash, and other web technologies, & enjoy playing chess, video games, etc.

Currently playing:
- StarCraft IIE-mail me Send mail

Disqus

Month List