Joe's Blog

line

A blog by Joe Billman about programming, and other stuff

line

Archive for the ‘Flash Builder’ Category

Installation Error: APIInternalError

Posted on: September 13th, 2017 by Joe

line No Comments

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

Posted on: April 25th, 2014 by Joe

line No Comments

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 #1009: Cannot access a property or method of a null object reference – UIMovieClip

Posted on: June 18th, 2013 by Joe

line No Comments

So I ran into this error again today. I first ran into it a few years ago. It happens to me when I have an asset that is created in Flash Pro and used in a Flex application. It happens when that component has focus and the whole application then loses focus and then receives focus again. The UIMovieClip class has some issues and so if you are getting this error try one of the following solutions. For either of these solutions you’ll need to put an asset on the root level of your application that extends UIMovieClip, DisplayObject or there are a few others. It has to be an object that the FocusManager instance of the main app can set the focus to. I like to use a logo or some other visual element that I can create in Flash and that will be on every view of your application (root level). What you want to do is before removing any UIMovieclip object from the display list, have the application set the focus to the logo or whatever you’re using. The first way of doing this is by adding the deactivate listener to your flex application. Then have the handler function for that set the focus. This works most of the time, but I’ve found some instances where it doesn’t. If you have text fields that have keyboard listener it doesn’t work. The way I prefer is to dispatch an event from each of my UIMovieClip objects before they are removed (I like to put it in a destroy function). That event bubbles all the way up to the app and then the app calls the function to change the focus. Here is an example:

this.focusManager.setFocus(logo);

That’s it. I hope this might help some of you from pulling your hair out. You want to keep all of the hair that you have, believe me I know.

Starling iOS app rotates after splash screen

Posted on: April 5th, 2013 by Joe

line No Comments

So I’ve been using Flash Builder and the Starling framework to create an iOS app of the Card Match game that I made a while back. I must say I’m pretty happy with the results, but there have been a few quirks. One of them was driving me nuts. I’m not sure how many of you will run into this but if you do hopefully this post will help. Here’s what it was doing: When the app would launch it would show the splash screen like it should and right after the splash screen was finished my whole app would rotate so that it was now upside down. I tried changing and then changing again the full screen and auto rotate properties in the app xml and nothing happened. So then I decided that I would just recreate the project in Flash Builder, so I made a new project and imported my classes, built it, and everything worked fine. Again I’m not sure why or if it was just a fluke, but if this happens to you, try making a new project.

I was recently working on a Flex Mobile Project and kept having this happen. After a lot of time and frustration I finally figured it out. By just adding -swf-version=29 to the compiler options that solved the problem. I think that it somehow wasn’t using the last AIR SDK somehow. I used the latest Apache SDK and it worked so I knew that it had to have something with the version. My guess is that without having that in there to force it to use the latest one it’s just missing something.

Mp3 works on pc but not on my iPad Starling

Posted on: March 16th, 2013 by Joe

line No Comments

I have been using Flash Builder and Starling 1.3 to create some iPad apps and recently ran into an issue that was making me want to pull out my hair. Luckily for me I don’t have any hair. The latest version of Starling (1.3) has a new AssetManager class in the starling.utils package. It’s pretty cool, it handles the loading and accessing of all of the assets for your apps. In the app that I’m working on I’m using it to load the graphic assets and the audio assets. Sounds simple enough right? That’s what I thought too, but then I ran into a little problem. When I ran the app on my PC using the AIR simulator the audio played fine, but when I ran it on my iPad I couldn’t hear any audio. It wasn’t throwing any errors, I just couldn’t hear anything. After trying everything I could think of, one of the guys that I work with told me to send him the audio files I was using and he would try them in his app. That got me thinking and so asked him to send me some of his audio files as well because they were working. So he did and they worked in my app. To make this long story short, the problem was with the particular MP3 files. I opened them up in Audition and saved them at a different bitrate and that did it. Not sure how many people will run into this, but if you do, try saving the mp3 file differently and see if that fixes it.

SoundChannel position doesn’t = Sound length

Posted on: January 29th, 2013 by Joe

line No Comments

So I recently made an AIR app at work that we use for finding cue points in an mp3 file. It loads an mp3 file, creates the sound wave spectrum for said file and then allows the user to target different locations in the file and output them as cue points. While working on this project I noticed that I was getting weird results on the the location of the play head in the audio file. It was really noticeable at the end of the file. The position property of the SoundChannel object at the end of the file didn’t equal the length property of the Sound object. It was a variable amount of milliseconds behind it. After a beating my head for a while and doing some searching online I realized what the problem was. It was all due to the bit rate at which the mp3 was saved. Anything below 128 was causing it to be off and the amount that it was off varied depending on the bit rate. If it was saved above 128 it was fine, but below caused problems. So if you are playing mp3 files in the Flash Player the ideal settings are 44100 Hz with a bit rate of 128 Kbps or higher. Also just as a side note if you don’t sample it at 44100 Hz the audio actually sounds bad as well. Hope this helps. Flash Player is still the best way to play audio files on the web.

