Flex Library Project: NativeMenu vs. ContextMenu - apache-flex

I have a Flex Library Project which has both Flex specific classes, and Air specific classes.
When I reference the library in an Air project, the compiler complains about an overriding contextMenu in mx.containers.Panel, saying that the param should be of type NativeMenu (instead of ContextMenu). If I switch it over to NativeMenu then it compiles fine.
The issue is when I reference the library in a Flex Project. This time it complains that it doesn't know the type NativeMenu. If I try to change it back to ContextMenu, then I get the same error as above.
I've searched google to no avail (found that someone else encountered the exact same problem: http://forums.adobe.com/thread/598791?tstart=-1 )
The docs don't help too much either, except stating the above: http://livedocs.adobe.com/flex/3/langref/flash/display/InteractiveObject.html#contextMenu
I'm thinking that its just not possible to do the mixing of Flex vs Air SDKs that I want, but I was hoping that maybe someone has figured this out.
Thanks!

You can't really target the web Flash Player and the desktop Player using the same project.
I would recommend encapsulating out as much functionality as possible into a library project. Then create a single Flex project and a single AIR project, both using the same library project.
Each respective project can extend, or replace, the different functionality.

I am not sure if this is the exact same problem, but I was having an issue with being able to reference the AIR libraries in a Flex Library project and found the (rather simple) solution.
Using Flash Builder 4.5, when creating a Flex Library Project, (right-click .. New.. Flex Library Project) there is a checkbox for "Include Adobe Air Libraries" at the bottom. This must be checked or AIR libraries will not be included.
When you select the version of SDK/AIR you are using in the dropdown, the message should also indicate what the minimum version of AIR required is for your application.

Related

Customize Adobe File

I have a problem with my Flex Builder Plug-in.
I'm using the Flex Builder 3 Plug-in in my Flex application (in Eclipse).
Now I want to customize the MessageResponder.as File in the Plug-In. I found the ActionScript File without any problems, but the point is, that my changes doesn't cause anything because the file is allready compiled. (That's my guess)
Now my question:
How can I compile the file after editing it? Is there a possibility at all?
Thanks for your help!!
What you want to do is called "Monkey Patching." What you need to do is create your own version of the file in the same package location, and yours will be used in preference to the one from the swc.
The MessageResponder.as class is a file in the Flex Framework. You can modify it if you want, and--in essence--create your own version of the Flex SDK. However, you will most likely have to re-buld the entire framework for this to work. You're best bet for doing this is to get the source for the most current Apache Flex SDK; modify your class and then build the framework from scratch. After that you can use the Flash Builder "multi-SDK feature" to use your modified SDK in a Flex Project.
I'm not sure if Flex Builder 3.x supports multiple SDKs.
This may be a time consuming process. The alternative is to extend the MessageResponder and add your changes. Then you'll have to make sure that your new MessageResponder class is used instead of the old MessageResponder class. This could difficult due to many private methods used in the Flex Framework.

where is the flex library file exist swc

