Sections
You are here: Home Forum Flash AS3 classes with flex instead of flash

AS3 classes with flex instead of flash

Up to Flash

AS3 classes with flex instead of flash

Posted by Joost Harts at November 25. 2007
i wonder if there will be any tutorials or example's available to get the make controller kit working with adobe flex. i am still learning to use flex so i am first of trying to get the controller working with singleled function. but so far i have ran into some compile errors and such, and help would be greatly apriciated cheers

AS3 classes with flex instead of flash

Posted by Liam Staskawicz at November 26. 2007
I haven't used Flex myself, but perhaps if you give some more info about what you're up to and the problems you're having we might be able to help you. If it's compile errors, have you installed everything in the appropriate location?

AS3 classes with flex instead of flash

Posted by Joost Harts at November 26. 2007
yes i added the folders as they where in the zip file. here is a screen shot which also shows the folder structure [img]http://into4.com/flextests/problem screenshot.jpg[/img] here is the copy of how i added the code shown in the example SingleLED.fla(that came included in the zip file) and added it into the mxml file. ?xml version="1.0" encoding="utf-8"? mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" mx:Script ![CDATA[ import com.makingthings.makecontroller.*; // import the MakingThings library addEventListener(Event.ENTER_FRAME,eachFrame); //errors are: Multiple markers at this line: -1180:Call to a possibly undefined method addEventlistener. -1120:Access of undefined property eachframe. var mcflash:McFlashConnect = new McFlashConnect( ); // our connection to mchelper mcflash.addEventListener( McEvent.ON_BOARD_ARRIVED, onBoardArrived ); //errors are: -1120:Access of undefined property onBoardArrived. -1120:Access of undefined property mcflash mcflash.connect( ); //errors are: -1120:Access of undefined property mcflash. var boxState:Boolean; function onBoardArrived( event:McEvent ) { var newBoard:Board = event.data; if( newBoard.location == "192.168.0.121" ) mcflash.setDefaultBoard( newBoard ); } function eachFrame( e:Event ) { if( checkbox.selected != boxState ) //if the checkbox has changed { if( checkbox.selected ) // if it's selected, turn the LED on { var msg = new OscMessage( "/appled/0/state", [1] ); mcflash.sendMessage( msg ); } else // otherwise turn it off mcflash.send("/appled/0/state", [0] ); boxState = checkbox.selected; //store the state for the next comparison } } ]] /mx:Script mx:Panel x="83" y="112" width="250" height="200" layout="absolute" mx:CheckBox x="70" y="60" label="Checkbox" id="checkbox"/ /mx:Panel /mx:Application you can download the latest version of flex builder 3 (beta) for free at adobe labs i hope you have enough information to help me out. also i was looking around the website for the xml diagram that is being used to let actionscript talk to the mchelper xml server. but i couldnt find it is there any chance it could be posted? so i can try and fiddle around to try and get a simple xml connection up. thanks in advance

AS3 classes with flex instead of flash

Posted by Liam Staskawicz at November 26. 2007
Have you added the location of the MakingThings library as a source path in your Flex project?

AS3 classes with flex instead of flash

Posted by Joost Harts at November 26. 2007
initialy no seeing as i added it to the project folder itself and it checks everything in the project folder and the import command should then be enough i thought. i tried your advice by adding them as a source path, so i first removed the one's that where in the folder itself (dont want duplicate's) then loaded them from a external folder with source path like so: [img]http://into4.com/flextests/problem1 screenshot.jpg[/img] sadly it didnt seem to make a difference at all :( you you can help me out

Re: AS3 classes with flex instead of flash

Posted by Michael Parisi at January 15. 2008

You don't need to use MXML to run a flash application through flex.

1. Simply go File->New->Actionscript Project.
2. Then, press next.
3. Then, in the Source Path tab, press Add Folder... and browse to your library.

4. To create new classes within the Actionscript Project, go File->New->Actionscript Class

 

I just got my controller a few hours ago. I still haven't tested with flex yet.

 

Re: AS3 classes with flex instead of flash

Posted by Michael Parisi at January 15. 2008

*UPDATE*

 

Works perfect with flex. Just tested it.

However, you do get Warning messages indicating the lack of type declaration in the  Make Kit Controller classes. This can be ignored.

