View Full Version : Flex 3 embedding Flash swf referencing resources
luis_costa
08-03-2009, 12:14 AM
Hi,
I’m trying to insert a Flash component “flashComponent.swf” in a SWFLoader source (see code bellow) this Flash component have some reference to a xml file that have other references to image files.
When I run this, the component appears but no images are display.
Question:
Shall I do any reference to XML and all image resource files, how can I do that?
Thank you,
Luis
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="400" height="300">
<mx:Script>
<![CDATA[
[Embed(source=’flashComponent.swf')]
[Bindable]
public var imgCls:Class;
]]>
</mx:Script>
<mx:SWFLoader x="10" y="10" width="380" height="280" autoLoad="true" scaleContent="true" source="{imgCls}" id="teste"/>
</mx:Module>
wvxvw
08-03-2009, 06:58 AM
All you have to do is to ensure the XML and image files exist in where you defined them in XML relatively to the compiled SWF. This would usually be your bin/debug or bin/release folder.
luis_costa
08-03-2009, 01:28 PM
Thank you for your help but I already had ensure that XML / images where in my bin/debug folder, I can open with success the flash component swf contained in my bin/debug folder but once I open the flex swf the flash component dosent work propertly,
what this flash component do is read from a xml and then get some pictures to disply, I put this flash component in a SWFLoader in my flex aplication.
could anyone could help me?
many thanks
wvxvw
08-03-2009, 01:53 PM
Well, few more questions:
Was the script in Flash SWF on the timeline, or did the SWF had a document class?
What error do you get when you debug it?
If your code looks exactly like you pasted it, then the first (opening) quote in [Embed] tag doesn't match the closing quote.
Are you sure you embedding entire SWF and not the symbols from it (in latter case DoABC tag is not created for embedded symbols - no code embedded, only graphics).
Are you by chance trying to embed AS2 SWF? In which case check if you have referenced _root, _levelX, or used loadMovieNum or some other legacy stuff in there.
luis_costa
08-03-2009, 08:13 PM
Ok tha flash component is on this: http://www.flashmo.com/preview/flashmo_132_horizon,
I try to put this flash component in a SWFLoader, could you try this if it works with you?
Thanks,
Luis
wvxvw
08-04-2009, 04:22 PM
OK... it's not a component... it's just a timeline code... well, timeline code isn't parsed by MXMLC transcoder, so, this would probably explain it... If you still want to use that code, I'd recommend you refactoring it into class, and using the class rather than embedding SWF.
luis_costa
08-07-2009, 06:45 PM
Thank you for your help I realy apreciated, I really what to use this code,
just one more thing how can I refactor it into a class?
Do I have to do it in flex (how)?
Or in flash(how)?
and then whats the correct way to use yhis class?
Thank you soo much :)
wvxvw
08-08-2009, 02:31 AM
I'd do it like this:
create new AS file with this content:
package
{
import flash.display.Sprite;
// paste the variables declaration here
public class FlashComponent extends Sprite
{
super();
// paste the variables initialization here
}
// paste the method declaration here
}
Also keep in mind that classes require access modifier, unlike timeline scripts which are always scoped to internal namespace, class memebrs can be in different namespaces. However if you omit the modifier, the members will be scoped to "internal" in the class too, it will give you a warning and will not compile in strict mode.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.