[flexcoders] Actionscript sprite within the Flex framework
I'm trying to do a primarily Actionscript 3 written Flex app writing within the Flex framework. Following Moock's Actionscript 3.0: The Essential Guide examples, I have set up a simple 3 file project, all files in the same folder. The app attempts to draw a circle on the stage. See code and errors below: //Application MXML file ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=EntryClass.main() /mx:Application //EntryClass.as file package { import mx.controls.Button; import mx.core.Application; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var mxmlApp:Application = Application(Application.application); mxmlApp.addChild(testSprite); } } } //TestSprite.as file package { import flash.display.Sprite; class TestSprite extends Sprite { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Before compiling, I get this error: 1084: class 'TestSprite' will be scoped to the default namespace: internal. It will not be visible outside of this package. After compiling, the debugger gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert ::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi ld() What's happening here? Is there a better way to set this up? Thanks. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team
Re: [flexcoders] Actionscript sprite within the Flex framework
The first error says you need the TestSprite class to be defined like: public class TestSprite extends Sprite The second error I initially thought was because the application addChild takes a UICompoent, but according to the help docs what you have 'should' work. I would try casting it as a DisplayObject although this probably isn't the correct way to fix it. mxmlApp.addChild(testSprite as DisplayObject); Steve On 9/19/07, Merrill, Jason [EMAIL PROTECTED] wrote: I'm trying to do a primarily Actionscript 3 written Flex app writing within the Flex framework. Following Moock's Actionscript 3.0: The Essential Guide examples, I have set up a simple 3 file project, all files in the same folder. The app attempts to draw a circle on the stage. See code and errors below: //Application MXML file ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=EntryClass.main() /mx:Application //EntryClass.as file package { import mx.controls.Button; import mx.core.Application; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var mxmlApp:Application = Application(Application.application); mxmlApp.addChild(testSprite); } } } //TestSprite.as file package { import flash.display.Sprite; class TestSprite extends Sprite { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Before compiling, I get this error: 1084: class 'TestSprite' will be scoped to the default namespace: internal. It will not be visible outside of this package. After compiling, the debugger gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert ::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi ld() What's happening here? Is there a better way to set this up? Thanks. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links
RE: [flexcoders] Actionscript sprite within the Flex framework
Even though the API says addChild takes DisplayObject, we can't override function signatures. The rules in Flex are: Navigator can only take Containers Containers can only take IUIComponents UIComponents can take anything. So put in a UIComponent tag and put the test sprite in there. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Wednesday, September 19, 2007 8:22 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Actionscript sprite within the Flex framework The first error says you need the TestSprite class to be defined like: public class TestSprite extends Sprite The second error I initially thought was because the application addChild takes a UICompoent, but according to the help docs what you have 'should' work. I would try casting it as a DisplayObject although this probably isn't the correct way to fix it. mxmlApp.addChild(testSprite as DisplayObject); Steve On 9/19/07, Merrill, Jason [EMAIL PROTECTED] mailto:jason.merrill%40bankofamerica.com wrote: I'm trying to do a primarily Actionscript 3 written Flex app writing within the Flex framework. Following Moock's Actionscript 3.0: The Essential Guide examples, I have set up a simple 3 file project, all files in the same folder. The app attempts to draw a circle on the stage. See code and errors below: //Application MXML file ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() /mx:Application //EntryClass.as file package { import mx.controls.Button; import mx.core.Application; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var mxmlApp:Application = Application(Application.application); mxmlApp.addChild(testSprite); } } } //TestSprite.as file package { import flash.display.Sprite; class TestSprite extends Sprite { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Before compiling, I get this error: 1084: class 'TestSprite' will be scoped to the default namespace: internal. It will not be visible outside of this package. After compiling, the debugger gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert ::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi http://www.adobe.com/2006/flex/mx/internal::addingChi ld() What's happening here? Is there a better way to set this up? Thanks. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links
RE: [flexcoders] Actionscript sprite within the Flex framework
So put in a UIComponent tag and put the test sprite in there. How would that look? I'm calling my class method as soon as the applicationComplete event occurs. Everything else is in Actionscript, the only MXML is this: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=EntryClass.main() /mx:Application Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Wednesday, September 19, 2007 12:29 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework Even though the API says addChild takes DisplayObject, we can't override function signatures. The rules in Flex are: Navigator can only take Containers Containers can only take IUIComponents UIComponents can take anything. So put in a UIComponent tag and put the test sprite in there. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Wednesday, September 19, 2007 8:22 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Actionscript sprite within the Flex framework The first error says you need the TestSprite class to be defined like: public class TestSprite extends Sprite The second error I initially thought was because the application addChild takes a UICompoent, but according to the help docs what you have 'should' work. I would try casting it as a DisplayObject although this probably isn't the correct way to fix it. mxmlApp.addChild(testSprite as DisplayObject); Steve On 9/19/07, Merrill, Jason [EMAIL PROTECTED] mailto:jason.merrill%40bankofamerica.com wrote: I'm trying to do a primarily Actionscript 3 written Flex app writing within the Flex framework. Following Moock's Actionscript 3.0: The Essential Guide examples, I have set up a simple 3 file project, all files in the same folder. The app attempts to draw a circle on the stage. See code and errors below: //Application MXML file ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() /mx:Application //EntryClass.as file package { import mx.controls.Button; import mx.core.Application; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var mxmlApp:Application = Application(Application.application); mxmlApp.addChild(testSprite); } } } //TestSprite.as file package { import flash.display.Sprite; class TestSprite extends Sprite { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Before compiling, I get this error: 1084: class 'TestSprite' will be scoped to the default namespace: internal. It will not be visible outside of this package. After compiling, the debugger gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert ::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi http://www.adobe.com/2006/flex/mx/internal::addingChi ld() What's happening here? Is there a better way to set this up? Thanks. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com http://www.mail-archive.com/flexcoders%40yahoogroups.com
RE: [flexcoders] Actionscript sprite within the Flex framework
?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() mx:UIComponent id=host / /mx:Application public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var host:UIComponent = Application.application.host; host.addChild(testSprite); From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Wednesday, September 19, 2007 10:46 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework So put in a UIComponent tag and put the test sprite in there. How would that look? I'm calling my class method as soon as the applicationComplete event occurs. Everything else is in Actionscript, the only MXML is this: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() /mx:Application Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Wednesday, September 19, 2007 12:29 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework Even though the API says addChild takes DisplayObject, we can't override function signatures. The rules in Flex are: Navigator can only take Containers Containers can only take IUIComponents UIComponents can take anything. So put in a UIComponent tag and put the test sprite in there. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Wednesday, September 19, 2007 8:22 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Actionscript sprite within the Flex framework The first error says you need the TestSprite class to be defined like: public class TestSprite extends Sprite The second error I initially thought was because the application addChild takes a UICompoent, but according to the help docs what you have 'should' work. I would try casting it as a DisplayObject although this probably isn't the correct way to fix it. mxmlApp.addChild(testSprite as DisplayObject); Steve On 9/19/07, Merrill, Jason [EMAIL PROTECTED] mailto:jason.merrill%40bankofamerica.com wrote: I'm trying to do a primarily Actionscript 3 written Flex app writing within the Flex framework. Following Moock's Actionscript 3.0: The Essential Guide examples, I have set up a simple 3 file project, all files in the same folder. The app attempts to draw a circle on the stage. See code and errors below: //Application MXML file ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() /mx:Application //EntryClass.as file package { import mx.controls.Button; import mx.core.Application; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var mxmlApp:Application = Application(Application.application); mxmlApp.addChild(testSprite); } } } //TestSprite.as file package { import flash.display.Sprite; class TestSprite extends Sprite { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Before compiling, I get this error: 1084: class 'TestSprite' will be scoped to the default namespace: internal. It will not be visible outside of this package. After compiling, the debugger gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert ::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx
RE: [flexcoders] Actionscript sprite within the Flex framework
Thanks - got the first error fixed, but the second one remains. If I cast testSprite as DisplayObject, I still see this error: Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert [EMAIL PROTECTED] to mx.core.IUIComponent.) mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi ld mx.core::Container/addChildAt mx.core::Container/addChild ..etc. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Wednesday, September 19, 2007 11:22 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Actionscript sprite within the Flex framework The first error says you need the TestSprite class to be defined like: public class TestSprite extends Sprite The second error I initially thought was because the application addChild takes a UICompoent, but according to the help docs what you have 'should' work. I would try casting it as a DisplayObject although this probably isn't the correct way to fix it. mxmlApp.addChild(testSprite as DisplayObject); Steve On 9/19/07, Merrill, Jason [EMAIL PROTECTED] mailto:jason.merrill%40bankofamerica.com wrote: I'm trying to do a primarily Actionscript 3 written Flex app writing within the Flex framework. Following Moock's Actionscript 3.0: The Essential Guide examples, I have set up a simple 3 file project, all files in the same folder. The app attempts to draw a circle on the stage. See code and errors below: //Application MXML file ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() /mx:Application //EntryClass.as file package { import mx.controls.Button; import mx.core.Application; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var mxmlApp:Application = Application(Application.application); mxmlApp.addChild(testSprite); } } } //TestSprite.as file package { import flash.display.Sprite; class TestSprite extends Sprite { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Before compiling, I get this error: 1084: class 'TestSprite' will be scoped to the default namespace: internal. It will not be visible outside of this package. After compiling, the debugger gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert ::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi http://www.adobe.com/2006/flex/mx/internal::addingChi ld() What's happening here? Is there a better way to set this up? Thanks. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links
RE: [flexcoders] Actionscript sprite within the Flex framework
Alex, thanks, but changing to your code suggestion, I still get an error, Main Thread (Suspended: ReferenceError: Error #1069: Property host not found on MyTestApplication and there is no default value.) and I think it is because EntryClass.main() gets called on the event applicationComplete, so the id for the UICompoenent does not exist yet, since it is further down the MXML. Chicken and egg thing, and not sure how to fix? Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Wednesday, September 19, 2007 2:51 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() mx:UIComponent id=host / /mx:Application public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var host:UIComponent = Application.application.host; host.addChild(testSprite); Recent Activity * 81 New Members http://groups.yahoo.com/group/flexcoders/members;_ylc=X3oDMTJnOHFiam5xB F9TAzk3MzU5NzE0BGdycElkAzEyMjg2MTY3BGdycHNwSWQDMTcwNTAwNzIwNwRzZWMDdnRsB HNsawN2bWJycwRzdGltZQMxMTkwMjI3OTQw Visit Your Group http://groups.yahoo.com/group/flexcoders;_ylc=X3oDMTJmZzh2b2tyBF9TAzk3M zU5NzE0BGdycElkAzEyMjg2MTY3BGdycHNwSWQDMTcwNTAwNzIwNwRzZWMDdnRsBHNsawN2Z 2hwBHN0aW1lAzExOTAyMjc5NDA- Yahoo! Finance It's Now Personal http://us.ard.yahoo.com/SIG=12j8rkb7g/M=493064.10729649.1140.867457 8/D=groups/S=1705007207:NC/Y=YAHOO/EXP=1190235140/A=4507179/R=0/SIG=12de 4rskk/*http://us.rd.yahoo.com/evt=50284/*http://finance.yahoo.com/person al-finance Guides, news, advice more. Need traffic? Drive customers http://us.ard.yahoo.com/SIG=12j76kc6d/M=493064.10729656.1147.867457 8/D=groups/S=1705007207:NC/Y=YAHOO/EXP=1190235140/A=3848644/R=0/SIG=131l 83flq/*http://searchmarketing.yahoo.com/arp/srchv2.php?o=US2006cmp=Yaho octv=Groups5s=Ys2=s3=b=50 With search ads on Yahoo! Popular Y! Groups Is your group one? http://us.ard.yahoo.com/SIG=12jmha3at/M=493064.11127061.11695037.867457 8/D=groups/S=1705007207:NC/Y=YAHOO/EXP=1190235140/A=4763761/R=0/SIG=11ou 7otip/*http://advision.webevents.yahoo.com/bestofyahoogroups/ Check it out and see. . http://geo.yahoo.com/serv?s=97359714/grpId=12286167/grpspId=1705007207/ msgId=87768/stime=1190227940/nc1=4507179/nc2=3848644/nc3=4763761
RE: [flexcoders] Actionscript sprite within the Flex framework
Alex, thanks, but changing to your code suggestion, I still get an error, Main Thread (Suspended: ReferenceError: Error #1069: Property host not found on MyTestApplication and there is no default value.) and I think it is because EntryClass.main() gets called on the event applicationComplete, so the id for the UICompoenent does not exist yet, since it is further down the MXML. Chicken and egg thing, and not sure how to fix? Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team
RE: [flexcoders] Actionscript sprite within the Flex framework
Shouldn't be, appcomplete is way late, long after host is ready. Can I see what your code looks like now? Both the app and the TestSprite. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Wednesday, September 19, 2007 1:36 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework Alex, thanks, but changing to your code suggestion, I still get an error, Main Thread (Suspended: ReferenceError: Error #1069: Property host not found on MyTestApplication and there is no default value.) and I think it is because EntryClass.main() gets called on the event applicationComplete, so the id for the UICompoenent does not exist yet, since it is further down the MXML. Chicken and egg thing, and not sure how to fix? Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team
Re: [flexcoders] Actionscript sprite within the Flex framework
Change the extends Sprite to UIComponent Merrill, Jason [EMAIL PROTECTED] escribió: I'm trying to do a primarily Actionscript 3 written Flex app writing within the Flex framework. Following Moock's Actionscript 3.0: The Essential Guide examples, I have set up a simple 3 file project, all files in the same folder. The app attempts to draw a circle on the stage. See code and errors below: //Application MXML file ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=EntryClass.main() /mx:Application //EntryClass.as file package { import mx.controls.Button; import mx.core.Application; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var mxmlApp:Application = Application(Application.application); mxmlApp.addChild(testSprite); } } } //TestSprite.as file package { import flash.display.Sprite; class TestSprite extends Sprite { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Before compiling, I get this error: 1084: class 'TestSprite' will be scoped to the default namespace: internal. It will not be visible outside of this package. After compiling, the debugger gives this error: TypeError: Error #1034: Type Coercion failed: cannot convert ::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi ld() What's happening here? Is there a better way to set this up? Thanks. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team - ¡Sé un mejor asador! Aprende todo sobre asados en: http://mx.yahoo.com/promos/mejorasador.html
RE: [flexcoders] Actionscript sprite within the Flex framework
Change the extends Sprite to UIComponent nope - same error message - thanks though. Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team
RE: [flexcoders] Actionscript sprite within the Flex framework
wait -thanks guys - changing to extends UICOmponent instead seems to have fixed it: //App: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=EntryClass.main() mx:UIComponent id=host / /mx:Application //ActionScript file Entry Class: package { import mx.core.Application; import mx.core.UIComponent; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var host:UIComponent = Application.application.host; host.addChild(testSprite); } } } // ActionScript file TestSprite: package { import flash.display.Sprite; import mx.core.UIComponent; public class TestSprite extends UIComponent { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Wednesday, September 19, 2007 4:53 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework Shouldn't be, appcomplete is way late, long after host is ready. Can I see what your code looks like now? Both the app and the TestSprite. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Wednesday, September 19, 2007 1:36 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework Alex, thanks, but changing to your code suggestion, I still get an error, Main Thread (Suspended: ReferenceError: Error #1069: Property host not found on MyTestApplication and there is no default value.) and I think it is because EntryClass.main() gets called on the event applicationComplete, so the id for the UICompoenent does not exist yet, since it is further down the MXML. Chicken and egg thing, and not sure how to fix? Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team
RE: [flexcoders] Actionscript sprite within the Flex framework
Shouldn't be required, but ok From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Wednesday, September 19, 2007 2:44 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework wait -thanks guys - changing to extends UICOmponent instead seems to have fixed it: //App: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=EntryClass.main() mx:UIComponent id=host / /mx:Application //ActionScript file Entry Class: package { import mx.core.Application; import mx.core.UIComponent; public class EntryClass { public static function main():void { var testSprite:TestSprite = new TestSprite(12, 100, 100); var host:UIComponent = Application.application.host; host.addChild(testSprite); } } } // ActionScript file TestSprite: package { import flash.display.Sprite; import mx.core.UIComponent; public class TestSprite extends UIComponent { private var _x:int; private var _y:int; private var _radii:int public function TestSprite(size:int, posx:int, posy:int) { x = posx; y = posy; _radii = size; graphics.lineStyle(1, 0xFFCC33); graphics.beginFill(0xCC3300, 1); graphics.drawCircle(0, 0, _radii); graphics.endFill(); } } } Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Wednesday, September 19, 2007 4:53 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework Shouldn't be, appcomplete is way late, long after host is ready. Can I see what your code looks like now? Both the app and the TestSprite. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Merrill, Jason Sent: Wednesday, September 19, 2007 1:36 PM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Actionscript sprite within the Flex framework Alex, thanks, but changing to your code suggestion, I still get an error, Main Thread (Suspended: ReferenceError: Error #1069: Property host not found on MyTestApplication and there is no default value.) and I think it is because EntryClass.main() gets called on the event applicationComplete, so the id for the UICompoenent does not exist yet, since it is further down the MXML. Chicken and egg thing, and not sure how to fix? Jason Merrill Bank of America GTO Learning Leadership Development eTools Multimedia Team