can any one help me that where is the SWC or run time library for the flex controls exist in the system?
Or can we provide our own library by using the controls in the dir
C:\Program Files\Adobe\flex_sdk_3.2\frameworks\projects\framework\src\mx
It is not very obvious what are you trying to ask but I'll try to guess :)
So the SWC with Flex controls is located here {Flex.SDK.root}/frameworks/libs/framework.swc and the corresponding RSLs are located here {Flex.SDK.root}/frameworks/rsls.
What about providing your own library to replace Flex controls I think it is not the right way. The best practice is not modify Flex SDK installation to have possibility to build your project on every computer with different environments (on a different developers computers or on client site).
And you should take in mind there are 4 standard ways to use code in Flash application:
Compile your code into SWF.
Use Runtime Shared Library aka RSL (which is SWF too).
Use SWZ which is signed and can be cached by Flash Player.
Use modules which are SWFs.
None of these ways doesn't suppose using Flex SDK in runtime. Flex SDK is being used only in process of building of your application.
So the best way to use some custom controls is to build them with your application using one of the ways I described above (excluding SWZ's which can be produced only by Adobe).
Just leave Flex SDK installation without changes and place classes/SWCs with custom controls in your project's classpath.
Hope this helps.

Flex Builder Plugin in Eclipse - Some Controls not available !

I downloaded Flash Builder from here : Download
I recently started writing some small programs in Adobe Flash Builder Plugin for Eclipse.
I am trying out those programs by reading out the Adobe book : Training from the source.
But, I found that some of the controls mentioned in the book for some e.g, such as ApplicationControlBar doesn't appear in the Adobe Flash Builder 4. That control is mentioned in the book, but unable to find in the Builder.
What should I do ? Any suggestions ?
I suppose you've created project using Flex 4 SDK which is default in Flash Builder 4. And the book covers Flex 3. So Flash Builder created spark Application container (from Flex 4) where ApplicationControlBar isn't actual anymore and replaced with controlBarContent property which allows to skin Application more flexible way.
So I can recommend you the following 3 solutions how to use Flex 3 (to be compliant with the book) in your project:
The easiest way to switch existing Flex 4 project to use Flex 3 is the following. Open project properties then Flex compiler > Flex SDK version > Use a specific SDK and select Flex 3 SDK which should be available there. Then you need to create new application in your project, select it as default using context menu, copy old application context to the new one and delete old application file. But I suppose it is better to create new project as far as you are dealing with sample apps from the book.
So just create new Flex project and select the right SDK version on the New Project master's first page.
If you plan to use only Flex 3 for your book's playground workspace you can set Flex 3 SDK as default so you won't need to select the right version on project creation. Just go to the Preferences > Flash Builder > Installed Flex SDKs and select the default version. You can go there right from the new Flex project wizard by clicking Configure Flex SDKs…
Hope this helps!
I've never seen or heard of an ApplicationControlBox. Perhaps they were referring to the ApplicationControlBar and that it's just a typo.
Adobe has some great documentation out there on each of its packages and classes. It's a great place to start if you ever have a question about one of the components.

converting Adobe AIR to Flex application

We have a Adobe AIR desktop client which talks to a WAMP server. How can i convert this AIR app to a Flex app to be used in the browser.
Please let me know.
Thanks
vish.
I would create a new empty Flex application and copy your files into that project. Then move any code in your main app component (which is derived from WindowedApplication) into the main app component in your new project (which is derived from Application). You'll also have to go through your app and determine which components are used that are specific to AIR and rework them to use other Flex components (the compiler will complain if you don't). This should give you a good start.
I would move everything into a Flex library project. Then have an AIR project as well as a Flex app project which accesses the common code in the Flex Library project. This way you don't have to maintain two different codebases for common code and you can also have code which is specific to each version.

Creating Flex 3.5 components with Flash CS5

Is there a way to create components compatible with Flex 3.5 by using Flash CS5? I'm stumped. Whenever I run the "Convert Symbol to Flex Component" command and then try to use the resulting .swc file in a Flex 3.5 app, I get multiple instances of the following error:
1046: Type was not found or was not a
compile-time constant: Matrix3D.
1046: Type was not found or was not a
compile-time constant: Vector3D.
Any help or suggestions?
I had the same problem. I found a work around, though. You need to create the component using Flash Builder by dragging a Flash Professional Component onto your application. (You must be in Design Mode to do this.) Then, in the properties sheet, there will be a button labeled "Create In Flash Professional..." Clicking this button will create a Flash Document with all the correct frameworks and sdks and launch Flash Professional.
The errors you are seeing are usually brought on by a version mismatch between the Flex SDK that the SWC was compiled against and the Flex SDK of your project.
When creating SWCs using the Flash Pro interface, I'm not sure if they can be used in Flex. Generally SWCs are not sharable between Flex and Flash. People either recompile the source code or generate a SWF and embed it or load it using a SWFLoader.
If you're using the Flex Component Kit for Flash make sure you're using the same kit that came with the SDK you plan to target.

Resources