Joe's Blog

line

A blog by Joe Billman about programming, and other stuff

line

Archive for the ‘ActionScript’ 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.

AS3 Singleton

Posted on: February 7th, 2014 by Joe

line No Comments

Singleton classes are very useful. So I wanted to show a simple sample of a Singleton class. I like to use these as models to store data in one location that multiple parts of your application can access. Singleton classes in ActionScript 3 for the most part are just like they are in other OOP languages. There is one minor difference. Since you can’t make a constructor private you have to add a few lines of code in the constructor. Here is a sample:

public class Singleton
{

	private static var _instance:Singleton = new Singleton();

	public function Singleton()
	{
		if(_instance != null)
		{
			throw new Error("Instantiation failed");
		}
	}

	public static function getInstance():Singleton
	{
		return _instance;
	}

}

That is my preferred way to do it for models that you know are going to be instantiated. Then you just add public variables and you have a model. Generally when I’m using models I always plan to instantiate them, but if you are not sure if you are going to instantiate the class you may want to do it like this:

public class Singleton
{

	private static var _instance:Singleton;

	public function Singleton()
	{
		if(_instance != null)
		{
			throw new Error("Instantiation failed");
		}
	}

	public static function getInstance():Singleton
	{
		if(_instance == null)
		{
			_instance = new Singleton();
		}
		return _instance;
	}

}

 

Get Spark Image width or height

Posted on: January 9th, 2014 by Joe

line No Comments

So one of the most annoying things about working with display items in the Flex framework is the difference in how things are rendered. This means that after you have created an object in AS3 code you can’t get the properties of that object until after a certain event in the creation process. Generally you need to listen to FlexEvent.CREATION_COMPLETE. After that fires you can usually get width and height etc. the Spark image is a little different. The best way that I’ve found is to listen to Event.COMPLETE and then get sourceWidth or sourceHeight instead of width or height. This one drove me nuts for longer than it should have so hopefully if you have this problem you can find this post before it drives you nuts.

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

Posted on: November 11th, 2013 by Joe

line No Comments

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.

ActionScript Mobile Projects

Posted on: July 24th, 2013 by Joe

line No Comments

I’ve been working on more mobile projects lately both at work and in my spare time. I’ve been mainly using the Starling framework and really like it so far. The other day I heard about a new technology being developed by Autodesk that takes flash games written in ActionScript and ports them to Android and iOS. It’s in the early stages, but it looks really promising. To learn more about it go here: http://gameware.autodesk.com/scaleform/advantage

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.

TypeError: Error #2007: Parameter antiAliasType must be non-null

Posted on: June 14th, 2013 by Joe

line No Comments

I got this error when I was trying to create a mx DateChooser via code instead of mxml. To make a long story short the solution was to move the call to the function that was attempting it to create it. It was being called from the constructor at first and I moved it to be called after the parent object was added to the stage and that did it. If you are getting this error, try and call whatever code is causing it later in time. I hope this helps.

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.

Recommended MP3 Settings for Flash Player

Posted on: March 16th, 2013 by Joe

line No Comments

I recently ran into another MP3 issue while working on a Flash Project. I found this one while working on an iPad app in Flash Builder. I meant to write about this issue a long time ago when some mp3 files that I was using on a website sounded really bad in the Flash Player. So here is my recommended MP3 Settings for mp3 files used in ActionScript applications:

  • Sample Rate – 44100 Hz (this one is the most important, if it is not set to this, it can sound bad, slow, fast, garbled)
  • Channels – Stereo or Mono work fine (for most sound effects I use mono)
  • Bit Depth – 16
  • Sample Rate – 128 Kbps (you can use higher or lower, I haven’t noticed too much improvements going higher, but it’s definitely noticeable as you start going lower)

This is probably common knowledge to most people working with Flash applications and ActionScript, but if not, I hope this helps.


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