How do you set up a pure AS project using OSMF source code?

My current project requires me to use the OSMF 2.0 source code, instead of the osmf.swc included in flex 4.6 or earlier flex sdks.

For the moment, I've added the source directly within my project's src/ folder (i.e. src/org/osmf/...).  Code completion correctly finds and imports code from these classes.

However, on compilation of this code (the only line currently using OSMF):

        var resource:URLResource = new URLResource("media/prog_index.m3u8");

I get this error:

[Fault] exception, information=VerifyError: Error #1014: Class org.osmf.media::URLResource could not be found.

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

 at java.util.ArrayList.RangeCheck(ArrayList.java:547)

 at java.util.ArrayList.get(ArrayList.java:322)

 at flash.tools.debugger.concrete.DManager.getFrame(DManager.java:671)

 at flash.tools.debugger.concrete.PlayerSession.pullUpActivationObjectVariables(PlayerSession.java:1113)

 at flash.tools.debugger.concrete.PlayerSession.requestFrame(PlayerSession.java:1091)

 at flash.tools.debugger.concrete.PlayerSession.getValue(PlayerSession.java:1206)

 at flex.tools.debugger.cli.ExpressionContext.memberNamed(ExpressionContext.java:430)

 at flex.tools.debugger.cli.ExpressionContext.locateParentForNamed(ExpressionContext.java:532)

 at flex.tools.debugger.cli.ExpressionContext.determineContext(ExpressionContext.java:482)

 at flex.tools.debugger.cli.ExpressionContext.resolveToVariable(ExpressionContext.java:342)

 at flex.tools.debugger.cli.ExpressionContext.lookup(ExpressionContext.java:161)

 at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:160)

 at macromedia.asc.parser.ThisExpressionNode.evaluate(ThisExpressionNode.java:34)

 at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1029)

 at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)

 at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1029)

 at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)

 at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1063)

 at macromedia.asc.parser.ExpressionStatementNode.evaluate(ExpressionStatementNode.java:50)

 at flash.tools.debugger.expression.DebuggerEvaluator.evaluate(DebuggerEvaluator.java:1304)

 at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)

 at flash.tools.debugger.expression.DebuggerExpression.evaluate(DebuggerExpression.java:105)

 at flex.tools.debugger.cli.ExpressionCache.evaluate(ExpressionCache.java:100)

 at flex.tools.debugger.cli.DebugCLI.evalExpression(DebugCLI.java:3648)

 at flex.tools.debugger.cli.DebugCLI.evalExpression(DebugCLI.java:3640)

 at flex.tools.debugger.cli.DebugCLI.doPrint(DebugCLI.java:3566)

 at flex.tools.debugger.cli.DebugCLI.processLine(DebugCLI.java:6551)

 at flex.tools.debugger.cli.DebugCLI.process(DebugCLI.java:734)

 at flex.tools.debugger.cli.DebugCLI.execute(DebugCLI.java:576)

 at flex.tools.debugger.cli.DebugCLI.main(DebugCLI.java:373)


My guess is that there's an older osmf.swc that's being compiled into the project, which doesn't contain the URLResource class.  I've looked at my module settings, and don't see any osmf.swc included in the flex framework - only playerglobal.swc.  I'm not sure where else to look.

How can I get my project to compile in IntelliJ IDEA?  for the moment, to get my work done, I'm having to use Flash Builder which is really frustrating.

Thanks in advance,
Kathryn

7 comments
Comment actions Permalink

According to the stack trace compilation completes successfully and this exception happend when swf is started for debugging.

Yes, the problem is probably because osmf.swc form SDK is used. You'll see it if you expand Flex SDK node in the table on the Dependencies tab of the build configuration (Project Strunctuer dialog). You need to do following:
- Project Structure dialog, SDKs, add one more Flex SDK 4.6, give it a name like 'Flex SDK 4.6 pure AS'
- from its Classpath tab remove osmf.swc (you may remove more SWCs that are not filtered out automatically for pure AS projects if you need)
- set this SDK for the build configuration (Dependencies tab)
- make sure that there's no more osmf.swc root under Flex SDK node in the table
This should help.

