Using Flex compiled code within Flash!
Why did I put effort in combining Flash and Flex generated swf’s?
A major AS 3.0 obstacle for me is the fact that the flex RPC sources are not available. This means we can only use rpc.swc supplied within the Flex framework or use a third party library. Another big thing I’ve been messing around with is the idea of using cairngorm within the Flash authoring environment. As we all know cairngorm depends heavily on databinding, one can simulate databinding using simple macros and a preprocessor or one can let the flex compiler do all the hard work and embed the flex generated library into flash. I’ve been trying hard and succeeded in both, just read on…
As I was messing around with flex (compc) generated swc’s and things like playerglobal.swc, flex.swc, rpc.swc, etc… I came to found out that Flash actually compiles code against swc’s!! Yes, that’s compiling, this means NO linking! So, the linking part has to be done manually… Do you remember ‘intrinsic classes’ back in the good old AS 2.0 days? This result is the same, but you’re not dealing with exclusion xml’s and or the ASI files!
In short, what do you need to do?:
- First create a class that will import your needed dependencies (mx.*, whatever you need!)
- Now create your component library from your class file with ‘compc’, for ex:
‘compc -source-path . -include-classes FooLib -output=./example.swc’
You should now have an swc file which you can use to compile against. In the flash authoring environment the swc is only used for type checking, think of it as an intrinsic package! - Now you’ll compile the library that you’ll dynamically load to access your classes:
mxmlc -source-path . -o ./bin/library.swf ./FooLib.as - Before you’re ready to compile against your newly created library you need to load the library at runtime. As far as I can tell there are two options, my favorite is to link against it as a shared library. This allows all your swf’s to run quickly without any actual code! First you make a link to the library and when you’re done you put the movieclip on the first frame of your application. The other option (which is excellent as a preloader btw.) is to use a standard flash.display.Loader. (Just don’t forget to set the ApplicationDomain in the loadercontext or you’re classes will not be accessible!)
- And finally you’re ready to compile your Flash classes against the classes flex compiled for you.
As a proof of concept I’ve converted (read quick & dirty) the cairngorm cafetownsend mxml views to Flash. The views have dependencies on cairngorm and the flex framework (mx.rpc.*, mx.validators.StringValidator, etc..), but they compile without any of these classes in the path just because the swc sits besides the fla! You can download this package here. After you’ve downloaded the flex sdk to your favorite location you need to run ‘compile.cmd’ (put the flex sdk ‘bin’ folder to your path, or you need to edit compile.cmd and at the path in front of compc and mxmlc), this will automate step 2 & 3. Now you can open cafetownsend.fla and compile without any errors.
If you’re only interested in getting webservices support in Flash then download the examples here.
Now let’s use cairngorm within our Flash authoring environment :-)
For ‘Jon Bradley’ from the FlashCoders maillist I tested some flex controls. And yes, that’s possible as well although you need some style classes initialized before adding controls to your view. My first attempt involved custom flex initialization, download that one here. My second attempt has a better workflow: you create a basic flex application which is compiled against your library.swc. This basic flex application is used for initialization when you want it to! The trick involves the overriding of the flex application. If you want to look into this method further then download a working example here.
As far as I (or google) can tell this is the first proper solution to use your flex classes within Flash!
[Edit1]As Geoff van den Ouden found out, this solution does not work instantly with the Flex 3 SDK! You need to add “-compute-digest=false” to as an extra parameter to compc. Or you should download flex 2.0.2.[/Edit1]
[Edit2]Julian Kussman got AIR crashing while using this method. It turns out AIR doesn’t like the shared library option. You can download a working AIR rpc example here.[/Edit2]
Good luck!
cool :>
Fantastic work here. Thanks for doing this.
You’re welcome Mike!
hi please let me know how to put mxmlc and compc in local path…
@greenmailx, I’ve edited the article for you. Forget about the path, just edit compile.cmd and add the path in front of compc and mxmlc. In my case it would look like this:
‘@c:\progra~1\adobe\flexsdk\bin\compc etc..’
Flex Controls in Flash V2 gives me a SecurityError:
Error #2044: Unhandled SecurityErrorEvent:. text=Error #2140: Security sandbox violation: file:///Users/owenvandijk/Desktop/flex_controls_in_flash_v2 Folder/main.swf cannot load file:///Users/owenvandijk/Desktop/flex_controls_in_flash_v2 Folder/flex_app.swf. Local-with-filesystem and local-with-networking SWF files cannot load each other.
FP 9 Update 3 op OSX
@Owen, don’t try to run those swf’s locally (filesystem). They need to be loaded from a webserver or within your flash environment.
@Sander
Even running the sources from within Flash CS3 gives me the same error? Let me try loading from localhost
@owen, don’t know what’s going on but it seems to be working for me:
http://labs.qi-ideas.com/wp-content/uploads/2007/12/flex_controls/
Anxiously awaiting your tutorial :)
cool work …
I’m glad i stubled upon yout post. I’ve been doing some exploration into bootstrapping flex inside flash in order to use parts of the flex framework. It seems like you got a lot further along than I did.
Can you tell me why you use…
if (0)
{
…
}
… in Main.as and Library.as
I know it doesn’t work without it but I don’t understand why it’s needed.
Jamie
It’s just a clause to prevent things from executing, nothing more. In this case it forces the compiler to include the classes in the swf/swc without execution.
I hope that makes things clear for you!
Nice work.
I’ve also made a “Cairngorm Lite” version which works with XML:80 and weighs in at 6KB, perfect for small to medium Cairngorm based Flash development.
Can I have your permission to post this example on Cairngormdocs?
This is a potentially new workflow which really could make an impact on heavy flash site development. Flex developers doing their flex, flash doing flash - but putting it all together with Flash instead of using Flash components in Flex.
@Evan,
Of course you have my permission! I strongly believe in sharing information…
Hello Sander Wichers,
I’m involved in a project, where the GUI part should be made using Flash.
Of course the Flash have some set of GUI controls. But it is not enough.
I have found more powerful controls in the Flex, e. g. Alert, TabBar …
At first I would like to use Flex mx.controls.TabBar in my Flash application code.
I have read this article and tried the procedure explained above, but failed.
Is this possible? If yes, could you please describe the steps more detailed? Do I need to write/compile my application logic using Flex?
this is fantastic - been groaning thinking that I need to rewrite all the RPC classes or do some substandard homebrew solution to get my library working cross platform - thanks!
@Aram,
I’ve made a small tabbar example for you:
http://labs.qi-ideas.com/wp-content/uploads/2007/12/flex_flash_tabbar.zip
Hello Sander Wichers
Thanks for the sample. It works fine in my side.
Seems that it is not possible to use Flex components together with Flash components in the same application. Am I right?
@Aram,
I haven’t tested that, in my head I cannot come up with a reason why that wouldn’t work though…
thanks so much… i can’t wait to play with this futher… just using the webservice for the moment.
Hi Sander,
Thats a great article and really helped me try and connect a webservice and trace back the results. But I am somehow unable to create a standalone component something like “WellManaged” which can be added to Flash CS3 and used as a generic webservice class. I hope I am making sense. Anyone and everyone’s help shall be appreciated.
Sorry guys thats wellconsidered and not wellmanaged…here is the link http://www.wellconsidered.be/blog/2007/10/24/webservice-class-for-as3-in-flash-cs3-update/
@Rajat,
I’m not completly sure what you mean. The only difference with the wellconsidered solution is that their code is embedded in the swf you compiled. In this solution your code is linked, I think you should look more closely at the RPC example. I hope you’ll see that flash compiles against the flex webservice classes it needs (in other words, uses those classes!).
Thanks Sander,
Thanks for ur previous reply!I used ur classes and now I can fetch my data in evetn.result. The only issue now is that I am really unable to store this data into a dataprovider on model. U have used arraycollection beautifully with list control on front end. I want to traverse event.result and thus want this data in form of an XML object or alternatively load this into a datagrid on frame 1. Seeking your help!
@Rajat,
The result can be retrieved using standard XML functions. The following piece of code will work in the webService Stocks exchange example that you’ve downloaded:
var stockListChildren:XMLList = result.children();
for each (var stock:XML in stockListChildren) {
var stockChildren:XMLList = stock.children();
for each (var stockItem:XML in stockChildren) {
trace(stockItem.name() + ” = ” + stockItem);
}
}
There is a good tutorial on this matter on kirupa.com:
http://www.kirupa.com/developer/flashcs3/using_xml_as3_pg1.htm
Ok read this thin few times and checked trough examples and it seems it is impossible to use Flex components in Flash as Flash components because they depend on some Flex root object specifics. Am I right? It just would help a lot if it was possible make them as initial Flash components.
May be somehow extending movie clip is possible so that it will have needed core functions like _app_StylesInit and then using Flex components as is? Is it possible? Or every time when I need Flex component in Flash I will need to do this kind of long process?
If so then it seems that developing components from the start would be better option. They would fit in to the Flash better at least… And will give possibility to control design/style better…
It would be interesting to know your opinion on that question :)
@wonderwhy.er,
I do think it’s possible to make some sort of preview component (stub/dummy) that will be active once you run your application. And yes the process can be simplified. I haven’t given it much thought though… But once you’re able to add components by code you should be able to layout these visually as well!
I’ll think about it further…
Heh that’s good to hear :D I suppose I will stick to my custom made for a while. It is kind of pain for me to use them as you use right now :( Anyways very good work and thanks for the info. Whish you luck with your ideas.
This works great in Flash, but when I try to create an AIR app using this method it crashes. Any clue why? I’ve found 2 or 3 other web service classes for flash and they all crash when trying to access the WSDL at http://www.weather.gov/forecasts/xml/DWMLgen/wsdl/ndfdXML.wsdl
i think it may have somehting to do with namespaces but i don’t know enough about web services to figure it out.
@Julian,
I’ve had one example that only ran on 9.0.45 and upwards, so maybe it has to do with the internal flash version AIR is using, but that’s just pure guessing.
My current AIR configuration is broken, so I’m currently not able to do some testing. Are you able to accesss any other classes within AIR that are compiled with compc/mxmlc? For ex. are you able to run the httpservice example in AIR?
Its a Great work Wichers,
Can i use Flex charts in side Flash in the same way…
I tried it but failed to achieve.
can you please give me some guidance to get it done
Thanks in Advance,
naren
@Naren,
I hope you know how, but first try to display your chart from an mxml file using just pure actionscript. If you’ve got that working then I’ll be happy to assist you further…
Hi, Sander,
Thanks for your good article.
I downloaded flash_rpc_examples.zip to test for Web Service for AS3 in Flash CS3. I found that the zip contains library.swc and library.swf.
I am not sure how I can use this this library in my Flash…I tried to place the swc file in the components directory, but no luck. Also I tried to import the library.swf into my Flash, but no luck…
Could you email or reply me back how to use the library file in my Flash CS3….I think it should be link somehow…
Thank you in advance.
Cool…..I finally figured out for web service!.
I am newbie for Flash, so it will help me a lot.
Thanks!.
Hi Sander,
Thankyou for the reply…
As you said i am able to display a piechart from a mxml file using actionscript. i compiled that using flex builder and able to load it in to flash.
But my requirement is i want to change the chart data with in flash at runtime and see the change immediately. and also want to change the chart (ex:Bar Chart) on user selection from a comboBox with the same data.
Thanks
Naren
Naren,
If you’ve got that working, then you’re a few step removed in getting this to work in Flash. If you want you can sent me (sander at qi minus ideas dot com) your sample and let me see what I can do for you.
Hi Sander,
When I’m using your examples for webservice and httpservice it works fine, but when I re-compile the library.swc and library.swf it doesn’t work. The compiler gives no errors, but when I rebuild my project it’s not able to find the WebService base class.
I’m using the flex 3 sdk, might this be the problem?
Thnx in advance!
Geoff
Hi Geoff,
It looks like flex 3 is outputting a new swc format (version 1.2). I don’t see this swc version number in any other swc that Flash CS3 is using. So I think Flash CS3 is only version 1.0 swc compatible. I tried to set this number to 1.0 but that has no effect for CS3. I think it’s just not compatible.
So stick with Flex 2.02 (http://download.macromedia.com/pub/flex/sdk/flex2_sdk_hf1.zip) if you’re able!
Thanx Sander,
Real nice of you to give me this kind of support. I have been trying to use Flextense in combination with this solution. I have been succesful with services using simple datatypes, but when it comes to complex datatypes (classes) Flash is able to compile using their flextense.core.swc, but finally it doesn’t work. It seems that Flash CS3 isn’t able to really use the stored classes in the swc library.
Do you think that this is the same problem?
Thanx in advance! :)
Geoff,
No that’s something else. What’s the error message you’re getting?
One other thing, don’t let Flash compile against flextense.core.swc, let mxmlc do that! Else there is no option to get the linking to work properly!
Sander,
Well I guess that part of the problem is that I do not fully master the mxmlc-concept in combination with existing swc’s. I work by the following method:
1. I Copy your Library.as class, rename it to lib2.as (also rename inside) and I make a reference to flextense.core.*; . So I replace the mx.rpc libs with flextense.core. I have tried this with core.* or core. it doesn’t matter.
2. I create a new cmd called compile2.cmd and the only line I have their is:
@mxmlc -source-path . -o ./lib2.swf ./lib2.as
3. Now the flextense.core.swc is in the same directory AND in the Flexsdk2\frameworks\libs dir.
4. When I run the compile2.cmd it returns the errors: undefined property AND Definition could not be found.
So I guess that mxmlc has no idea where to look. I really feel like I’m missing something … so close but yet so far :)
I hope the process is clear for you.
Geoff,
You need the ‘-library-path+=.’ parameter. It’s all about knowing how it really works, it took me 2 minutes, here is a flextense weather example for you:
http://labs.qi-ideas.com/wp-content/uploads/2007/12/flextense_example.zip
Sander,
D0h, I found out I really did 2 stupid things. Point 1: As you pointed out not using the library parameter, should have thought of that.
Point 2: I referenced to flextense.core in stead of flexTense.core … so case sensitive will kill you at the end :)
But really man, I’m very happy with your feedback and your help. A whole new world is opening up with this stuff working in CS3. Now I can communicate with my .NET webservices and this is working out-of-the-box and a lot better then manually upgrading AMF.NET to version 3.0
The first thing I’m gonna do now is get some sleep! Cheers and once again, thank you very much!
Hi, Sander.
BTW, I am working on Flash CS3/AS3.
I found a little bit strange behavior.
Once the library is loaded in the first layer like your web service example, then I dropped a button UI component in second layer. When I test this, button was rendered strangely….
I noticed that if the library is loaded in the first layer…it always produces this strange rendering behavior.
If you try this in your environment, I am sure you will know right away what I meant..
For example, in your example.fla (in webservice), drop button UI component in header layer, then test the movie….
Do you know is there any way to prevent this?..
Thanks,
Hi Sander,
I know this is not the correct place my question, but seems you gus are pretty good in Flex and Flash cs3.
Can somebody let me know how to exclude classes in CS3 like *_exclude.xml in flash 8.0
Please help we are converting a huge project from AS2.0 to AS3.0
@ TJ and Sander,
I noticed the same problem. It doesn’t matter what you do, the first-time you load it into the flashplayer UI components go bad. If you refresh the component (like in a webpage) then the controls are ok the second time around.
I have tried quite a lot, not yet able to solve the issue.
@manotosh, check out my latest two articles, that provides all the information you need. Although the article states ‘using flex compiled code in flash’, the method actually gives you back the exclude.xml functionality (you’re not forced to use the flex classes, you can use any class you want to compile it into a ‘library’!).
Play around and you’ll see…
@TJ and @Geoff,
I’m not able to reproduce this, please sent me an example.
Hi Sender,
You wouldn’t need an example. I just did on your example flah file(in the web service example, example.fla).
Just open example.fla in Flash CS3.
Drop a button UI component on header layer.
Test movie.
You will see strange rendering issue.
Thanks,
Hi Sander,
Since yesterday, I’m trying to export an API I made with Flex Builder 2 plug-in for Eclipse so that a designer team could use it and they are working with Flash CS3.
But I tried your method and it doesn’t work. I have some weird errors such as :
TypeError: Error #1006: getInstance n’est pas une fonction.
at mx.core::Singleton$/getInstance()
at mx.managers::PopUpManager$cinit()
at global$init()
at mx.controls::Alert$/show()
at scripts::MyClass()
at Sansnom_fla::MainTimeline/frame1()
or some VerifyError … What is getting on my nerves is that I can start your examples :’( lol please help if you have any ideas ?
Hi Vincent,
When I look at that error I think you’re trying to call a function that doesn’t exist in the library. Is PopUpManager and or Alert embedded in the library?
Hi Sander,
Sorry, it’s just a stupid mistake. I noticed that in that version of my API, I started to use the XIFF API and indeed, I did not import its classes in the Library.
I removed these few lines and it works. I’m quite impressed :) that’s pretty cool ^^
I have a question though :) Must we systematically add all the classes in the if (0) { … } ? Can’t we just put a kind of mypackage.*; as well as a simple import mypackage.*; above ?
Anyway thanks for your stuff :)
You’re welcome. For ‘mypackage.*;’ the compiler is too smart, it will simply not embed the classes then, the compiler is looking for dependencies… (this was not the case in as 2.0)
You probably don’t need the if(0), but thats just there to be secure so nothing gets executed.
Ok thanks a lot Sander :)
Hi I downloaded your codes for flash CS3 webservices. can you expalin how I can customise and use it because when i create a new file and place ur symbols(FLEX Library) its not wrking, whereas it works fine when i use you fla. how the main.swf is published wehn i publish example.fla
Iam a newbie please help me.
thanks
Harish
What can I do to include the CSS styles of Flex into the .swc or the .as?
@Julian,
I’ve had a short look at your problem with AIR. It turns out AIR doesn’t like the shared library option. You can download a working AIR rpc example here:
http://labs.qi-ideas.com/wp-content/uploads/2007/12/air_rpc.zip
Yours, Sander
Many many many thanks! Been looking for a way to get some Flex action going on in Flash. You are the man.
Lets hope they actually make an official solution for this some time…
This is awesome! Not only it solves the Webservices problem but opens doors for whole lot of functionality from within Flash.
Impressive work!
Well, welcome back ^^ I have a new problem. I have to include my components in a Flash application and since last Friday, it worked very well. But now, it seems that Flash CS3 can’t find any of my events class. All the classes in the package mypackage.events failed.
And I got a VerifyError 1014, XXX class not found. It’s quite annoying… I verify that all my classes were included in the Library.as and all so I don’t know what’s the matter… Please, if you have any ideas.
Hi, great stuff from France (sorry for my english)
I’m trying you’re web service example, and it works fine with the flex 2 frameworks (not with the flex 3 frameworks). But just a precision you forgot a class in you’re Library : mx.rpc.soap.LoadEvent witch is dispatched when the WSDL document has loaded sucessfully. Note that in flex 3 this class is deprecated it replaced by mx.rpc.events.WSDLLoadEvent.
my example :
package {
import flash.display.MovieClip;
import flash.text.TextField;
import mx.rpc.soap.WebService;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.soap.LoadEvent;
import mx.utils.ObjectUtil;
public class Main2 extends MovieClip{
//public var debug_txt : TextField;
private var ws : WebService;
public function Main2(){
debug_txt.text = “Calling Webservice…\n”;
ws = new WebService();
ws.wsdl = “http://localhost/Service.asmx?WSDL”;
ws.addEventListener(LoadEvent.LOAD, onWSDLComplete);
ws.loadWSDL();
}
private function onWSDLComplete(evt:LoadEvent):void{
debug_txt.appendText(”\nwsdl loaded:\n”);
ws.HelloWorld.addEventListener(”fault”, faultHandler);
ws.HelloWorld.addEventListener(”result”, resultHandler);
debug_txt.appendText(”Executing HelloWorld…\n”);
ws.HelloWorld();
}
public function resultHandler(evt:ResultEvent):void {
var result : XML = XML(evt.result);
debug_txt.appendText(”\nResult:\n”+result.toXMLString());
}
public function faultHandler(evt:FaultEvent):void {
debug_txt.appendText(”With Error:\n”);
debug_txt.appendText(evt.fault.faultString + “\n”);
}
}
}
@Olivier,
You’re welcome! But you’re not completely right though, “mx.rpc.soap.LoadEvent” is actually included in library.swf, and that’s because all dependencies are automatically embedded. In this case “mx.rpc.soap.WebService” forces the inclusion of LoadEvent. You’ll see that without the import in library.as you’re code will compile as well!
Hi and thank you for this subject. It allow me to use AS3 in my new project which use webservices. I am now trying to migrate to AIR and this trick does not work any more. the air application crashes whenether I insert the flex library in the bibliotheque. Have you been trying it ?
Best regards
Aurelien
@Aurelien, check out the example in the lower part of my post, search on “edit3″.
Great! I had not seen this point, I am going to test it immediatly. Thanks!
Apologize, you are right !
I noticed in the library.swc file there are the mx.rpc.soap.LoadEvent classe in the node name mx/rpc/soap/WebService in the catalog.xml file.
Just for persons who are searching personnal classes for web service Mr Carlo Adulcente : (http://labs.alducente.com/?p=5) has done a nice job.
Thanks again !
Hi Sander,
I am wondering if you have come in to this problem. I think it is relevant here as there would be many people looking at this blog looking for ways to use RPC classes outside of the Flex Framework.
I am finding that when I make a simple AMF request through RemoteObject from within an Application component in Flex it is successfull yet when I try to do the same using the flex RemoteObject class in a simple Actionscript Project or with the CS3 integration method you have detailed here the initial connection header is corrupted and does not show up as a flex.messaging.messages.CommandMessage but as a generic Object. This causes in my case AMFPHP to return a garbled message which in turn cannot be parsed by RemoteObject into an error message.
To reproduce try the following:
I have set up a HelloWorld service with a say method accepting a string argument (default AMFPHP service)
This MXML code works:
But if I compile an Actionscript only class from the following code (very similar just without the Flex Framework):
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.Graphics;
import mx.rpc.remoting.RemoteObject;
import mx.messaging.ChannelSet;
import mx.messaging.messages.CommandMessage;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.core.Application;
import mx.rpc.remoting.Operation;
public class RpcCs3Checker extends MovieClip
{
public function RpcCs3Checker()
{
var button:Sprite = createSprite();
button.addEventListener(MouseEvent.CLICK, handleClick);
addChild(button);
}
private function handleClick(e:MouseEvent):void
{
var remoteObject:RemoteObject = new RemoteObject();
// Required but not used since we are using AMFPHP
remoteObject.destination = “this-is-not-used”;
remoteObject.source = “HelloWorld”;
var chs:ChannelSet = new ChannelSet();
chs.addChannel(new AMFChannel(”my_unique_id”, “http://abx/gateway.php”));
remoteObject.channelSet = chs;
remoteObject.addEventListener(ResultEvent.RESULT, handleResult);
remoteObject.addEventListener(FaultEvent.FAULT, handleFault);
var op:Operation = remoteObject.say;
remoteObject.say(”This is something to say”);
}
private function createSprite():Sprite
{
var sp:Sprite = new Sprite();
var g:Graphics = sp.graphics;
g.beginFill(0xFFFFFF);
g.drawRect(10,10,50,20);
g.endFill();
return sp;
}
private function handleResult(e:ResultEvent):void
{
trace(”result”);
}
private function handleFault(e:FaultEvent):void
{
trace(”fault”);
}
}
}
I get this error:
TypeError: Error #1034: Type Coercion failed: cannot convert Object@e114921 to mx.messaging.messages.ErrorMessage.
Which upon investigation with an AMF snooper seems to be based on the initial connection message not being of the correct object type as stated above.
I think this is a bug within the RPC code although since the code is closed source it is very frustrating to comeup with the ultimate problem and hence develop a workaround.
Any ideas here?
Rudi
@Rudi, no time yet to dive into this just yet… But are you sure you’re not trying to mix AMF0/AMF3 code? And are you using the amfphp 1.9 (amf3) version?
Rudi,
I’ve got things working for you, check out my remoting example:
http://labs.qi-ideas.com/wp-content/uploads/2007/12/remotingservice.zip
I’ve used ServerConfig instead of your custom channel code, but that’s just for convenience (although you’re example is cleaner!). The only thing you need to add are some registerClassAlias calls to your code! I’ve added the necessary ones to my example (ErrorMessage and the sorts).
Good Luck!
wow thanks so much for checking this out so quickly. yep sorry should have pointed out was using AMFPHP 1.9 and Flex 2.01. will check this out once i get back to the office.
Sander I owe you a beer! ….next time i am in the ‘damm’ i let you know!
Hello Sander, do you know if all the classes of the Library.as must be listed in a particular order (such as the order in the packages, directories ?)
We face a compatibility problems with only a few classes (custom events classes it seems) and we don’t know what’s going on. [VerifyError 1014, XXX class not found.] The compilation is OK but when you start the application, it displays this error.
I succeeded in correcting the problem in my version of the sources but I don’t know how. A colleague faces the problem but we have the same version of the class file that is not found.
@Rudi, :-) you’re welcome!
@Vincent, the order of the classes is not important, no. Maybe it has to do with the loading of the library?! I’m suspecting that. Try to download the AIR example on the bottom of my article and see if that works…
Hi Sander, thx for sharing your solution. I’ve been working on a project using your flex webservices lib. It works great, but only in flash players higher then 9.0.28. When using 9.0.28 the script crashes immediately after the webpage is loaded without a clear error. Do you have any idea what the problem might be and do you have a solution to this problem?
I also used the flash components in this project, they didn’t render correctly and found that by adding them with actionscript on init in stead of with the flash IDE they’ll render correct.
Hi Bram, it could be the shared library stuff, you should download the AIR example and see if that works in 9.0.28…
It’s great that you’ve found the solution with the regular flash components. Could you subscribe the steps in detail, so I can add these to my blog entry? (I’ll put you’re name behind it as well :-))
Thx Sander, using the method cfr the air example it also works in flash player 9.0.28. Nice!
if you add the components with code they render correctly, not really handy, but it works.
You can draw the comboboxes in the flash IDE and note their coordinates, delete them and add them with actionscript
I used checkboxes, lists and combobox in my project
using a standard combobox for example:
import fl.controls.CheckBox;
import fl.controls.List;
import fl.controls.ComboBox;
public class Main extends Sprite {
private var myCombo:ComboBox;
public function Main():void {
createComponents();
}
private function createComponents():void{
myCombo = new ComboBox();
myCombo.x = 120;
myCombo.y = 333;
myCombo.height = 22;
myCombo.width = 64;
addChild(myCombo);
}
}
Hi Bram, your welcome! Ok that’s not the neatest solution I must say. I will look into the real problem when I have some spare time…
Hi Sander,
Great article… however I desperatly need your help to get it to work…. here is what i did.
1) Downloaded Flex2 and Webservices Sample Zip
2) changed compile.cmd to point to sdk
3) compiled and moved library.swf to my fla folder
4) Created a Symbol called flexlib, import for runtime sharing, URL = library.swf class = flash.display.MovieClip
5) Dragged clip onto fla first frame
6) Tried import mx.rpc.soap.WebService; in an as
7) Test project I get error:
Definition mx.rpc.soap.Webservice could not be found
Damn I’ve tried everything .. what am I missing?
Any help would be awesome (email if you like)
Bill
As a follow up Sander ..
I am running Vista and CS3 and I cannot get your webservice example to work either .. same errors
1046: Type was not found or was not a compile-time constant: ResultEvent.
Sob!
Sander, great work btw!
Re. webservice are you (or any1) able to post an example using namespace in the XML response. I can navigate the response object using event.result. But cannont seem to parse to XML if it contains namespace.
public function resultHandler(event:ResultEvent):void
{
trace(event.result.diffgram.DocumentElement.LibraryExitPoints.id) //works
trace(event.result.diffgram.DocumentElement.LibraryExitPoints.@id) //doesnt - because its not xml yet
var test:XML =
Zmed
Sue
Data analyst
;
trace(test..firstName[0]); //works
var result:XML = XML(event.result);
trace(result); //traces [object Object]
trace(result.toString() ) //traces [object Object]
trace((result..id)[1]) //traces undefined
great works!,
i have a problem on result,
i can’t receive an array complex from soap php.
not any kind of event.
Does anyone out there have a copy of Carlo Alducente’s AS3 web service package (GORF) mentioned by Olivier in comment 67?
All Carlo’s web links seem to be down and I am desperate for it!
If you got a copy kicking and could mail to
me-at-richardmaunder.com (replacing -at- with @ of course)
I’d be hugely grateful!
Keep up the good work
Richard
Hey guys, I downloaded Flex SDK 3.0 From Adobe Website. But how do i extract the class from sdk to the Flash Cs3 Professional Class? i read the above but i still dont understand. I need the Webservices from Flex very much. How do i do that? Sander Can you send me through my email? Thanks.
I had created the components in flex and builded it in swc file format, and its working in Flex application, now i want to know
How to integrate that Flex builded components to the Adobe Flash CS3…
Let me know
[…] Flash CS3 / Web Services Missing web services in Flash CS3? Useful links for people looking for the missing classes: Custom Class wellconsidered » Blog Archive » WebService class for AS3 in Flash CS3 Webservices from Flex re-packaged so it can be used in Flash CS3 Using Flex compiled code within Flash! : Qi Labs […]
[…] AS3 Umsetzung. Nach langem Suchen fanden wir die für uns perfekte Lösung. Auf der Seite von qi-ideas wurde die Idee der sharedLibrary […]
Great stuff! The air rpc example helped me a lot to create an air application with flash cs3, using fluorinefx aperture to call a .net assembly. (Fluorinefx aperture needs some flex things)