One of the most common requests for the Flash team is to provide a Webservice component for Actionscript 3.0 like the one Flash has for Actionscript 2.0. Finally, Flash has provided the features in CS4 to allow users to use any Flex components that does not rely on Flex framework such as Flex WebService component and HTTPService.
In the below example am going to demonstrate how users can use Flex WebService in Flash to get countries names and populate them in a Flash DataGrid component.
1. File > New
2. Select "Flash File (Actionscript 3.0)".
3. Open the Component panel and drag a DataGrid component to the stage and call it "dg".
5. File > Publish settings and click on "Flash" tab.
6. Click on "Settings" button to launch "Advance Actionscript 3.0 Settings"
7. Click on the "library path" tab
8. Click on "Browse to SWC file" icon and get the "framwork.swc" and "rpc.swc" from the Flex SDK as follow :
You can download FlexSDK and select the above SWC's from the following location
"sdks/3.0.0/frameworks/libs/"
9. Open the action panel and import the following:
import mx.rpc.soap.*;
import mx.core.*;
import mx.rpc.events.*;
import fl.data.DataProvider;
10. The following 2 lines of code are required if you are using SDK 3.0.0 but not if you are using higher version of SDK
//The following 2 lines to register class for
//Interface"mx.interface::IResourceManager
var resourceManagerImpl:Object = ApplicationDomain.currentDomain.getDefinition("mx.resources::ResourceManagerImpl");
Singleton.registerClass("mx.resources::IResourceManager", Class(resourceManagerImpl));
11. Now copy the following and paste below the above 2 line of codes
var foo:WebService = new WebService();
foo.addEventListener("load", finishedLoading);
foo.loadWSDL("http://www.webservicex.net/country.asmx?WSDL");
var myOperation:Operation;
function finishedLoading(evt:LoadEvent):void
{
myOperation = Operation(foo.getOperation("GetCountries"));
myOperation.addEventListener("fault", wsdlFault);
myOperation.addEventListener("result", wsdlResult);
myOperation.send();
}
function wsdlFault(evt:FaultEvent):void
{
trace(evt.fault);
}
function wsdlResult(evt:ResultEvent):void
{
trace(evt.result);
var myResult:Object = evt.result;
var len:Number = myResult.length;
var xml:XML = XML(evt.result);
var dp:DataProvider = new DataProvider(xml);
dg.dataProvider = dp;
}
12. Test Movie and you should get a list of all the countries inside the datagrid :
Thursday, October 23, 2008
Using Flex Webservice component in Flash CS4
Bookmark this post:blogger tutorials
Social Bookmarking Blogger Widget |
Thursday, September 25, 2008
Flash CS4 and Flex Metadata
In previous versions of Flash up to Flash CS3 , Flash did not support many of the Flex Metadata such as :
* Embed
* IconFile
* ResourceBundle
* Style
The most common metadata complained about is Embed metadata. Flash CS4 has added support to many of these metadata which will help developers to write code in Flex and testing it in Flash without worrying about incompatibilities at least in this area. In this post am going to talk about Embed metadata and show some examples.
Users can use embed metadata to embed the following type of assets :
* Image (GIF, JPEG, PNG).
* SVG.
* Sounds.
* SWFs (both AS2 and AS3).
* Symbols extracted from SWFs (not sure if AS2 or AS3 or both supported).
* Fonts from AS2 SWFs only (i think, maybe from AS3 SWFs as well).
Example : in the following example am going to embed GIF using Embed metadata.
1. Launch Flash CS4
2. File > New and select "Actionscript File".
3. Copy and paste the following code
package {
import flash.display.*;
public class GIFEmbed extends Sprite {
[Embed(source="../assets/tala.gif")]
private var theClass:Class;
public function GIFEmbed() {
var displayObj:DisplayObject = new theClass();
addChild(displayObj);
}
}
}
4. Save the AS file and give it a same name as the class name " GIFEmbed.as "
Note : [Embed(source="yourAssets.gif")] this is where you point to the actual assets.Please change the yourAssets.gif with the absolute path or relative path to your assets.
5. Create a Fla file and save it in the same place where the AS file is.
6. Add the GIFEmbed.as file as document class.
7. Test Movie.
8. You will get the following warning message as follow :
9. Click "Update Library path" button to add the path of the Flex.SWC to your library path.
10. Test Movie. Your image should be successfully embedded.
* Embed
* IconFile
* ResourceBundle
* Style
The most common metadata complained about is Embed metadata. Flash CS4 has added support to many of these metadata which will help developers to write code in Flex and testing it in Flash without worrying about incompatibilities at least in this area. In this post am going to talk about Embed metadata and show some examples.
Users can use embed metadata to embed the following type of assets :
* Image (GIF, JPEG, PNG).
* SVG.
* Sounds.
* SWFs (both AS2 and AS3).
* Symbols extracted from SWFs (not sure if AS2 or AS3 or both supported).
* Fonts from AS2 SWFs only (i think, maybe from AS3 SWFs as well).
Example : in the following example am going to embed GIF using Embed metadata.
1. Launch Flash CS4
2. File > New and select "Actionscript File".
3. Copy and paste the following code
package {
import flash.display.*;
public class GIFEmbed extends Sprite {
[Embed(source="../assets/tala.gif")]
private var theClass:Class;
public function GIFEmbed() {
var displayObj:DisplayObject = new theClass();
addChild(displayObj);
}
}
}
4. Save the AS file and give it a same name as the class name " GIFEmbed.as "
Note : [Embed(source="yourAssets.gif")] this is where you point to the actual assets.Please change the yourAssets.gif with the absolute path or relative path to your assets.
5. Create a Fla file and save it in the same place where the AS file is.
6. Add the GIFEmbed.as file as document class.
7. Test Movie.
8. You will get the following warning message as follow :
9. Click "Update Library path" button to add the path of the Flex.SWC to your library path.
10. Test Movie. Your image should be successfully embedded.
Bookmark this post:blogger tutorials
Social Bookmarking Blogger Widget |
Monday, July 21, 2008
About Me
HI All,
My name is Tareq AlJaber, I work for Flash Authoring team focusing on components, Actionscript 3.0 tools and Compiler.
In my upcoming posts i will be talking about tools that beginners can use to create interactive flash content using Actionscript 3.0 and help them gain the knowlodge needed to get them into a professional level in writing application using Adobe Flash Authoring.
I will also have some live training based on the requests/demands.
Thanks and Welcome to my Blog
Tareq
My name is Tareq AlJaber, I work for Flash Authoring team focusing on components, Actionscript 3.0 tools and Compiler.
In my upcoming posts i will be talking about tools that beginners can use to create interactive flash content using Actionscript 3.0 and help them gain the knowlodge needed to get them into a professional level in writing application using Adobe Flash Authoring.
I will also have some live training based on the requests/demands.
Thanks and Welcome to my Blog
Tareq
Bookmark this post:blogger tutorials
Social Bookmarking Blogger Widget |
Subscribe to:
Posts (Atom)