Embedded AS3 SWF access in Flex 2

I have an SWF (Action Script 3) created in Flash 9 Alpha
Public.
I can access all its methods and variables when using
SWFloader, but fail to do so when embedding it by using [Embed]
tag.
I need to do it to use it as a custom cursor (CursorManager
accepts objects of Class type as cursors). Before I was using SWF 8
(AS2) with LocalConnection, but since the new SWF 9 is in Action
Script 3, I want to use it directly.
The code looks like this:
[Embed(source = "cursor_9.swf")]
private var newCursorSymbol:Class;
private function changeCursor(event:MouseEvent):void
CursorManager.setCursor(newCursorSymbol);
The question is. Can I, and if I can, then, how, access this
swf methods from within a Flex 2 application?
or else, can the CursorManager somehow accept the content of
SWFloader, which is a MovieClip object?
Thank you

This is tough. The DisplayObject that represents the customer
cursor is instantiated internally by the CursorManager and is
stored in a private variable, so there's no way to get at it. I
believe there is a hack you can do if you ever only have one
instance of that cursor. The Class you pass to the CursorManager
can be any DisplayObject, so you can cook one up to wrap your SWF.
For example, call it MyCursor.mxml:
<mx:Canvas xmlns:mx="...">
<mx:Script>
<![CDATA[
public static var sCursorLoader: SWFLoader;
]]>
</mx:Script>
<mx:SWFLoader id="loader" source="cursor_9.swf"
creationComplete="sCursorLoader = loader"/>
</mx:Canvas>
And then use the CursorManager:
CursorManager.setCursor(MyCursor);
The idea is that once the CursorManager instantiates the
MyCursor class, the static variable will point to the SWFLoader, so
you can access it in a global way:
MyCursor.sCursorLoader
Of course, you'll have to put in some kind of delay to make
sure the SWF is completely loaded, etc. This is just something I
thought of off the top of my head, so take it with a grain of salt.
:-)

