I am using Flash CS5 and I have created a large, rarely changing framework that I don't want to be recompiled every time I use it in my projects.
I must be doing something wrong because the "auto-complete" functionality doesn't show the names of the parameters of the functions.
For example, I have a function:
public class Hey {
public function show(name:String, num:Number, data:Array):void {...}
}
I export the SWC file and when I import it into another project, then the auto-complete for this function shows :
show(arg0:String, arg1:Number, arg2:Array):void
So, instead of "name", "num" and "data" I get "arg0", "arg1" and "arg2".
I have downloaded other SWC files and the auto-complete gets the names correctly.
Am I doing something wrong at export-time?
I have never been able to get an SWC generated with the Flash Pro IDE to supply the correct parameter names in code hints. For some reason, the Flash IDE either does not use the same compiler or does not use the same compiler options as the Flex SDK toolkit.
You can generate code-hinting-compatable SWCs with Flash Builder by creating a Flex Library project. The "Flex" part of "Flex Library" is a little misleading. You can build AS3-only SWC files with this project type.
Or if you don't feel like shelling out the money for Flash Builder, you can always download the free Flex SDK and use the compc compiler to generate the SWC for you. It's the same tool set that Flash Builder uses to generate SWCs, so you will get the same code-hinting ability. The syntax is pretty straight-forward if you're used to command line tools:
compc -source-path . -include-classes MyCustomClass -output=MyLibrary.swc
Hopefully someone can post a better answer and prove me wrong, but I've never seen a Flash-generated SWC include the parameters in code-hinting.
I suppose you compile with debug=false but should be debug=true to keep all necessary data in swc including arguments names.
Optimizing libraries means to remove debugging and other code from the library prior to deployment. For normal libraries that you are not using as RSLs, you do not need to optimize. This is because you will likely want to debug against the library during development, so you will need the debug code inside the library. And, when you compile the release version of your application, the compiler will exclude debug information as it links the classes from the library.
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7ad5.html
For me the easiest way was to import the code to a Flash Develop project, and install a plugin to export swc's: http://sourceforge.net/projects/exportswc/
After installing Flash Develop go to Tools ยป Install Software and install the AIR SDK + ASC 2.0 (Action Script Compiler 2.0).
Furter information here: http://www.flashdevelop.org/community/viewtopic.php?t=2987
Related
I have been trying to compile StrobeMediaPlayback from source; I've managed to compile the project using ANT with the Flex 4.5.1 or Flex 6 SDK and also successfully compiled using Flash Builder 4.5 (as recommended by the project).
In all cases, compiling the SMP project results in a 433k StrobeMediaPlayback.swf. Also, StrobeMediaPlayback.swf located in src/player/StrobeMediaPlayback/bin/StrobeMediaPlayback.swf ships as 433k. My question then, is how on earth do I compile StrobeMediaPlayback.swf to 253k as it exists in the for Flash Player 10.1 folder? It appears there is an external OSMF.swc file in this folder that is 233k - typically this gets bundled with the build... however, I can drop the 253k StrobeMediaPlayback.swf into a new project without the OSMF.swc file and it works fine.
So, if it turns out that I need to compile StrobeMediaPlayback without bundling the OSMF.swc, can someone point me in the right direction on how to do this?
Relevant installation documentation that was impossible to find: http://osmf.org/dev/osmf/specpdfs/building-osmf.pdf
So, if it turns out that I need to compile StrobeMediaPlayback without bundling the OSMF.swc, can someone point me in the right direction on how to do this?
Try,
in your StrobeMediaPlayback project, mark the osmf.swc as an external library.
(Project > Properties > Application Build Path > Library Path > OSMF > Link Type)
I've been googling around for the past 2 hours looking for some simple instructions on how to add my own custom metadata tag in as3 with no success. I'm starting to think that I'm probably not searching for the correct terms.
The Problem
Ultimately, what I want to do is add a custom metadata on a function that takes a function as a parameter and makes sure that the given function has the correct parameters.
I.e. I have the following function:
public function testCallback(callback:Function):void
{
callback("test");
}
and I want to get a compiler error when I call it like this:
public function doNothing():void
{
// doing nothing
}
public function someRandomFunction():void
// ...
testCallback(doNothing);
}
The way I'm thinking of doing this is by having this metadata:
[Callback(paramName="callback",callbackParams="string")]
public function testCallback(callback:Function):void
{
callback("test");
}
The extension would run during compilation and, if the function passed does not contain the correct parameters, a compile-time error will be thrown. I THINK by using flex2.compiler.util.ThreadLocalToolkit.logError(path, line, errorMessage); I can accomplish this.
The Search
I've been googling for a couple of hours now and couldn't find a simple tutorial that could get me started. I found some SDK bug reports (SDK-18718, SDK-26041), an unfinished forum post, a tutorial (?) on how to add a custom metadata in FlexBuilder (I'm using FlashDevelop), a not-so-useful answer in StackOverflow and many many more dead ends.
The Help
So far, as far as I could understand, I will use Java to create the extension and then, using a compiler command, I'll add it into my project. However, I don't know what do I need to get started.
My two main questions are:
A) What do I need to create the extension in Java? (do I need Flex Builder? Eclipse? what libraries do I need in my classpath?)
B) Once I have compiled this into something (a swc?), how do I include this in FlashDevelop in my AS3 Project?
Thanks in advance!
Update
I've been able to create a Java project in eclipse, add the Flex libraries, implement the IMxmlcExtension interface and compile the project into a jar with the correct MANIFEST file. Unfortunately, adding the extra -extension=MyTest.jar in FlashDevelop, did nothing.
In case it is useful, the resulting command line for the compiler was
mxmlc -load-config+=obj\MyProject.xml -debug=true -incremental=true
-swf-version=10 -extension=flex_test.jar -o obj\MyProject634846490611881374
Update 2
Timofei Davydik helped me narrow down the problem. It seems that FlashDevelop is the main problem. Creating an extension and compiling it in command line works. I started a thread in FlashDeveloper's forums. In case you're interested, the thread is: -extension compiler option
Update 3
Pilippe is correct, it seems that the problem comes from the fact that FlashDevelop uses Flex Compiler SHell (fcsh). I am now looking into how can I switch compilers.
Really interesting question. I've done some research. Yes, we can write mxmlc extensions and add some custom functionality. But processing custom metadata is really complicated, and much time is needed debug and explore flex compiler sources. I've created a post in my blog about extensions, you can check it:
http://tim-davydik.blogspot.com/2012/09/flex-compiler-mxmlc-extensions-forcing.html
How to make meta-data tags work in Action Script
Timofei Davydik's wrote a quick and simple tutorial in his blog to answer my question, named Flex compiler mxmlc extensions. Forcing compiler language, and helped me a bunch to track down what is the problem (which is why I'm giving him the bounty). In his post, he is using Flash Builder and not FlashDevelop, which brings us to the answer of the next question:
How to program them using Flash Develop
Unfortunately, as Phillipe pointed out, for AS3 projects, FlashDevelop uses the Flex Compiler SHell (FCSH), which doesn't support meta-data. Since FlashDevelop is open-source, I'll try (and probably fail) to switch the compiler for testing purposes. For anybody else interested in this, I think this forum post is a good start: [ GIFT ] Try new AS3 compiler (ASC 2.0) in flashDevelop 4.x
I'm developing AS3 project using Flash Builder 4.5 (also with library Away3D 4.0 and Flex 4.5.1 SDK).
Also, I add my own SWC library, which I compile previously into my project.
It works find if I import class in my SWC library, however I want my swf run in a stand-alone flash player 11.
I follow this tutorial:
http://help.adobe.com/en_US/flashbuilder/using/WSe4e4b720da9dedb5-4dd43be212e8f90c222-7ffb.html
Now, I could run my app in a flash player 11, but I got an error in run time:
VerifyError: Error #1014: XXX class could not be found
And XXX is my class in SWC library. How should I fix this?
Merged into code means this, in project properties -> Flex Build Path -> Library Path -> Framework Linkage. Framework lingage has two options Merged into code and RSL. Chose Merged into code. This should solve your problem.
We had this problem when trying to build a project using a Native Extension.
Classes within the NE weren't being found at runtime, but were accessible in Flash Builder.
It turned out that by default the .ANE file wasn't copied to the device.
To fix this, change the following project property:
ActionScript Build Packaging -> Apple iOS -> Native Extensions -> Check 'Package' for the ANE
No idea why it wasn't included by default. When you uncheck 'Package' you get a warning telling you that it may cause runtime issues!
In my case, we had a nested reference to the same library which needed to load before the other library also using it. This fix can be accomplished by unchecking the 'Automatically determine library ordering based on dependencies' and moving the library up in the chain of Build path libraries. Flash Builder was unable to determine the correct order base on dependencies because we had 2 different versions of the same library. The error would only happen during run time.
I had this problem after installing AIR 3.9 and trying to upgrade a project.
It was also saying there was an RSL error, before throwing a succession of #1014 errors.
It worked after I set the textLayout.swc link type in Advanced ActionScript Settings to 'merged into code' instead of the default (RSL)
Hope this helps!
Since I landed on this page searching for this error message and none of the above solutions worked for me, here's how I finally managed to work around it:
It seems that this error happens particularly when you include old libraries that were compiled with the old compiler but compile your app with the new one. Unfortunately the error sometimes fires and when you compile again it doesn't; at other times it works fine in the debug version but then it fails in the release.
What worked for me is to include dummy objects in your main app which are instances of the class that the verify error complains about:
import some.classpath.to.TheClassThatFailsOnVerify;
function YourMainApp(){
var dummy:TheClassThatFailsOnVerify = new TheClassThatFailsOnVerify ();
}
At least in my case the errors only fired for classes that were not used directly in the app but only internally in the swc library code, so by having the dummy objects in the main app I force Flash Builder to include those classes in the compilation.
In some cases you might have to first find the swc that contains the class in question since it's not part of the library swc you use but it's again a library that that swc uses itself.
I'm using FlashDevelop4.0.0 RC1 to create AS3 library project, in which I want to import Away3D library. I follow this tutorial to set up my FD.
http://www.mclelun.com/blog/2011/08/flashdevelop-stage3d-away3d/
However, FD generate error message when I use ExportSWC4.2 plugin to compile the project, I got error message said that
at away3d\materials\methods\TerrainDiffuseMethod_NormalizeKernel.as(10): The definition of base class ByteArrayAsset was not found
Can anyone help me with that? Thanks!
p.s.
I also have issue like the following link
http://sourceforge.net/tracker/index.php?func=detail&aid=3401191&group_id=252536&atid=1127375
not sure if it's related to my problem.
Are you downloading the zip package from http://away3d.com/download/ or accessing via SVN / GIT?
http://away3d.com/images/uploads/releases/away3d_4_0_110915.zip
Not sure about their GIT, but I found the SVN repo dated.
I did not see ByteArrayAsset anywhere in the inheritance chain within my version:
away3d.materials.methods.TerrainDiffuseMethod
away3d.materials.methods.BasicDiffuseMethod
away3d.materials.methods.LightingMethodBase
away3d.materials.methods.ShadingMethodBase
mx.core.ByteArrayAsset is an Adobe class.
There's a NormalizeSplats Pixel Bender linkage, but I did not see any Normalize Kernel.
I'd recommend grabbing the Broomstick ZIP package - I had no issues building the SWC with Flash Builder targeting Flash Player 11.
I am facing a really weird issue while trying to use an "swc" file imported from Flash CS5, that I am trying to use in Flex Builder 3 (by converting symbol to "Flex Component"). The errors are coming in files which are not even remotely related to the "swc" file that i am importing.
Now, I know that the automation stuff has come as a part of FB4, but I don't really have an option to migrate to FB4.
I have tried to change the flex sdk settings in Flash CS5 (steps given below), but that has not helped.
Edit-->Preferences-->Actionscript-->"Actionscript 3.0 Settings"-->"Flex SDK Path" (pointing this to flex3.5 sdk instead of Flex4.0 sdk)
I feel that the issue is most probably a compatibility issue b/w Flex 3 and Flex 4, but have not been able to find a workaround for the same. Any help is greatly appreciated.
Thanks,
Kapil
Here is the trace:
Severity and Description Path Resource Location Creation Time Id
1044: Interface method createAutomationIDPartWithRequiredProperties in namespace mx.automation:IAutomationObject not implemented by class com.sparsha.view.ui:SchematicWindow.
1044: Interface method createAutomationIDPartWithRequiredProperties in namespace mx.automation:IAutomationObject not implemented by class
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class com.sparsha.lib.controls:CloseableTabBar.
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class
1044: Interface method get automationEnabled in namespace mx.automation:IAutomationObject not implemented by class com.sparsha.lib.layouts:DockedAppLayout.
OK, first, the error: this means that Flash probably generated a class for the symbol you are importing using a certain template, where the template doesn't fit the SDK you are using to compile the project. Specifically, the generated class did not implement the methods listed in the error message. I.e. your framework.swc has a definition of mx.automation:IAutomationObject that has method createAutomationIDPartWithRequiredProperties() (nice name btw), but Flash generated code that reads as
package com.sparsha.view.ui {
import mx.automation:IAutomationObject;
public class SchematicWindow implements IAutomationObject { . . . } }
Since you cannot do anything about Flash not generating the method you need, your only way is to monkeypatch the SDK. I.e. copy the mx/automation/IAutomationObject.as from the SDK sources to the classpath of your project. Remove the conflicting method declaration (this may or may not result in other errors). If it results in further errors, repeat the same procedure for every class that "misbehaves"...
However, monkeypatching will mean that you are no longer able to use framework RSLs, as they will come with the original version. So, I would try to avoid the problem altogether and look for another way of exporting symbols from Flash IDE, for example, by not making them a Flex component. Or, if you really insist on them being a Flex component, then bootstrap the FlexSprite, for example, and assign your Flash symbols the bootstrapped class as the "parent class".
I was also having this problem recently. I would get the errors when I included the flash generated swc in my flex projects lib folder.
I was able to work around the issue by upgrading my flex to the flex 4.5.1.21328A SDK.
Additional Details about my project that might help others:
My swc was generated from Flash Professional CS5.5 and my Flex Project was being used in Flash Builder 4.5.
My swc was published to Flash Player 9 with ActionScript 3.0.
My flex project was using the 3.5.0.12683 SDK.