I guess this is something that should be updated, as it would be more proficient.

Re: AS3 classes with flex instead of flash

Posted by aaron at May 10. 2008
I've got a flex app working with sending out to appled, but how do I read in, say like the dipswitch value?  This did not work along with several other variations.  I'm calling init() on the application creationcomplete.  I've noticed in my mchelper (v2.2) that my autosend commands are not going through, however I did send them through on a button click event and they still didn't work.  Any ideas? 

public function init():void{
                mcflash.connect()
                mcflash.setDefaultBoard(myBoard);
               
                mcflash.send("/system/autosend-usb",  [1]);
                mcflash.send("/system/autosend-interval",  [10]);
                mcflash.send("/dipswitch/autosend", [1]);
                mcflash.addAddressListener("/dipswitch/value",PopMessage);
               
            }
            public function PopMessage(event:McEvent):void{
                Alert.show("here");
            }

Thanks,
Aaron

Re: AS3 classes with flex instead of flash

Posted by Steven Cross at June 20. 2008
Hi all, I have read through this thread numerous times but still can't figure out how to work with the board in Flex. I believe that I have properly imported the library but I get numerous error trying any of the sample code I have seen. Does anyone happen to have a very simple Make Controller/Flex project they could share? I would love to see an MXML file with inline actionscript that sends a command to the board that I could copy to make sure I have things set up correctly? A simple panel with LED-On and LED-Off button calling scripts that communicate via USB to the board? Many thanks! Steve

Re: AS3 classes with flex instead of flash

Posted by Philip Forget at June 20. 2008

Steve,


Is there any reason you are using MXML instead of AS3? And are you using Flexbuilder or something else like Flashdevelop. I've cast all the undeclared variable types in the AS3 Libraries because I compile in strict mode, I would be happy to pass those along to you if they are causing your compile errors. If you are willing to use AS3 I'll gladly set up a sample project in Flashdevelop or a simple class that you can compile in Flexbuilder.



Also... Flashdevelop is awesome, way too awesome. You should give it a try, the code completion is fantastic, cuts my AS3 development time by a quarter.


Philip

Re: AS3 classes with flex instead of flash

Posted by Steven Cross at June 21. 2008
Philip, I am actually planning to build any logic that I need using AS3. I just mentioned MXML because that is the way I normally do UI work so I was anticipating the need to call AS3 functions from within the context of an MXML UI. I do use FlexBuilder and have never heard of Flashdevelop but I will certainly look into it. Thanks for the recommendation! If you can pass along a simple project that I could compile in FlexBuilder and use as a starting point it would be ever so greatly appreciated! Thanks, Steve

Re: AS3 classes with flex instead of flash

Posted by Philip Forget at June 22. 2008

Hey Steve,

I have flexbuilder alpha for linux, I don't know if the project will be compatible with the standard flexbuilder app for mac or pc. Is it built on eclipse? I have to say... the code completion is absolute garbage compared to Flashdevelop. Flashdevelop automatically parses your classes and creates code completion for them in real time, and code completion doesn't disappear the minute you hit backspace which really drives me CRAZY in flexbuilder. On top of the fact that it just works better, it's lighter, easy to set up, and COMPLETELY free and open source. It might be a bit daunting to set up at first, but It's really not that bad, and I'll be more than happy to help you get it set up. Here's the link to the latest beta release,


http://www.flashdevelop.org/community/viewtopic.php?t=2893


and I'll try to get you something in flexbuilder in the meantime, but I won't be near my linux box until late this evening.

Re: AS3 classes with flex instead of flash

Posted by aaron at July 02. 2008

Steve,

I was able to get the on board LED to work with Flexbuilder (V2).  I was not able to figure out how to read stuff in, but haven't spent any time on it since my previous post.  I'd be happy to send you my code of a simple mxml page that has a working button click, but you must realize I'm a novice agmunst novices. 

Aaron

Re: AS3 classes with flex instead of flash

Posted by Steven Cross at July 26. 2008
Aaron, I would greatly appreciate it if you could send me that code! If you can zip up a copy of your Flex project directory and send that along it might help as part of my issue seems to be project directory structures, etc. If sending via email you can send to flex@strangemoon.com . Many thanks! Steve
Powered by Ploneboard
Document Actions