Installation Error: APIInternalError

I know I know, Flash is dying. Sadly Adobe announced the end of life for Flash Player, but I have high hopes that Adobe AIR will live on and I love ActionScript 3.0. Recently at work I was updating an old app that we created in AIR and I was running into some problems when trying to debug it on an iPad. It would build and then while it was trying to install the app it would throw up an error that said “Installation Error: APIInternalError”. I’ve seen this error before and have usually gotten around it by just unplugging the iPad and plugging it back in again or restarting Flash Builder or IntelliJ. I think I even had this happen once before and I got around it by updating the Apple certificates. I tried all of that this time and nothing was working. After a very long time searching online and pulling my hair out (that I don’t have) I came up with the following suggestions:

  • Make sure that iTunes recognizes the device
  • Run the following command in the AIR SDK bin folder ‘adt -devices -platform ios’
  • Verify that the Provisioning Profile has the device included in it
  • Unplug the cable and plug it back in
  • Plug the cable into a different USB port (try plugging straight into computer if you have a USB hub)
  • Is the version of iOS a beta or too new? If so, try a different iPad with a different version
  • Try installing a dev build (ipa in the bin-debug folder) in iTunes
  • *Download a new version of the AIR SDK

 

I did get mine working again and I think that the main problem was I trying to test on an iPad that was running a new beta version of iOS 11. Running it on two other iPads that were running iOS 8 and iOS 10 worked. *The fix for iOS 11 was to wait and get a new version of the AIR SDK.

Flash Builder attempts to launch and then fails

I wrote a post a while back about how to fix Flash Builder when it wouldn’t start. I found that there were two things to try, one of which usually fixed the problem. The first was to deactivate a product in the creative suite and reactivate it. The other one was to delete the  Adobe Flash Builder folder that is usually located in your users directory. If the deactivation and reactivation didn’t fix the problem, deleting the Adobe Flash Builder directory usually will. The frustrating part is that also removes any customization that you’ve made to your workspace which can take time to set up again. So after doing this many times I finally spent more time looking into what the problem was and I found it. Here’s all you need to do to get it to start again and not loose all of the customization. Inside of the Adobe Flash Builder folder navigate to -> .metadata -> .plugins -> org.eclipse.ui.workbench in that folder there is a file called workbench.xml. Edit this file in a text editor and remove any references to files in projects that you know weren’t open the last time that you used Flash Builder. If you don’t remember just remove all references to files. This may mean that you have to re-open some files, but that’s better than having to configure your workbench again. I was able to find which files were open by making a copy of that directory and then deleting it and opening Flash Builder. It recreates the folder and will open and you can usually see what projects are open. Another thing to try is attempt to open Flash Builder and see if it stays up long enough for you to see which projects are open. If you run into this issue I hope this helps.

TypeError: Error #1007: Instantiation attempted on a non-constructor

So I know that many people are jumping ship when it comes to Flash and Flex when it comes to web applications but if you are one of the ones like me that is still doing this type of development you might run in to this sometime. The app that I am working on is a Flex app that uses the 4.6 sdk. The is a central module that loads other modules. The problem I ran into was on one of the modules that was using an AdvancedDataGrid. I kept getting the Error #1007: Instantiation attempted on a non-constructor. The solution ending up being something very simple. The main application just needs to have an instance of the AdvancedDataGrid. I simply added AdvancedDataGrid; that along with the import and you should be good to go.

Remove Duplicates from an Array AS3

I recently needed function that would remove duplicate values from an array. After looking around online and modifying what I found to fit my needs I came up with the following:

var arr:Array = ["a", "b", "c", "a", "d", "a", "a"];

removeDuplicates(arr);

trace(arr);

function removeDuplicates(target:Array):void
{
	for(var i:uint=target.length; i>0; i--)
	{
		if(target.indexOf(target[i-1]) != i-1)
		{
			target.splice(i-1, 1);
		}
	}
}

If you are searching for a way to do this, I hope this helps!

Extra space below img tag

So I’ve been doing a lot of web development lately and have run into some issues that have driven me nuts. The latest one had to do with an HTML email template I was creating. for HTML emails you have to use a lot of tables which is always fun. I had a table with columns and rows that had images in them. The img tags were putting in extra space below them. I was using the HTML 4 strict doc type. That was part of the problem. If I changed that it worked fine, but I wanted to use that particular doc type since it was for an email template. I’ve been able to fix problems like this before by just adding a br tag after the img tag, but that didn’t work with this doc type. The problem is due to how the img tag is displayed. It’s generally an inline element not block. So using CSS I changed the display to block:

img
{
    display:block;
}

I overwrote the display for all of the img tags because that is what I needed, but you could do it on an individual (inline) basis.

 

Word multilevel list not working

