Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
gosubtle
Posts: 24
Registered: ‎06-22-2012
My Device: Z10 + Playbook
My Carrier: ATT

BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

Hi everyone, I have an issue I'm getting on both my VM bb10 and Dev Alpha (upgraded with the recent OS upgrade in late november: Autoload-DevAlpha-10.0.09.1103.exe). Based on the fact I am trying to create 2 seperate versions of a hopefully awesome app I'm developing just for Blackberry, I did what someone in another thread mentioned to do (sorry I forget the person's name) and I am using direct library links and not including SDK automatically based on platform so I can develop variations of a BB10 and PB version at roughly the same time.  I am using FB 4.6 as part of CS6.  I tried to go with 4.7 but I gave up because 4.6 is still working just fine for me.

 

This approach worked outstanding for my previous PB app that I published and allowed me to still have a seperate project that work (at least initially) properly with BB10.

However, the second I change to the BB10 sdk 3.0 libraries and referrence those files it fails for me with this:

 

TypeError: Error #1007: Instantiation attempted on a non-constructor.
	at qnx.fuse.ui.theme::ThemeWhite/createCSS()[E:\hudson\workspace\BB10_0_04-AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\theme\ThemeWhite.as:25]
	at qnx.fuse.ui.theme::ThemeWhite()[E:\hudson\workspace\BB10_0_04-AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\theme\ThemeWhite.as:20]
	at qnx.fuse.ui.theme::ThemeGlobals$/getTheme()[E:\hudson\workspace\BB10_0_04-AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\theme\ThemeGlobals.as:246]
	at qnx.fuse.ui.theme::ThemeGlobals$/lookupStyle()[E:\hudson\workspace\BB10_0_04-AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\theme\ThemeGlobals.as:189]
	at qnx.fuse.ui.theme::ThemeGlobals$/lookupValue()[E:\hudson\workspace\BB10_0_04-AIR_SDK_API\src\qnxui\src\qnx\fuse\ui\theme\ThemeGlobals.as:201]

 

This has happened to 2 seperate very simple applications I have tried to use.  One where the said code below in question was placed on a Sprite and another where it was placed on a Container control.

 

As background, here are the other important settings:

Libraries included:

Flex 4.6.0

*Air Global.swc

*core.swc

*osmf.swc

*textLayout.swc

*servicemonitor.swc

Referenced Libraries

*qnx-air.swc - C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\air

*blackberry.swc - C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\blackberry

*qnxmedia.swc - C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\qnx

*qnxui.swc - C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\qnx

*QNXSkins.ane - C:\Program Files (x86)\Research In Motion\blackberry-tablet-sdk-3.0.0\frameworks\libs\qnx\ane

I also have included the other 3 ANE files and have made sure they are included with a checkbox for the build.

Here is the includes:

 (Rest of .ane files in qnx ane folder are also loaded with same path)

 

And here is the base code I'm taking from the examples:

Includes:

	import qnx.fuse.ui.buttons.Button;
	import qnx.fuse.ui.buttons.LabelButton;
	import qnx.fuse.ui.buttons.SegmentedControl;
	import qnx.ui.data.DataProvider;
	import qnx.fuse.ui.text.TextFormat;
	import flash.text.TextFormatAlign;
	import qnx.fuse.ui.skins.SkinStates;

 And code that actually fails when trying to generate this:

			var buttonArray:Array=[];
			buttonArray.push({label:"AM"});
			buttonArray.push({label:"FM"});
			buttonArray.push({label:"HD"});
			
			// create a segemented control
			var mySegment:SegmentedControl = new SegmentedControl();
			mySegment.x = 200;
			mySegment.y = 200;
			mySegment.width = 200;
			// set the data provider
			mySegment.dataProvider = new DataProvider(buttonArray);
			// set the selected index to be the 3rd item in the dataProvider
			mySegment.selectedIndex = 2;
			// add the control to the display list
			stage.addChild(mySegment);
			
			var myButton:LabelButton = new LabelButton();
			myButton.label = "Click here yo!";
			stage.addChild(myButton);

 
This fails with either control commented out but does not fail when both are commented.  Do I need to still include some of the SDK 2.1 files?  Am I just missing something mega obvious?  Hopefully I am. :smileyhappy:

 

Thanks for any help!

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

3.0 text alignment is from:
import qnx.fuse.ui.text.TextAlign;
It will probably still work with other alignment classes buecasue they are using the same string value.

Do you have "Add platform specific libraries to library path: checked?

You do not need anything from SDK 2.1.

Is it crashing at the control instantiation?

Or is it crashing when adding to the stage? If so, you need to first listen to when the stage has been created and the "page" has been added to the stage first. My guess is that your stage is null.
Please use plain text.
Contributor
gosubtle
Posts: 24
Registered: ‎06-22-2012
My Device: Z10 + Playbook
My Carrier: ATT

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

[ Edited ]

No I do not have any of the SDK 2.1 libraries in this case.  I luckily learned my lesson a while back for not having the following code there to prevent null stage:

 

		<main app class>
		{
			.....
			addEventListener(Event.ADDED_TO_STAGE,handleAddedToStage);
		}
				
		private function handleAddedToStage(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE,handleAddedToStage);
			// stage is avail, we can now listen for real events
			

			initializeUI();
		}

 If anything I may have to just settle for 2.1 dev for now and just forget about trying to be a "good" app that will fall under the 10k and other numerous benefits that BB has put out for us.

