Flex 3 vs Flex 4 Preprocessor directives and code behind (External Actionscript file)

I have a framework that I've built that I want to use on Flex3 and Flex4.
I've added pre-processor directives as per this link (http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html) and got my Flex 4 code to compile nicely.
I then went to flex 3 and discovered my sub-class of Application wouldn't compile because it was based off of spark. No problem, I'll add in a directive.
Except now my overridden class has duplicate code, specific to which SDK it is using.
No problem, I'll put all of the application class code in an Actionscript file and include it in both Application class declarations for each directive.
It works nicely in Flex 3, so I went to Flex 4, tried to compile and now I'm getting compiler errors saying things such as "The (private|public|protected) attribute may only be used on class property definitions." and "The (private|public|protected) attribute can only be used inside a package.
This same file works in Flex 3, but not in Flex 4.
What can I do to make the code compile in both places?
I'll work on a simple case so I can upload some code.

Nevermind.
I got around this issue by renaming my sub-classed Application to "...Application".
Now I can use a directive to specify an import statement for the extends Application portion rather than specifiing the fully qualified spark.components.Application or mx.core.Application.
Lame - but done.

Similar Messages

  • Trying to properly code a menu with buttons that can go back and forth between external swf files

    I have a project I've been working on that, when properly coded, has a "main menu" with 4 "doors" (buttons). When the corresponding buttons to these "doors" are clicked, it should go to and play an external .swf file. If that doesn't make sense, think of a DVD menu. You click play movie, it plays the movie. When the movie is over, there's two buttons on that swf file to either play the movie over or go back the main menu, which is an external .swf file (Remember, we go to the movie from the menu, which is a seperate file). So far, the buttons work. The menu works. However, from the movie, at the conclusion, when I click the button to go back to the main menu, it displays the movie clip and the buttons, but none of the buttons work. I'm starting to think it has to do with the fact the main menu was written in AS3 and the movie was made in AS2. If anyone can assist me in being to able to keep both files and still navigate between the two, being able to bring up the menu from the movie and be able to play the movie again, and so on and so on, that'd be GREAT. I'm somewhat of a noob to Flash, but I learn quickly and I'm open to any suggestions. Here's the code for main menu, which I guess acts as the parent file, and the movie. If I get this to work, I essentially would duplicate the same actions for the other 4 doors, once I complete the environments for them. Thanks
    Main.Fla/Swf (written in AS3)
    (This is the action on the first frame, that has all the buttons. For this question, I'm just trying to properly code for 'Door4', which is the "door" to the movie.)
    import flash.display.Loader;
    stop();
    var myLoader1:Loader=new Loader ();
    Door4.addEventListener(MouseEvent.CLICK, jayzSwf);
    function jayzSwf(myevent1:MouseEvent):void
              var myURL1:URLRequest = new URLRequest("jayzspeaks.swf");
              myLoader1.load(myURL1);
              addChild(myLoader1);
              myLoader1.x = 0;
              myLoader1.y = 0;
    Movie.Fla/Swf (written in AS2)
    (This is action on the button that returns to the menu)
    on (release) {
              this.createEmptyMovieClip("container",this.getNextHighestDepth());
              container.loadMovie("main.swf");

    At least you're going in the correct (mis)direction. You have AS3 loading AS2. So that's not a huge hurdle.
    I believe all you really need to do is send your Main.swf a signal that the content it loaded (e.g. jayzspeaks.swf) is done and you want to get rid of it.
    The code I pointed you to asks you to (upon download and import then) instantiate it in both AS2 and AS3. They give a very simple easy to understand line of code.
    // as2, load this in jayzspeaks.swf
    var myBridge:SWFBridgeAS2 = new SWFBridgeAS2("connectionID", clientObj);
    // as3, load this in main.swf
    var myBridge:SWFBridgeAS3 = new SWFBridgeAS3("connectionID", clientObj);
    Make sure the connectionID matches between them. Set it to whatever you want.
    When you're done with your as2 loaded content you'd send a signal (over localconnection) back to the AS3 Main like they say:
    myBridge.send("someFunctionToUnloadContent");
    myBridge.close();
    You'd need to make the as3 function "someFunctionToUnloadContent()" (example purposes only name) and it should unload the jayzspeaks.swf that was loaded in the loader.
    Make sure you get that close in there so you don't drill up a bunch of localconnection objects just like the simple source code says.

  • Jsp and Code Behind

    Is it possible to create a Jsp Page the Same way that an aspx (asp.net) Page is created.
    With your basic design I.E. your html and controls in one file and then your class that extneds System.Web.UI.Page which is in you code behind file ??
    if so Are there examples of this ??

    Jsf is somewhat comparable to the asp.net controls yet I was asking if there is a way to do codebehind like asp.net pages.
    the reason for this :;
    I am converting from asp.net to jsp and want to move with the least pain.
    thanks in advance

  • Load and unload the external swf file using AS3(for window, IOS and android)

    For the external swf file loading, I use this code
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
    its working great but I don’t know how to unload the loaded swf files (looking: unload one by one and unload all)
    in AS2 we have
    on (release) {
              loadMovieNum("scene2.swf", 1);
              unloadMovieNum(2);
              unloadMovieNum(3);
    but i need in AS3

    Now I use this code and this time I got these compiler errors
    package {
                    import flash.display.SimpleButton;
                    import flash.display.MovieClip;
                    import flash.events.MouseEvent;
                    //import flash.display.URLRequest;
                    //import flash.display.Loader;
                    import flash.events.Event;
                    import flash.system.ApplicationDomain;
                    import flash.net.URLRequest;
                    import flash.system.LoaderContext;            
                                    public class load1 extends SimpleButton {
                                                    var loadit:Loader;              
                                                    public function load1() {
                                                                    this.addEventListener(MouseEvent.MOUSE_DOWN, loadfile);
                                                    private function loadfile(event:MouseEvent):void {
                                                                    trace("you clicked me");
                                                                    loadit = new Loader();
                                                                    this.parent.addChild(loadit);
                                                                    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                                                                    loadit.load(new URLRequest("s01.swf"), _lc);
                                                    private function unloadfile(event:MouseEvent):void {
                                                                    loadit.unloadAndStop();

  • Indesign script to find and replace from external excel file

    I have been asked to update an existing price list (set up as lots of small tables) in Indesign (500+  pages). I have been given a new Excel spreadsheet with the product codes and new prices. I am looking for some assistance on finding or creating a script that can do such a thing if at all possible to speed up the process over just copying and pasting. Does anyone have any suggestions or point me in the right direction?

    1. Your Excel conversion to FindChangeList format idea seems okay, apart from one thing: both findWhat and changeTo strings should have double quotes around them. As they are now,
    grep {findWhat:lang1"} {changeTo:"lang2} {incl...(etc.)
    the opening one after findWhat and the closing one after changeTo are missing.
    2. Your first line contains 2 definitions. Each separate definition should be on a line of its own. (This might occur elsewhere as well, didn't check.)
    3. Any double quotes inside strings will cause problems. Precede them with a backslash to 'escape' them and convert them to a literal character. I found this one:
    "(for IC5/8"V)"
    -- change to
    "(for IC5/8\"V)"
    4. Some of your strings start with double double quotes:
    changeTo:""(MITM刀具见254页 ...
    5. To prevent your problem with this order
    grep {findWhat:Inserts"} ...
    grep {findWhat:Inserts Ordering Code System"} ...
    sort your Excel list alphabetically, case preserving, in reverse order.
    You probably also want wholeWord:true, and caseSensitive:true.
    Hope this helps!

  • Flex Code Behind Issue

    Hey guys,
    so I have created a simple flex proj
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" themeColor="#0EFF02">
    <mx:Script>
    <![CDATA[
    private function onOver(evt:Event):void{
    trace("onOver : " +evt.currentTarget );
    test.setStyle("backgroundColor",0xff00ff);
    private function onOut(evt:Event):void{
    trace("onOut : " +evt.currentTarget );
    test.setStyle("backgroundColor",0xffff00);
    ]]>
    </mx:Script>
    <mx:Canvas id="test" x="118" y="136" width="443"
    height="133" themeColor="#099FFF" backgroundColor="#D70000"
    rollOver="onOver(event);" rollOut="onOut(event);">
    <mx:Button x="39" y="35" label="Button"/>
    </mx:Canvas>
    </mx:Application>
    So basically all the code above does is changes the
    backgroundColor of the Canvas. It works fine
    Now if I make a MXML Component using the Code Behind Method
    Main.mxml
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" themeColor="#0EFF02" xmlns:ns1="item.*">
    <ns1:ListItem x="80" y="48"/>
    </mx:Application>
    ListItem.mxml
    <item:CListItem xmlns:mx="
    http://www.adobe.com/2006/mxml"
    width="400" height="300" xmlns:item="item.*">
    <mx:Button x="65" y="61" label="Button"/>
    </item:CListItem>
    CListItem.as
    package item
    import flash.events.MouseEvent;
    import mx.containers.Canvas;
    import mx.events.FlexEvent;
    public class CListItem extends Canvas
    public function CListItem()
    super();
    this.addEventListener(FlexEvent.CREATION_COMPLETE,
    onComponentLoaded);
    private function onMouseOver(evt:MouseEvent):void{
    trace("CListItem.onMouseOver :");
    this.setStyle("backgroundColor",0xff00ff);
    private function onMouseOut(evt:MouseEvent):void{
    trace("CListItem.onMouseOut");
    this.setStyle("backgroundColor",0xffff00);
    private function onComponentLoaded(evt:FlexEvent):void{
    this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
    Now when I mouse over the Button component the onMouseOut
    function gets called and there is a flicker in the backgroundColor.
    If I dont use the Code Behind Method then the onMouseOut
    function does not get called when I rollOver the button.
    Can anyone explain this strange behavior?
    Thanks
    Cheers
    Firdosh

    Conrad - there's no plans to enhance specific codebehind support.  It's worth mentioning, however, that you can adopt the spark skinning model for all of your components to get a good codebehind separation of view and logic.
    Ely.

  • Can Flex 4.6 connect directly with a MS WCF

    Can Flex 4.6 connect directly with a MS WCF without having to use a 3rd party tool like WebOrb.  I have several basic httpprotocal wcf services that I want to move to a mobile app with Flex. Any feed back or insight will be appriceated.

    The correct answer to this question appears to be that Apple's terms of service *do not* prohibit the loading of swf's on IOS from remote servers dynamically at runtime.  They prohibit the loading of swf's that *contain executable ActionScript code*. 
    I loaded a PPT into Adobe Connect and then retrieved the resultant slide swf's from the Connect server.  I took these swf's and loaded them into my iPad app, dynamically at runtime, from a remote server.  The swf's loaded and animations played.  I made no changes to my code.  I'm just using a plain old SWFLoader object.
    Loading swf's dynamically at runtime from remote servers into IOS works - if you make the swf's right.  How to do that I'm not sure.

  • In Flex 3 how to Stop and Replay .swf animation created in Flash

    Hi
    I have an animation file that is created in Flash (I think
    CS3). In Flex if I import it inside a SWFLoader or if I import it
    as an Image. It plays once and stops. Then I can not replay it. I
    also can not pause it when its playing.
    I have tried few things based on help and code available in
    the Web to of no help. I have tried to convert the swfLoader
    instance to a movie clip like so to stop
    var c:MovieClip = swfLoaderHeaddress1.content as MovieClip;
    c.stop();
    <mx:SWFLoader x="53" y="116" width="206" height="255.3"
    visible="true"
    source="assets/animations/curatorial/ZoomHeadress_2nd.swf"
    id="swfLoaderHeaddress1"/>
    It does not work.
    I have not created the .swf animation, I am not sure how it
    is done. I belive it may not be using any ActionScript as I know
    the artist who created it does not know ActionScript. Does
    something need to be done inside the Flash to support the stop and
    play? Or is there a way to restart/replay stop a .swf animation in
    Flex 3 no matter how (and whether or not its developed using
    ActionScript) its developed in Flash?

    One way is she has to add some AS code to the animation, or
    you can do it yourself.
    In swf there must be something like this:
    var connReciever:LocalConnection = new LocalConnection();
    connReciever.client = this;
    connReciever.connect("fromFlexToSWF");
    function myFunction(parameter:SomeClass):void {...}
    And in Flex:
    var connSender:LocalConnection = new LocalConnection();
    connSender.send("fromFlexToSWF", "myFunction", [..args]);
    The other way: in case with just play/stop there is a way to
    resolve this by using that Flex Component Kit (or maybe "Flex Skin
    Design Extension", i do not remember), it is something like she
    just adding labels to animation frames then she exports it with
    Flex Kit and then you can work with it like with an object with
    "states".

  • Flex Builder 3.1 Standard and Flex SDK 4.1 build 16076

    Hi I have a problem I have downloaded Flex SDK 4.1 16076 and added to my sdk list in Flex Builder. I can compile my program fine except when I change files the flash imports are removed and the code hints don't have any knowledge of flash.display and other base classes such as Movieclip and Sprite. As soon as a manually paste the imports into my class files it compiles again but can't be doing with copying imports back in every time I change a class file.
    It didn't do this on version 4.0.0 - I have added   -static-link-runtime-shared-libraries=true to compiler arguments as I did have a problem with it firstly compiling about FontAsset.
    Does anyone know why? Do I have to add another swc in?

    You should always have separate workspaces for separate versions of Flash Builder.
    Flex 3 and Flex 4 have some large differences.  You will probably want to spend some time reading about migrating by searching on Google.  Here is a good place to start: http://www.adobe.com/devnet/flex/articles/flex3and4_differences.html

  • SQL Server 2008 Reporting Project - Invoke/Consume Web Service and Return Dataset in C# Code-Behind

    Hello,
    I have a Visual Studio 2010 C# class with a method that invokes/consumes a web service and returns an XML dataset. I am traversing through the parent/child nodes and parsing out the data then inserting it into a SQL Server 2008 R2 table for a join within
    another stored procedure. 
    Instead of using a 3rd party API to generate the PDF for this data, I am creating an SSRS report. The formatting will be easier and I can do a RenderFormat directly to PDF.
    Can I expect to be able to transfer the code-behind method to this report and have it be able to work with the web service the same way? It is a SOAP-based web service returning parent nodes and two levels of nested child nodes.
    I have also been researching the approach of calling the web service in the same stored procedure that is currently querying the physical tables (which is used to populate a gridview and PDF) but it looks like it may only be possible with a CLR stored procedure.
    Is it possible to implement a CLR stored procedure within an SSRS report? 
    Hope this makes sense. Any help, suggestion or point in the right direction would be greatly appreciated.
    Thanks,
    Buster

    Hi Buster,
    SSRS supports web service data source, we can call the SOAP-based web service in SSRS report directly. Then, we can use custom code in SSRS to parse the XML data. However, we won’t be able to join another data in SQL Server database.
    Reference:http://technet.microsoft.com/en-us/library/aa964129(v=sql.90).aspx#repservxmlds_topic3
    We cannot implement a CLR stored procedure within an SSRS report directly. In order to execute the CLR store procedure in a SSRS report, we have to execute it as text using the following code:
    Exec <stored procedure name>
    Reference:
    http://dotnetslackers.com/Community/blogs/bmains/archive/2009/01/15/executing-a-clr-stored-procedure-in-reporting-services.aspx
    Hope this helps.
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • How to add Column to Adobe flex mx:DataGrid in mxml and/or actionsctpt?

    I have simple mxml code
    <mx:DataGrid id="DGG"
                 editable="true">
        <mx:dataProvider>
            <mx:Object scheduledDate="4/1/2006"/>
        </mx:dataProvider>
    </mx:DataGrid>
    <mx:Button id="SetBut"
               label="Set Array as Data Provider"
               click="SetDP(); AddBut.visible = true;"
               x="100.5"
               y="164"
               width="211"/>
    <mx:Button id="AddBut"
               label="Add a column!"
               click="AddCol();"
               x="100.5"
               y="194"
               width="211"
               visible="false"/>
    <mx:Script>
        <![CDATA[
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.collections.ArrayCollection;
            [Bindable]
            public var MyAC:ArrayCollection=new ArrayCollection([{scheduledDate: "4/1/2006", homeTeam: "Chester Bucks"}]);
            public function SetDP():void
                DGG.dataProvider=MyAC
            public function AddCol():void
                MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
                DGG.columns.push(new DataGridColumn("Umpire"));
        ]]>
    </mx:Script>
    I want to add rows to my table datagrid how to do such thing?
    How to add Column to Adobe flex mx:DataGrid in mxml and/or actionsctpt?
    (You can put this code in Flash or AIR app - it will compile with no errors, but will not add any columns=( )

    Change this:
                 public function SetDP():void
                    DGG.dataProvider=MyAC
                    MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
                public function AddCol():void
                    var dgc:DataGridColumn = new DataGridColumn("Umpire");
                    var ca:Array = DGG.columns;
                    ca.push(dgc);
                    DGG.columns = ca;
    Dany

  • Flex programs written in English and digital gibberish

    Flex programs written in English and digital gibberish,
    but only in a few appear on the compute.
    What causes the pattern to be narrow?
    Conflict is a software problem or system? 

    Read on about JNI.
    This has nothing to do with JSF. In the future please post JNI related questions at the JNI forum.

  • Using Code Behind Technique and Popups

    I am starting to use the code-behind technique a bit more
    lately and have run into a problem.
    If I try to open a popup using a class that has a separate
    mxml and backing .as file, I get a null object reference.
    var pu : PopupClass =
    PopupClass(PopUpManager.createPopUp(this, PopupClass, true))
    where PopupClass.mxml extends PopupClassCode.as (which in
    turns extends BaseForm which extends DragPanel)
    Has anyone successfully done what I'm trying to do? It seems
    that it should be easy.
    Tony

    I am starting to use the code-behind technique a bit more
    lately and have run into a problem.
    If I try to open a popup using a class that has a separate
    mxml and backing .as file, I get a null object reference.
    var pu : PopupClass =
    PopupClass(PopUpManager.createPopUp(this, PopupClass, true))
    where PopupClass.mxml extends PopupClassCode.as (which in
    turns extends BaseForm which extends DragPanel)
    Has anyone successfully done what I'm trying to do? It seems
    that it should be easy.
    Tony

  • Flex 4 states and using includein with actionscript

    Hello,
    How do you handle states and the "includeIn" tag in ActionScript? For example:
    var vGroup:VGroup = new VGroup();
    var initialState:State = new State();
    initialState.name = "initialState";
    initialState.overrides.push(new AddChild(this, vGroup));
    this.states.push(initialState);
    This is not valid code, but it's what I'd like to do.
    Thanks

    Set up something similar in MXML and use -keep–generated-actionscript and see what the code looks like.

  • Code-behind + Design Mode = ... ?

    Hello everybody
    I'm trying to step into the Flex world from the right side. That's why I started using Code-behind pattern right away (in a search for info I've also foundCode-in-Front pattern... anyone interested? ). Well, the problem is - I create the combined element with it's logic and then extend it through MXML, and then I instantiate it in the main MXML file. So far everything good, but Design Mode now shows a white box with a red cross inside instead of my custom coded component with it's buttons, combos, etc. Is there any solution to that?

    Ouch...
    I have no problem with compiler. The App runs and works fine
    Is MVC approach compatible with design mode?
    Can you point me to some good MVC framework? Maybe PureMVC?

Maybe you are looking for

  • Why do my saved pics/images have a green mark on the all of a sudden after 4 months of non use on my G3?

    I went to look aty images after not using my G3 desktop for a few months and all of the pics have a big green mark on the lower half of them, any ideas whats going on and how to correct it?

  • Fm for previous date

    Hi, Is any FM is there which can calculate the previous 1 year date or more. Suppose I have today's date & based on that date I wanted to calculate the previous 1 year date.

  • R 9.0.124.0 Flash Crash

    I just upgraded to latest flash player and now video streaming from BBC website always crashes IE6 on W2K I tried unsinstall and instal of older version but it still happens so I tried current vewrsion 9 124 again and still same problem. This is what

  • Count incoming/outgoing messages

    Exchange 2k7 on Windows 2k3. Is there a way to count the number of messages going through my exchange server without the use of a 3rd party app? I was thinking is has to be possible with a VB or powershell script but ensure where to start.

  • Error 1335, installation stops

    Installation of Elements 11 stops with an error message: Error 1335, cabinet file Data 2.cab is corrupt or cannot be used. I ran Adobe Support Advisor and got no result. What do I do next?