And i'd like to give advice regarding osmf 2.0 sources configuration. If you are going to edit them - it is ok to have them in your src folder (or you can create a second separate source root to distinguish osmf source code from your other code). But if you want to use osmf sources as raw AS library - you'd better configure it as a raw AS library. For convenient reuse you may configure it at global or project level. E.g. go to Project Structure | Global libraries, press [+], select ActionScript/Flex library type, select osmf 2.0 source folder (it should not be within you source root in this case!) and make sure that is is detected as raw AS library. Then go to Dependencies tab of the build configuration and add dependency on this global library.

0
Comment actions Permalink

Thanks Alexander.  You're right, it was a runtime error, my mistake.

Also, yes, I am modifying the source code, that's why it's in my src/ :-)

Unfortunately, your solution does not work.  As I noted above, I don't see an osmf.swc in the Module Settings (== Project Structure) of my previous project.  I followed your advice anyway and created a new "pure AS sdk", which had a much longer list of swcs than just playerglobal.swc, including OSMF.  I removed osmf.  Set my previous project to use this new sdk.  Got the same runtime error.

Other ideas?

0
Comment actions Permalink
I don't see an osmf.swc in the Module Settings of my previous project

By default pure AS project in IntelliJ IDEA contains not only playerglobal.swc. Reducing the swc list requires a hack with SDK configuration that I described. How could you get rid of osmf.swc without this hack?
Untitled.png
Anyway, I tried to create sample project to reproduce the issue, but haven't seen any errors with both standard or reduced pure AS SDK. Can you please check my attached project and modify it to reproduce the issue?



Attachment(s):
UsingOsmf2.zip
0
Comment actions Permalink

Thanks again, I'd be happy to check it.  I see that you've put osmf_src into a separate src folder, which is basically the only difference from my project.  

What's your run configuration?  When I try creating an HTML wrapper, the dialog isn't coming up with a name for the swf.  I can enter UsingOsmf2.swf there, but when I try to debug, I get

Flex Debugger Startup Error
Failed to connect; session timed out.

In the meantime, since I can't run yours, I made a similar test app, with the osmf source within the main src/ folder, which produces the runtime error.



Attachment(s):
Test.zip
0
Comment actions Permalink

OMG! That must have been my first question: what IntelliJ IDEA version do you use! Thank you for the sample project, now I see that you use IntelliJ IDEA 11.0 or older. And all my answers assume that you use version 11.1.x.

There's no convenient way to work with pure AS projects in version older than 11.1, so please consider upgrading. Note that we have completely redesigned ActionScript and Flex project setup in IntelliJ IDEA 11.1. Now you can explicitly mark your Flash build configuration as 'Pure AS' and my hack with removing osmf from sdk will work (though looks like it is not needed, but may be done for clarity).

Workflow with HTML wrapper is also changed - now it is close to Flash Builder concept - you keep HTML template in a separate folder (like 'html-template'), but not in the source root.

One or two source roots for osmf and other classes - that doesn't make any difference for compilation/running. I just think that keeping different things in different folders is more convenient.

0
Comment actions Permalink

Aha!  That's that problem.  My version (10.4 or 10.5) is misleading, because in the Flex project setup dialog there was an option to create an AS project, so it wasn't clear that the functionality wasn't there.  

Anyway, I've both purchased the upgrade to 11.1, and am using the 30-day trial while waiting for my new license key.  And setting up the project as you suggest above works out of the box, without requiring me to remove any swcs.

Now I can start plowing ahead on this project again and make my boss happy.

Thanks so much for your help!  

0
Comment actions Permalink

Thanks Alexander! Using IntelliJ 11.1, I no longer experience this problem.

0

Please sign in to leave a comment.