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
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: HelloWorld Example with MX/Spark components

The new SDK (0.9.1) does not add any new features, just support of Burrito and some very minor bug fixes.

 

Only about a month to go (early January) to submit to App World.  A lot has to happen between now and then.  I hope everyone is ready to hook themselves to some iv caffine drip Smiley Surprised

Developer
Posts: 43
Registered: ‎11-19-2010
My Device: Blackberry Tour
My Carrier: Verizon

Re: HelloWorld Example with MX/Spark components

I noticed that there is no size set for any of these button:

 

qnxButton = new qnx.ui.buttons.Button();

qnxButton.x = 10;

qnxButton.y = 10;

qnxButton.setSize(75,42);

this.addChild(qnxButton);

 

I have a qnx button on top of a sprite object  and it shows up fine. Smiley Wink

See if that fixes it.

Contributor
Posts: 40
Registered: ‎11-21-2010
My Device: 9630
My Carrier: Verizon

Re: HelloWorld Example with MX/Spark components

You can use MX components, even with 0.9.0.You just need a top level application. I'm working on an app right now and it's exactly like developing for AIR anywhere else.

 

I created a normal AIR application and then switched the project to use the SDK for Blackberry. There was some problem creating a project using that SDK that was anything but a .as file for the main app.

 

And add the compiler args (your library path may vary):

 

-locale en_US -library-path+="C:/Program Files/Adobe/Adobe Flash Builder 4/sdks/blackberry-tablet-sdk-0.9.0/frameworks/locale/en_US"

 

And configure a launch profile of course.

 

Then you should be able to deploy something like this:

 

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                       xmlns:s="library://ns.adobe.com/flex/spark"
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       backgroundColor="#000000"                        >    

 

    <mx:Button label="Close" click="stage.nativeWindow.close()"/>
    
</s:Application>



Dungeon Joe - A Touch-focused Strategy Game http://dungeonjoe.com
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: HelloWorld Example with MX/Spark components

Have you been able to check the resulting SWF filesize from this method to the Sprite only method?  I dont have the number with me, but the file size difference was significant (~2x) and in the case of WindowedApplication base class, the load time in the simulator was just too slow.  I would rather work in MXML land, because I feel I am writing less code and have increase productivity, but the download and loadup by this method did not seem to warrant to proceed further in that direction.  If you can show that an MXML approach is still light weight, I would love to change gears and go back to that approach.

 

Also had trouble setting the SWF parameters above the main Sprite definition in any approach other than the "standard" approach.

New Contributor
Posts: 3
Registered: ‎12-01-2010
My Device: Not Specified

Re: HelloWorld Example with MX/Spark components

If you want to use MX or Spark components, you MUST have an Application component as Root.

MX and Spark components inherits from UIComponent class which initialise a lot of things and communicate with a top Manager. It is not possible to add Sprites on MX or Spark components (except UIComponent with some tricks), because they don't use the same display events. And you can't use MX or Spark components on Sprites, because components need an initialisation to display, and Sprite can't do that.

When developping real desktop AIR programs or web Flex programs, if you use Shared Libraries, your SWF will be >40kB. if you add static librairies, it will be bigger.

Developer
Posts: 107
Registered: ‎11-20-2009
My Device: Tegra 2 Android tablet and Playbook
My Carrier: Rogers

Re: HelloWorld Example with MX/Spark components

[ Edited ]

@jtegen

Planning to check size of similar function apps with Sprite + QNX and Spark, but apps shoul be substantial not just one button in a container!

Will post my results here.

 

I agree with you that using x,y for mobile devices is bad, I always use relative coordinates, containers (like vbox,hbox) and non absolute layour managers.

Always runinng orientation test to see how UI looks with different orientation.

http://riahut.com
Developer
Posts: 107
Registered: ‎11-20-2009
My Device: Tegra 2 Android tablet and Playbook
My Carrier: Rogers

Re: HelloWorld Example with MX/Spark components

[ Edited ]

Forgot to mention, new Burito SDK actually has <MobileApplicaiton/> root element, I suspect there are bunch of mobile optimised components as well. As part of my test I will check how big is Mobile optimised Spark Application.

http://riahut.com
Contributor
Posts: 40
Registered: ‎11-21-2010
My Device: 9630
My Carrier: Verizon

Re: HelloWorld Example with MX/Spark components

[ Edited ]

@jtegan

Note in the above example, I'm using Application rather than WindowedApplication.

 

Of course the SWF loads quickly, but the Flex Init time is a few seconds, so I put a preloader on it to get rid of the 'white box' progress bar for the few seconds it's shown. I'm fine with it not being absolutely instantaneous.  It doesn't take as long as Firefox does to launch on my desktop, Smiley Happy

 

-=Cliff>



Dungeon Joe - A Touch-focused Strategy Game http://dungeonjoe.com
Highlighted
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: HelloWorld Example with MX/Spark components

I just did a quick sample between Application root class and Sprite root class.  The Sprite root class to just show a label is 127KB.  The Application based application is 540KB; 425% larger.

 

Any suggestions to get it smaller?

 

Sprite:

import qnx.ui.text.Label;
	
	[SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
	public class SampleAway extends Sprite
	{
		public function SampleAway()
		{
			this.stage.nativeWindow.visible = true;
			
			var label : Label = new Label();
			label.text = 'Hello World';
			addChild( label );
		}
	}

 Application:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
		xmlns:s="library://ns.adobe.com/flex/spark" 
		xmlns:mx="library://ns.adobe.com/flex/mx" width="1024" height="600">
  <s:Label text="Hello World" />
</s:Application>

 

New Contributor
Posts: 3
Registered: ‎12-01-2010
My Device: Not Specified

Re: HelloWorld Example with MX/Spark components

You can try to use shared libraries with Flex. It's an compiler option.