Please use plain text.
Contributor
gosubtle
Posts: 24
Registered: ‎06-22-2012
My Device: Z10 + Playbook
My Carrier: ATT

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

Oh sorry I didn't answer the last part.  I did some more research.  It looks like it's crashing even when I simply declare a variable as say a segmented control.  So my guess is, it's failing when it loads the SDK libraries because if I gather correctly from everything, flash only includes/loads libraries when it's actually used (such as a variable etc).

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

Is this an existing app/FB project that you are just switching to SDK 3? If so, try a simple app from scratch with the correct libraries and SDK reference and see if you get that to run.
Please use plain text.
Contributor
gosubtle
Posts: 24
Registered: ‎06-22-2012
My Device: Z10 + Playbook
My Carrier: ATT

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

First, before I answer, thanks a lot helping me try to work this through.

 

As for the project, it's completely 100% new.  Create project, add SDK 3.0 referrences when creating the project and adding those small snippets of code.  I had the same issue with another project i had earlier so I decided to start completely new in case i'm doing something wrong.  But followed everything according to everything i've read and it still fails.  Maybe this is ok for now, can you tell me how much improved 3.0 is vs 2.1?

 

Thanks again.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

3.0 is for BB10 apps and 2.1 is for PlayBook apps. All of the controls are different and skinned for the higher resolution screen on the BB10 devices.

when I create a new BB10 app in FB, I:
a) Assume 3.0 is already reference in the preferences for the workspace
1) Create a new "Action Mobile Project"
2) Enter project name
3) I select just BlackBerry for target platform
4) Select initial permissions
5) Select full screen
6) Decide if I want the app to reorient (can change later)
7) Next
8) On Build Path, add any other SWC file
9) Change App ID to reverse DNS
10) Under Native Extensions tab, select Add Folder...
10a) Select folder under 3.0.0/frameworks.libs/qnx/ane
11) Select Finish, this creates your project
12) Select project Properties
13) Under ActionScript Build Packaging/BlackBerry:
13a) Select "Add platform specific libraries to library path"
13b) Select "Enable digital signing"
13c) Under Native Extensions, check QNXDevice and QNXSkin ANE (you might get warning that they are not used yet)
14) Press OK.
15) Under Debug Icon, select Debug Configurations
15a) Select Add Icon (top left)
15b) Select On device for Launch Method
15c) If you have not created a profile before, you will need to do so
16) Press Apply then Debug

Those steps works great for me. Does this help?
I will try your sample code and report back.
Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

The following worked fine:

package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	
	import qnx.fuse.ui.buttons.LabelButton;
	import qnx.fuse.ui.buttons.SegmentedControl;
	import qnx.ui.data.DataProvider;
	
	public class SampleApp extends Sprite
	{
		public function SampleApp()
		{
			super();
			
			// support autoOrients
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			

			this.addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage );

		}
		
		private function handleAddedToStage(e:Event):void
		{
			this.removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
			this.initUI();
		}
		
		private function initUI() : void
		{
			var buttonArray:Array=[];
			buttonArray.push({label:"AM"});
			buttonArray.push({label:"FM"});
			buttonArray.push({label:"HD"});
			

			// create a segemented control
			var mySegment:SegmentedControl = new SegmentedControl();
			mySegment.setPosition( 200, 200 );
			mySegment.width = 400;
			// set the data provider
			mySegment.dataProvider = new DataProvider(buttonArray);
			// set the selected index to be the 3rd item in the dataProvider
			mySegment.selectedIndex = 2;
			// add the control to the display list
			stage.addChild(mySegment);
			
			var myButton:LabelButton = new LabelButton();
			myButton.label = "Click here yo!";
			stage.addChild(myButton);
		}
	}
}

 Personally, All UI elements should go into a "page" and pages added and removed to the root display and not the stage.  Above code the addChild(...) calls should use "this" instead of "stage" so the elements are being added to the root sprite and not directly to the stage.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

Additionally, gui elements should be members of the class so they are accessible to other methods in the class.
Please use plain text.
Contributor
gosubtle
Posts: 24
Registered: ‎06-22-2012
My Device: Z10 + Playbook
My Carrier: ATT

Re: BB10 Air Dev Alpa and VM Run Time Error with SDK 3.0

Yeah, I just didn't really take notice on the simulator.  I launched 2.1 on the dev alpha and wow, this is going to cause problems.  I couldn't even really use it it's so small.  I am going to look into a full reinstall of flash and the SDK's with completely new projects (only my RIM keys will be kept).  Hopefully this works, and if I cannot fix this and/or resize the controls for the different resolution, I may have to end up making my own controls for certain things.

 

It's the weekend, but was hoping one of the RIM genies could shed some light on it.  Thanks again jtegen, you have helped a lot of the people i have noticed on these forums. :smileyhappy:

Please use plain text.