Similar Messages

  • Flex to AS3 swf

    I want to get swf files I have produced in Flash Builder 4.5 into Prezi.
    They require what they are calling an "AS3 SWF" file for loading.
    My SWF from FB is not making the trip.
    Any ideas as to how I can get my FB swf to be/look like an AS3 swf?
    Thanks.

    Flex has several dependencies on the framework itself. If you want to bring it into Prezi, I'd create it in Flash and keep it pure actionscript.

  • Flash SWF (with as3 code) integrate in Flex probelm

    Hello everyone,
    I'm having a problem to make my Flash SWF working in Flex. I
    created an animation movieclip, made a button and wrote a script to
    play this movieclip in Flash. Everything works fine but when I use
    SWFLoader in Flex to integrate this SWF in my application. This
    "play" button is working anymore in Flex.
    Should I remove the button and script in Flash and put them
    in Flex? How could I write the script in Flex to call a function to
    play this SWF?
    Is there any other way to solve this problem?
    Thank you in advance.

    "Smile2JP" <[email protected]> wrote in
    message
    news:gmqtde$fbi$[email protected]..
    > Hello everyone,
    >
    > I'm having a problem to make my Flash SWF working in
    Flex. I created an
    > animation movieclip, made a button and wrote a script to
    play this
    > movieclip in
    > Flash. Everything works fine but when I use SWFLoader in
    Flex to integrate
    > this
    > SWF in my application. This "play" button is working
    anymore in Flex.
    >
    > Should I remove the button and script in Flash and put
    them in Flex? How
    > could
    > I write the script in Flex to call a function to play
    this SWF?
    > Is there any other way to solve this problem?
    I have an example on my blog that demonstrates controlling a
    Flash movie
    from Flex:
    http://flexdiary.blogspot.com/2009/01/example-of-casting-contets-of-swfloader.html
    I included links to more basic examples in the code, so you
    might find one
    of them helpful even if this isn't.

  • Can I load a swf into my Flex app that loads other swf's?

    The code below loads an AS2 swf into my Flex mobile for IOS app and it works.  If that AS2 swf has like a circle in it that runs across the stage, it loads and displays properly when run in FlashBuilder.
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                     xmlns:s="library://ns.adobe.com/flex/spark"
                                     xmlns:mx="library://ns.adobe.com/flex/mx"
                                     initialize="init()">
              <fx:Script>
                        <![CDATA[
                                  import mx.core.UIComponent;
                                  private var request:URLRequest = new URLRequest("http://PATH_TO_AS2_SWF");
                                  private var loader:Loader = new Loader();
                                  private var myComponent:UIComponent = new UIComponent; 
                                  private function init():void{
                                            myComponent.percentHeight = 100;
                                            myComponent.percentWidth = 100;
                                            loader.load(request);
                                            myComponent.addChild(loader);
                                            player.addElement(myComponent);
                        ]]>
              </fx:Script>
              <s:Group id="player"
                                   height="100%" width="100%"/>
    </s:Application>
    But if that AS2 swf loads other swf's, they don't load or display.  My FlashBuilder debugger reports no errors or security sand box violations.   I'm using the most elemental code in my AS2 swf so as to not cause problems.  This is it in its entirety:
    this.onLoad = function(){
              _root.loadMovie("http://[PATH_TO_REMOTE_SWF]");
    The paths to the remote content are fine because swf's load and display fine from AS2 swf when run on it's own - not embedded in Flex app.  They also load and run fine if I cut out the AS2 swf and access directly from my Flex code.  So I know there isn't a path issue.  More likely not accessing the right layer in the AS2 swf from Flex or something.  Or maybe security sandbox violation but I don't see anything reported in the FlashBuilder debug console.  When run console just reports:
    [SWF] SwfMobile.swf - 2,639,761 bytes after decompression
    [SWF] assets/swf/AS2.swf - 1,470 bytes after decompression
    Is there something inherently wrong with loading swf's that load other things?  Even if I have the AS2 swf load jpgs they don't load so the format of the target content at the end of the chain doesn't seem to be the issue.  Just the act of embedding a swf that loads other things seems to be the problem.

    Ah, yes. Using an AVM1 SWF could prove difficult...
    I'm going on about 3 hours of sleep at the moment, but let me toss out a few thoughts I have and hopefully something will stick...
    Ok, so my first thought what to try and cast the loaded content as a MovieClip and call methods on that, but the fact they are AVM1 throws that out the window.
    That leaves LocalConnection, as you mentioned. But this would require you to have code on the receiving end to handle the connection... no good either.
    But what if you created a "bridge" in AS2 that holds all the code for the receiving end of LocalConnection (or has the control logic itself, perhaps even eliminating the need for LocalConnection all together!). I think maybe this is what you were trying to do already by loading a SWF into a SWF? Well instead of loading your bridge at runtime, what if you statically linked it into your project as a class?
    *a few moments later*
    Well it looks like you can in fact link in a a symbol created for AVM1, but it will only come in as a SpriteAsset, and will not include any custom code (which makes sense, since they use entirely different class constructs).
    To do the test, I created a symbol exported for actionscript (AS2/Flash8), then linked it in with a CSS style embed. I then instantiated the class and called describeType on it.
    So in summery, it looks like calling custom code on the bridge is out (I did not test this extensively, that was just my first impression with this simple test). However, if you may be able to perform the actions you need by attempting to cast the loaded content into something AVM2 can recognize. Apparently it does this automatically when linked in statically, so maybe there is something there worth looking into... mainly, can you do what you need using only the base class and no custom code?
    Keep me posted!

  • AS3 swf tiny question

    I have a feeling that I know the answer to this. I am not
    terribly savvy on Actionscript (basic sklls, not expert)..and not
    in 3.0 at all!!!!!!!! I have a website that is done nearly all in
    Flash with AS2.0. I recently added a video player from a video
    aggregator, but their player is AS3.0.
    All I could do was to build an html page and embed the AS 3
    player into that. I prefer the seamlessness that Flash provides. Is
    there ANY possible way to embed an AS3 swf file into an AS2
    website.
    I just cannot completely rebuild the entire website right now
    in 3.0!!!!
    Is there ANY simple solution? I cannot believe that I am the
    only person who is having issues like this...Ugh!!!!
    thanks for any help you can offer.

    you can't use an as2 file to load an as3 file and have the
    as3 file work.
    you can use getURL() to load your as3's embedding html file.
    if you want it to look seemless, you can load into the same window
    so the user will see your as2 content replaced by the as3 swf.
    in the as3 swf you can put code to load your as2's embedding
    html file (using navigateToURL()). so, you can go back and forth
    between your as2 and as3 swfs.

  • Embedding a SWF file with an iFrame

    I wanted to embed an assessment in to one of my PDFs. I know I can't do it directly so I tried to create a small little Flex app that shows an iFrame (see here for the example). I then tried to insert this (as a SWF) in to my PDF file. I have a problem where when selected in the PDF it displays the SWF file, but not the linked URLs for the iFrames. Any ideas? how I might be able to get around this. Here is an example of what I was working on.
    Any help would be much appreciated.
    Noel

    hat do you mean with embedding a SWF file into another?
    you can embedd a SWF file in a HTML file. you can load a SWF
    file in another SWF file.
    but to embedd a SWF into another is not possible.

  • Issues adding swfs created in Flex to a Captivate project

    The company I work with, ePath Learning Inc. has an online authoring tool called eActivity that we use to publish different eLearning templates. This online tool is built completely in Flex and uses the Flex compiler to ouput a swf file that can be used in many different products and online courses. Because it's an AS3/Flex created swf, we've had to wait for Captivate 4 to be released to support the generated swf file, so now we are testing it's compatibility and have run into some issues. It appears that swf files from our online authoring tool do not work correctly in Captivate. Further testing resulted in any swf published using Flex do not work properly in Captivate. Attempts at adding a swf file complied with Flex result in a variety of different errors as well as a performance issue causing the control bar as well as all other aspects of the Captivate project to work incorrectly.
    I've attached 2 sample swf files, 1 built using our online authoring tool and 1 using Flex Builder 3. When added to a new blank project in Captivate 4 using AS3 settings we have the errors as explained above.

    Hi there
    I just uploaded a small video to Jing. See if it helps you resolve the issue.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Using a swf generated by Flex from a Flash component

    I know you can include and control a swf generated by Flash
    within a Flex component. But can you do the inverse? Can you use a
    swf generated by Flex within a Flash project/component?
    We plan to develop a "core" module that would be used in a
    lot of other Flash and Flex components we'll develop in the future.
    This core would be a package of classes that could be easily
    re-used by the components. There would be nothing visual in it,
    only standard classes.
    Even if this core would not contain any visual components, we
    would like to develop it using Flex since we prefere Flex Builder
    to the Flash editor to code and debug.
    But I'm not sure if:
    1) A core module like this, developped in Flex, could be used
    by our Flash components or only by other Flex components?
    2) If we use Flex to generated this core, will the resulting
    .swf be bigger than if we would have used Flash to develop it?
    Since there will be no Flex visual components in it, maybe it will
    be as small? Is there a compiler parameter to tell Flex to only
    include the minimum things possible in the generated .swf?
    Any help or link about this would be really appreciated!
    Thanks you in advance!
    P.S. I apologize to those aware that this message was also
    posted on another Flex related forum, but I received no reply on
    it!

    try this. for me it has worked.
    import flash.net.URLRequest;
    import flash.utils.Timer;
    var loader:Loader = new Loader();
    var timer:Timer;
    var myclip:MovieClip;
    //load the Flex Component
    loader.load(new URLRequest("IS.swf"));
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    loaderDone);
    addChild(loader);
    function loaderDone(e:Event) {
    timer = new Timer(100);
    timer.addEventListener(TimerEvent.TIMER, handleTimer)
    timer.start();
    function handleTimer(event:TimerEvent):void {
    //cast the loader.content into MovieClip to access
    currentFrame.
    myclip = loader.content as MovieClip;
    if (myclip.currentFrame == 2)
    however, i need to access properties of IS.mxml..
    any data member would work..
    or if i could dispatch an event in IS.mxml and catch it in
    flash through IS.swf, it would work.
    Pls somebody suggest.

  • Unable to apply embedded font swf to text in text layout framework

    Hello,
    We have created a swf for a given font (for e.g., Calibri.swf) which contains all the styles (Regular, Italic, Bold, BoldItalic).
    We have created a xml which lists the name of the font and the corresponding swf file path. The names from the xml are loaded into a combo box in the application.
    When we try to apply the selected font to a text in the text layout framework, it does not apply the same. It sets the font to default "Times" font.
    Following is a snippet of code to apply the font to the text:
    private function selectFont(fontXML:XML):void {               
                    var path:String = fontXML.@source;
                    var myEvent:IEventDispatcher = styleManager.loadStyleDeclarations(FlexGlobals.topLevelApplication.url.substring(0,FlexGl obals.topLevelApplication.url.lastIndexOf("/"))+"/"+path);
                    myEvent.addEventListener(StyleEvent.COMPLETE, function(event:StyleEvent):void{
                        var editManager:EditManager = textFlow.interactionManager as EditManager;
                        var itextLayout:TextLayoutFormat = new TextLayoutFormat();
                        itextLayout.fontSize = 20;
                        var fontName:String = fontXML.@name;
                        Alert.show(fontName);
                        itextLayout.fontFamily = fontName;   
                        Alert.show( "itext = " + itextLayout.fontFamily);
                        editManager.applyFormat(itextLayout,itextLayout,itextLayout);
                        var flowLeafElement:FlowElement = textFlow.findLeaf(editManager.anchorPosition) as FlowElement;
                        editManager.changeStyleName(fontName,flowLeafElement);
    Can anyone please let us know what is missing in the implementation?
    Thanks in advance.
    Vikram

    My recommendation: unless you really care about ISWFContext implementations and the application domain issues, ignore Alex's post about embedded fonts.
    It is a nice discussion about the inner workings of the domain and security of how this works but it is imho broken and is an insane concept to require an ISWFContext to just use an embedded font. It also breaks runtime CSS loading that has fonts embedded in it because the Flex compiler (last I checked) was also busted – it doesn't include the function necessary to create within context the font embed so that it may be applied. You can't create an ISWFContext with a compiled CSS file.
    These issues were introduced in the last Flex SDK beta before FB4 was released in final form. There are multiple bugs logged against the issue of applying loaded font files to TLF text (in short, SWFContext is broken and you have to override GlobalSettings.resolveFontLookupFunction to return embedded or null, all the time).
    Here's some more details to get you started - with links to at least one of the SDK bugs that were filed:
    http://forums.adobe.com/message/2656152
    For example:
    import flashx.textLayout.elements.GlobalSettings;
    import flash.text.engine.FontLookup;
    GlobalSettings.resolveFontLookupFunction = function makeValid():String { return FontLookup.EMBEDDED_CFF };
    And you may need to do this after your font is loaded:
    yourTextBlock.textFlow.invalidateAllFormats();
    Disclaimer: I haven't seen the latest Flex SDK release to see if this was fixed. I have an AIR application with native process that builds embedded font SWF files for use and stub code for FB4 usage but haven't updated to the latest SDK yet to see if it's working properly.
    Anyhow, your best bet is to look at the Flash Builder forums. I think this is/was a Flex team issue, not TLF.

  • Embedding a SWF Video in an AIR 2 HTML App

    I've been through the forums for awhile and I can verify that my issue doesn't have to do with transparency or chrome.  I have an IFRAME which is in the application sandbox, giving it access to files in app-storage.  Dynamic images are loading fine, but my dynamically generated <OBJECT> code that is placed in the DOM is not loading the SWF video.  I can see the object placeholder, but no video.
    Are there any requirements to embedding a SWF file, perhaps size requirements (both height and width required)?  Given the fact that my content is dynamic and I don't know the dimensions of the SWF file, I currently have two options for embedding:
    1. Calculate the height and width of the parent element, and assign those values to the OBJECT params.
    2. Use 100% width and height on the OBJECT
    This might pose problems with the proportions of the SWF file, which I'm hoping can be fixed by the scale PARAM (http://kb2.adobe.com/cps/127/tn_12701.html).
    Please help, I haven't been able to find any similar problems.  I followed the documentation for embedding from here:
    http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS4B441C24-BAE3-4110-91FD-A4E5EEFB2467.htm l

    Is this happening for any swf file, or is this an issue related to video?

  • Problems with a AS3 SWF

    Hello,
    I am having issues with a SWF file posting properly in a Catalyst project.  I have already put a post in the Catalyst section but I wanted to bounce the idea off this room that the issue is more SWF and less Catalyst because everything else in Catalyst is working just fine, including other AS3 SWF files that I have linked throught the site.  The files are here:
    www.electronic-lifestyle.com
    If you enter the Home Theater section you will see a SWF load in the film frame after it downloads (maybe 3 seconds).  This SWF with alter the screen on the image and give you controls on the bottom right corner to shift the aspect ratio of the content on the projection screen.  This is a AS3 SWF that works just fine, but if you click on Electronics the page shifts to another film frame that is blank.  It is a scroll panel in Catalyst that is refusing to load the content which is a SWF with several links set up as buttons in AS3.
    I cannot figure out why one SWF will work and the others will not.  Is it possible that I am publishing the files incorrectly somehow?  I checked the publish settings for the files that work and the files that don't and they are exactly the same.  I have tried to rebuild the pages with both the good SWFs and the bad SWFs and I get the same results.
    Even more puzzling is that the entire project works when I check the Local files.  The issue only rears it's ugle head when I put it on the server and try it live.
    If anyone has insight into the connectiuon between Flash AS3 SWFs and the way FXP files imports them that could come close to explaining this please let me know.  The only difference between the two are the buttons, I am going to try to remove the buttons and see if the SWF works.
    Thanks in advance,
    Brett

    Hey,
    Yes I have figured out the issue and I simply can't believe the solution.  I have been discussing it on the Flash Catalyst Forum.  Here is a recent post, please feel free to take a look at the page I have set up to demonstrate the issue in case you ever come across it.  It is a real kick in the head.
    Brett
    Chris,
    Thanks for  the tip but I just figured out the problem and you are not going believe  this.  I removed the buttons from two of the scroll panes and replaced  them with buttons made in Catalyst and the problem magically went away.   Take a look at this page:
    www.electronic-lifestyle.com/SpeakSEL-OLD/Main.html
    The first three pages work just fine but the Third and Fourth pages (Outdoor & Subwoofer) will not load the SWF.   The ONLY difference between these two pages are the buttons in Flash.   It would seem that buttons will create a destructive error that prevents  the SWF from loading.
    If this pans out then the  developers for Adobe really missed a big one with this.  I have over 47  pages that now need to be rebuilt because I assumed that a button built  in AS3 would not interfere with the SWF load.
    Now this  isn't something that happens all the time, I have several SWFs in this  site that use buttons and work just fine but they are nested in Movie  Clips and they all have to do with timeline controls rather than opening  another URL.  Maybe the "_blank" tag is the issue but I am required to  get the user to a different page by the client's request.  I can't very  well go back to the client and tell him that Catalyst has an issue with  that very normal request.
    Anyway, thanks for the  suggestion, I am spending the rest of my day republishing my SWFs  without buttons just to remake them in FC.  BTW, the real kick in the  head is that the SWFs with the buttons work on the local files, its when  you upload to a server that everyting seems to fall apart.
    Brett

  • Imported AS3 swf animation not looping

    I have tried all of the settings in Captivate 5.5 but can't keep my animation looping and not sure why.
    I've imported an AS3 swf animation (just a simple movieclip animation of a blinking line) into Captivate 5.5. I placed the animation at the end of the timeline on the slide, and want the blinking line to stay there and continue to blink (i.e., animate) even after the slide has come to the end of the timeline.
    I've tried everything I can think of. I assumed that checking the "Loop" setting in Captivate for the animation would do it, but it seems to have no effect.
    I am pretty sure what is happening is that the click box on the Cp slide is forcing the animation to pause. In other words, the imported animation's timeline is being forced to pause too. Is there a way to stop this?
    Any ideas?

    Hi there
    Try inserting a Click Box that pauses the slide about half a second before the end of the animation on the Timeline.
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Communication between AS2 Template and AS3 Swf

    I created a template in AS2 which loads as2 swf's. i want to load as3 swf. then how can load as3 swf.within as2 template.
    please help me to find out this...

    hI,
    Look at package SDYNAMICDOCUMENTS, or look for DD_* ( This is Dynamic Documents  Tamplates ) in SE38.
    Regards,
    Marcelo Ramos.

  • Load AS2 swf into AS3 swf problem

    I have a flash with AS3 and inside this swf i load in a AS2 swf.
    to load swf works just fine, but the problem is when i load this i want to go to
    a specific part of it, for example i want to go to frame 3 in the loaded swf.
    i must control this from the AS3 swf, does someone know if this is possible?
    thanks in advance

    so can i do like this then to go to frame 3 in my loaded swf?
    MovieClip(ldr.content).gotoAndStop(3); ?
    sorry for being such an airhead
    thanks for helping me out =)
    Date: Sun, 7 Jun 2009 10:25:09 -0600
    From: [email protected]
    To: [email protected]
    Subject: load AS2 swf into AS3 swf problem
    no.
    if, in your loaded swf, you have a function f1() on the loaded swf's main timeline and you load that swf using a loader (say ldr), use:
    MovieClip(ldr.content).f1();   // to call f1() in the loaded swf
    >

  • Convert AS2 swf to AS3 swf

    I have a swf (written in AS3) that loads other swfs into it.
    There are no issues when loading other AS3 swfs but there is a
    problem loading AS2 swfs. I get the following error:
    TypeError: Error #1034: Type Coercion failed: cannot convert
    flash.display::AVM1Movie@35d3a51 to flash.display.MovieClip.
    Is there any way to convert the AS2 swf into a AS3 swf so it
    will be compatible with my loader? I cannot go back and change the
    AS2 swfs because I do not have the fla files. Or is there any way
    to incorporate AS3 code that will load AS2 swfs properly? It seems
    hard to believe that Adobe would neglect this backwards
    compatibility issue. Thanks

    Hello Andrei1,
    Thanks for looking at my simple AS3 code. The AS2 swfs that
    I've been working (and having difficulties) with are components
    that I've purchased from places like www.flashden.com. Some are
    image transitions (such as "Dynamic Image Draw found at
    http://www.flashden.net/item/dynamic-image-draw/7532)
    while another is used to create a looped banner rotator animation
    (IMG_loop, a free d/l from www.afcomponents.net). I have another
    that uses an .xml file to configure a slideshow animation.
    You mention "needing to do more" if AS2 scripts inside its
    swf are to be run by the parent AS3 fla; what would these lines of
    code be?
    In researching my problem further I've since realized that
    most of these issues deal both with the version of AS used, as well
    as the version of the Flash player the fla is set up to animate
    for. In particular, the "Dynamic Image Draw" component requires
    that Flash Player 8 or 9 be used with AS2.
    Given that many of my purchased components are like this,
    I've since changed my main fla movie from AS3 back to AS2 and have
    learned that the scripting needed to call individual multiple swfs
    into it at various points in the timeline is MUCH simpler!!!!! One
    single, easily interpreted, line of code vs. 5 lines using
    variables and much more arcane (to me) function calls.
    I started my file with AS3 figuring that I'd be better off
    learning the new version of the language; much stress and
    forehead-rubbing later, I've seen just how much easier and
    understandable AS2 is to learn.
    I recognize that there are likely very strong arguments for
    the more structured coding approach used by AS3, but for someone
    like me who wants to generate customized Flash presentations with
    little fuss, I'm not qualified to make them.
    Perhaps this is a no brainer for those many flash gurus out
    there, but for me this tiny bit of wisdom has been hard fought for!
    That being said, is there an easy way to convert a swf file
    created using AS2 to something that AS3 can work/interact with?
    I've come across a free d/l product called actionscript bridge, but
    haven't been able to understand how to get it to work.

Maybe you are looking for