Flash Player Garbage Collection.

Posted on: October 2nd, 2012 by Joe

line No Comments

So the more you work with ActionScript 3 and especially when it comes to building RIA’s (Rich Internet Applications) or games, the more garbage collection will become really important. When I first started down the road of memory management and garbage collection there were a lot of things that were very confusing. This post is to share the things that I’ve learned and hopefully help others avoid much of the confusion. The first thing to know is as of right now there is no real way of triggering a garbage collection pass on demand, but there are some good practices to follow that will ensure that objects are flagged to be collected. The first thing to be aware of is that if you are not using the Premium version of Flash Builder to profile your swf file you are going to have a difficult time knowing if it’s cleaning itself up properly. There are some other tools out there to help with this, but as off the time I wrote this Flash Builder Premium is by far the best. One tool to keep in eye on though that looks very promising is called project monocle. Do a Google search for it. Covering how to profile a swf is a little beyond the scope of this post, but when you’re writing your code here are the things I’ve found that you want to look for.

  1. Remove all event listeners.
    It’s good practice to use weak referencing when adding listeners. To do this set the last parameter in the addEventListener function to true. Doing that is not a guarantee though so remember to always remove listeners.
  2. Set all complex data types and any other object that contains a reference to another object such as Arrays and vectors to null.
    Although you can’t call the garbage collector on demand, this is the best way to ensure that an object is marked for collection on the next pass(as long as listeners are remove prior).
  3. Stop and nullify all timer and loader variables.
    Timers and loaders are notorious for hanging out in memory so make sure you watch them carefully.
  4. Ensure that all display objects are off of the display list before trying to destroy them.
    It’s rare, but there have been times when I’ve had to manually remove children from a parent before destroying the parent.
  5. Start a habit of good coding practices that works for you.
    So after you know what types of things to look for in your code that can lead to memory leaks, start making some habits to help you avoid those things. One thing that I’ve found helpful is to create a “destroy” or “cleanup” function for every class. Another thing that I’ve started doing that is very helpful is to make “create” and “destroy” functions for every complex object that I instantiate. So for example say that you were making a game that had a hero class, the two methods would be “createHero” and “destroyHero”. In those functions is where the object is created/destroyed(null) and where listeners are added and removed. Then you would have one public function that when it comes time to do the overall cleanup would call all of the destroy functions for the different objects. You can download a sample AS file that illustrates how to do this.

Memory management is very important in polishing any game or project. I hope this helps.

Flash Builder 4.6 Won’t Start

Posted on: July 14th, 2012 by Joe

line 9 Comments

I recently updated to CS6 and everything was working great until one day I tried to open Flash Builder and it wouldn’t open. It would pull up the Splash screen for a few seconds and then silently die. I’ve had something similar to this happen in the past and it was usually due to a file in the workspace getting corrupted and was an easy fix. You simply renamed or moved the workspace folder, launched Flash Builder so that it created a new workspace folder and then replaced the files in the new folder with the old one. This time however that didn’t work. So after a couple of hours of trying everything I could think of from uninstalling and re-installing to attempting to pull out all of the hair that I wish I had, I finally came across the answer. I read online that people were having problems getting Acrobat X to open. So I tried to open it on my machine and sure enough it wouldn’t open. After reading further online I discovered that other people had fixed this problem by opening Photoshop, deactivating, then re-opening Photoshop and activating again. So I did that and both Acrobat X and Flash Builder 4.6 launched like normal. With Adobe CS6 they have gone to a new activation model that requires you to put in the license key along with your Adobe ID. My guess is that there is an issue where after the trial period has ended (even though you activated it) it deactivates. Not sure but deactivating and re-activating solved it for me. So if Flash Builder or Acrobat won’t open, give this solution a try.

PS
I am using a PC with Windows 7 and am not sure if this problem exists on Mac.

How to embed fonts using actionscript 3

Posted on: May 27th, 2010 by Joe

line No Comments

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.


Warning: Use of undefined constant Y - assumed 'Y' (this will throw an Error in a future version of PHP) in /homepages/16/d145171736/htdocs/php/footer.php on line 1