This morning I was working on a Word 2007 document that had a bulleted list in it and couldn’t get it to indent and place the different bullet points in the multilevel list properly. Needless to say it was driving me nuts. If you run across this problem here is what you do to fix it. Click on the office button->word options->proofing->auto correct options->auto format as you type and select the check box “set left and first indents with tabs and back spaces” under automatically as you type section at the bottom.

404 Not Found Error from my WordPress blog when I click on an entry or archive

So I just had this happen recently to two blogs that I maintain. The home page of the blog showed up fine, but when I clicked on a link to go to any page other than the home page I would get a 404 not found error. Pretty crappy, but the good thing is it was simple to fix. Log in to your Dashboard, under the Settings tab there is a Permalinks link. Click on that and then click the Save Changes button. This re-creates the .htaccess file and that should fix the problem. I found this solution on WordPress’s forum here. WordPress Rocks!

Random Vector and Random Array Functions

I’ve been working on a Blackjack game and have needed to do a lot of shuffling, cards that is. I’ve seen quite a few shuffling functions over the years. Here is the one I like, partly because I wrote it. Well okay I took what I liked in the others and modified them to come up with these:

public static function randomArray(src:Array):void
{
    var len:uint = src.length;
    for(var i:int=len-1; i>=0; i--)
    {
        var randIndex:uint = randomUint(0, len-1);
        var temp:* = src[randIndex];
        src[randIndex] = src[i];
        src[i] = temp;
    }
}

Vector version looks like this:

public static function randomVector(src:*):void
{
    var len:uint = src.length;
    for(var i:int=len-1; i>=0; i--)
    {
        var randIndex:uint = randomUint(0, len-1);
        var temp:* = src[randIndex];
        src[randIndex] = src[i];
        src[i] = temp;
    }
}

Here is a sample of how the vector version is used:

Randomize.randomVector(cards as Vector.<Card>);

Here is the randomUint function that it uses:

public static function randomUint(min:uint, max:uint):uint
{
    return Math.random()*((max+1)-min)+min;
}

I like to call these functions a random number of times so that the deck of cards is nice and shuffled. Enjoy!

How do I change the retry time in SmartFTP

So if you do much with ftp you have probably heard of SmartFTP. If not I would highly recommend them. I have used a variety of ftp programs and theirs is by far the best that I have used up to now. It has a lot of great features and is reasonably priced. If you have used it then you have also most likely ran into the issue that arrives if you attempt to upload a file and it fails causing it to state that it will retry at (time stamp) future. The default is 30 seconds from the time that it attempted to upload the file. Well for me the problem is 30 seconds is much more than I care to wait. I do a lot in Adobe Flash and I have SmartFTP set to monitor the .swf file for the .fla file that I am working on. This way every time I publish the file it will automatically upload it for me. The problem is that SmartFTP recognizes the file having been changed right as Flash begins to compile the swf not when it is actually finished. This means that every time I would have to wait 30 seconds. Well there is a solution and here it is. To change the retry default time value go to Favorites > Edit Favorites. In the Favorites window, go to Tools > Edit Default Favorite. In the Properties window, select the “Connection” menu, and there you will see a setting “Retry Delay” it is set to 30 seconds by default. There you can type in whatever time you want. For most small swf files 1 second has worked for me.

How to embed fonts using actionscript 3

This was causing my to bang my head for a little while. There are different ways depending on  whether you are using Flash or Flash Builder (previously Flex Builder). If you are using Flash you can go here for a good example/tutorial: http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/. Basically you add a font to the library by clicking the pop-up menu (in the upper-right corner of the Library panel), export it for actionscript and then give it a class name. After that your code looks something like this:

var myFont:Font = new Font1();
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.fontName;

Embedding fonts in AS3 seems to be a big problem for many people out there especially if you are using Flash Builder/Flex Builder. I know it was driving me crazy! I was following the examples, but still seemed to keep getting the same error: “An Embed variable must not have an existing value.”. Okay maybe it’s just me but that one was a little cryptic. Finally after a long time, but before having to do a Google search for straight jackets I figured out what I was missing. In all of the examples the embed line was right above a Class variable, but mine was not, so I added one and  cha ching it worked. Here is a sample:

[Embed(source="assets/MONACO.TTF", fontName="monaco",
mimeType="application/x-font-truetype")]
private var MonacoFontEmbed:Class;

It may just be me but this was not obvious I must confess. You don’t use that variable at least I didn’t, you simple set the .font property to the fontName value. It looks something like this:

myFormat.font = "monaco";

monaco is what I named it. You can name that whatever you want along with the variable. I named it MonacoFontEmbed, but you can name it whatever. I hoped this helped. If you have any questions feel free to post them. Embedding fonts is very useful especially if you are planning to manipulate a text field. Manipulations like rotation will just cause your text field to disappear if created dynamically and without embedding the font.