Fritz -
this is easily enough done, but before showing you how to do that, can you
tell us why you want it in onEnterFrame? I suspect that the
creationComplete event is a more appropriate solution to what you are trying.
Here is the code you asked for:
ShowAlert.as
=========
package {
import mx.controls.Alert;
import mx.core.UIComponent;
import flash.events.Event;
public class ShowAlert extends UIComponent{
public function ShowAlert(){
this.addEventListener("enterFrame",showAlertBox);
}
public function showAlertBox(event:Event){
this.removeEventListener("enterFrame",showAlertBox);
mx.controls.Alert.show("frame entered");
}
}
}
main.mxml
=========
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" >
<ShowAlert />
</mx:Application>
If this is all you want, it can be done more simply as:
Main.mxml
========
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.macromedia.com/2005/mxml"
creationComplete="alert.showAlert()">
<ShowAlert2 id="alert" />
</mx:Application>
ShowAlert2.as
=========
package {
import mx.controls.Alert;
public class ShowAlert2 {
public function showAlertBox(){
mx.controls.Alert.show("drawn once");
}
}
}
At 09:54 AM 12/16/2005, you wrote:
>Hi.
>At first: thanks for your replies, they sound quite useful.
>But:
>Could anybody of you be so kind and show me, how to write an AS3 class
>and a MXML file which does the following:
>The mxml file should be the main file.
>
>The MXML file should invoke the AS class and the AS class should show
>an alert box onEnterFrame and then delete onEnterFrame.
>
>I hope somebody can show me how this works, I can't do it :(
>
>Thx,
>bye,
>Fritz
>
>
>
>
>
>--
>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
>
>
>
>
>
>SPONSORED LINKS
><http://groups.yahoo.com/gads?t=ms&k=Web+site+design+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ>Web
>
>site design development
><http://groups.yahoo.com/gads?t=ms&k=Computer+software+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw>Computer
>
>software development
><http://groups.yahoo.com/gads?t=ms&k=Software+design+and+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ>Software
>
>design and development
><http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=OO6nPIrz7_EpZI36cYzBjw>Macromedia
>
>flex
><http://groups.yahoo.com/gads?t=ms&k=Software+development+best+practice&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw>Software
>
>development best practice
>
>
>----------
>YAHOO! GROUPS LINKS
>
> * Visit your group
> "<http://groups.yahoo.com/group/flexcoders>flexcoders" on the web.
> *
> * To unsubscribe from this group, send an email to:
> *
> <mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]
>
> *
> * Your use of Yahoo! Groups is subject to the
> <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.
>
>
>----------
------------------------ Yahoo! Groups Sponsor --------------------~-->
Most low income homes are not online. Make a difference this holiday season!
http://us.click.yahoo.com/5UeCyC/BWHMAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
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
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/