Re: [Flashcoders] pure AS3 app to use mx.* stuff
Thanks a lot, Cory, this helps, but only partially. //code in main class extending Application var triangle:FlexSprite = new FlexSprite( ); //draw triangle rawChildren.addChild(triangle); shows a triangle in SWF, but also shows an error: (output) [Fault] exception, information=ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. (Flash debug player) ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/getChildIndex() at mx.managers::SystemManager/getChildIndex()[C:\dev\flex_201_ja\sdk\frameworks\mx\managers\SystemManager.as:1270] at mx.managers::SystemManager/mouseDownHandler()[C:\dev\flex_201_ja\sdk\frameworks\mx\managers\SystemManager.as:2478] Any ideas? On 2/14/08, Cory Petosky wrote: Flex apps override addChild to only allow things that implement IUIComponent. If you need to add a child that's just a plain display object, manipulate the rawChildren property instead. -- Best regards, GregoryN http://GOusable.com Flash components development. Usability services. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] pure AS3 app to use mx.* stuff
Glen, ...you can have your class in the app folder called SystemCore.as this looks like it extends a display object Not exactly :-) If It extends Sprite, the result is grey-gradient standard flex bg, w/o any traces of my objects. Trace commands are executed nice, however. If I make the main class extending mx.core.Application then, in addition to tracing messages, I can see my (white) background and initializing progress bar. But: === [Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert mx.core::[EMAIL PROTECTED] to mx.core.IUIComponent. Fault, addingChild() at Container.as:3301 === where FlexSprite is used in code: var triangle:FlexSprite = new FlexSprite( ); // drawing a triangle... addChild(triangle); And it's addChild() that causes the error (no error with addChild() commented). So far, it looks strange for me, as the argument's type of mx.core.Application.addChild() is DisplayObject. Thoughts? Glen Pike wrote: You can write pure AS3 files for Flex - all MXML gets compiled down to AS3 before it is compiled to bytecode. (I had done followed an example online which has a pure AS3 component - once it is written, you add the package to your namespace and add an MXML tag in your code to add it to the stage.) Like with the workaround on the forum you posted - if you have added your package path to the namespace ( xmlns:app=app.*), you can write your code in an AS file rather than an MXML file, then you write it as you would any other class file - no need for Script tags mixing mxml / as code. ?xml version=1.0 encoding=utf-8? mx:Application horizontalScrollPolicy=off xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:app=app.* layout=absolute frameRate=30 app:SystemCore id=sysCore width=100% height=100%/ /mx:Application So the above example, you can have your class in the app folder called SystemCore.as this looks like it extends a display object or similar as it has width and height attributes - not sure about extending other classes. -- Best regards, GregoryN http://GOusable.com Flash components development. Usability services. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] pure AS3 app to use mx.* stuff
Flex apps override addChild to only allow things that implement IUIComponent. If you need to add a child that's just a plain display object, manipulate the rawChildren property instead. On 2/14/08, Gregory N [EMAIL PROTECTED] wrote: Glen, ...you can have your class in the app folder called SystemCore.as this looks like it extends a display object Not exactly :-) If It extends Sprite, the result is grey-gradient standard flex bg, w/o any traces of my objects. Trace commands are executed nice, however. If I make the main class extending mx.core.Application then, in addition to tracing messages, I can see my (white) background and initializing progress bar. But: === [Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert mx.core::[EMAIL PROTECTED] to mx.core.IUIComponent. Fault, addingChild() at Container.as:3301 === where FlexSprite is used in code: var triangle:FlexSprite = new FlexSprite( ); // drawing a triangle... addChild(triangle); And it's addChild() that causes the error (no error with addChild() commented). So far, it looks strange for me, as the argument's type of mx.core.Application.addChild() is DisplayObject. Thoughts? Glen Pike wrote: You can write pure AS3 files for Flex - all MXML gets compiled down to AS3 before it is compiled to bytecode. (I had done followed an example online which has a pure AS3 component - once it is written, you add the package to your namespace and add an MXML tag in your code to add it to the stage.) Like with the workaround on the forum you posted - if you have added your package path to the namespace ( xmlns:app=app.*), you can write your code in an AS file rather than an MXML file, then you write it as you would any other class file - no need for Script tags mixing mxml / as code. ?xml version=1.0 encoding=utf-8? mx:Application horizontalScrollPolicy=off xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:app=app.* layout=absolute frameRate=30 app:SystemCore id=sysCore width=100% height=100%/ /mx:Application So the above example, you can have your class in the app folder called SystemCore.as this looks like it extends a display object or similar as it has width and height attributes - not sure about extending other classes. -- Best regards, GregoryN http://GOusable.com Flash components development. Usability services. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Cory Petosky : Lead Developer : PUNY 1618 Central Ave NE Suite 130 Minneapolis, MN 55413 Office: 612.216.3924 Mobile: 240.422.9652 Fax: 612.605.9216 http://www.punyentertainment.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] pure AS3 app to use mx.* stuff
Hi, I had similar problems - I have been developing with FD3 (nice) to write AS3 code and using Embed to add graphics / sounds at compile time. Graphics were created as MovieClips in Flash 8 - I have one file and set Linkages. Previously with AS2, I have used the Linkage / AS2 class file method, so this is a similar thing. Look at Keith Peter's post here for some direction: http://www.bit-101.com/blog/?p=853 I ran into some problems with this though - it looks like FD3 only has autocompletion for the core AS3 and the Flex side of things. I wanted to use the mx.* tween classes, but could not get these into my project as I don't have CS3... I asked about this on the FD Forums - search for author glenpike - and got the reply that I should install CS3 to compile against the classes, so I guess there is no stub code like FD coders have provided / integrated for Flex code autocompletion... There will probably be an issue with CS3 components too - have not tried this yet. FD3 allows you to create Flex / Flash projects so I guess the Flex one includes the framework if you use it (sorry, a few weeks since I did the Hello World stuff and have forgotten the exact bits). Also, if you use FD3, get the shell script for the Flex compiler - it improves compilation speed greatly - http://labs.adobe.com/wiki/index.php/Flex_Compiler_Shell Glen Gregory N wrote: Hi all, As far as I know, so called pure AS3 project typically uses flash classes, intristics and others that come along with Flash IDE. From the other side, Flex2 project can be built with Flex2 SDK , but *based on .mxml file*. Frankly, I'd prefer to use flash-like class structure, instead of mixed mxml-and-as code. After googling for an hour or so, the best workaround I've found is: http://www.actionscript.org/forums/archive/index.php3/t-146833.html I guess I'm not the only one who faced this issue. Can you please share you finding and/or thoughts? PS: currently I'm working in Flex2 SDK (via FlashDevelop), but without Flash IDE. -- Glen Pike 01736 759321 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] pure AS3 app to use mx.* stuff
Glen, thanks for your reply. Previously with AS2, I have used the Linkage / AS2 class file method, so this is a similar thing. Look at Keith Peter's post here for some direction: http://www.bit-101.com/blog/?p=853 I'd like to mention one thing here about embedding symbols (movieclips). The matter is that, if the mc has only one frame (as most of my symbols do), it's embedded as mx.core.SpriteAsset and should be use as is or casted to Sprite. Similarly, if the symbol has 2+ frames, it's embedded as mx.core.MovieClipAsset and can be casted to MovieClip. I spend several hours in frustration before found this in EAS3 book :-). FD3 allows you to create Flex / Flash projects so I guess the Flex one includes the framework if you use it (sorry, a few weeks since I did the Hello World stuff and have forgotten the exact bits). So do I :-) Actually, everything goes ok, unless I'm trying to use components ( mx.controls.*). No problem using them in mxml file, but, to use them in AS3, seems I need 1) minimal mxml to load application 2) make main class to extend mx.core.Application (not Sprite) From the other hand, there is NO way to use fl.controls.* (and other non-intristics) w/o Flash CS3 installed. Hence was the question - trying to make the required mxml as small as possible. BTW, Flexcoders have several posts about it, but seems they feel ok using script tag in mxml. While I'd prefer to have well-planned class structure... -- -- Best regards, GregoryN http://GOusable.com Flash components development. Usability services. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] pure AS3 app to use mx.* stuff
Hi, Sorry was getting confused with what you were trying to do... You can write pure AS3 files for Flex - all MXML gets compiled down to AS3 before it is compiled to bytecode. (I had done followed an example online which has a pure AS3 component - once it is written, you add the package to your namespace and add an MXML tag in your code to add it to the stage.) Like with the workaround on the forum you posted - if you have added your package path to the namespace ( xmlns:app=app.*), you can write your code in an AS file rather than an MXML file, then you write it as you would any other class file - no need for Script tags mixing mxml / as code. ?xml version=1.0 encoding=utf-8? mx:Application horizontalScrollPolicy=off xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:app=app.* layout=absolute frameRate=30 app:SystemCore id=sysCore width=100% height=100%/ /mx:Application So the above example, you can have your class in the app folder called SystemCore.as this looks like it extends a display object or similar as it has width and height attributes - not sure about extending other classes. Glen -- Glen Pike 01736 759321 www.glenpike.co.uk http://www.glenpike.co.uk ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders