Help in AS3 Sprite

Hello All,
I got this Error : 1061: Call to a possibly undefined method addChild through a reference with static type Class.
what I'm trying to do :
I have create a new class called Graph and make it extends Sprite and  add a scroolpane to my stage and make an empty movie clip called content_mc and make the source of the scrollpane equals to content_mc
in the first frame i wrote this code
import Graph;
var graph:Graph = new Graph();
content_mc.addChild(graph);
Any help will be appreciated
Thanks in Advance

Thanks for your reply
I did what you say , but I still have the same error
and I have create the content_mc
insert-> new symbol -> Enter the name of content_mc -> choose the option export fpr actionscript and then click ok
and I have creating some shapes in it and test it with the scrollpane and it's working
but when i remove the shapes and use the action script to add an inistance from my graph to it i have the previous error
Thanks in Advance

Similar Messages

  • Need help on AS3!

    Hello! I need some help on as3. I'm still a noob at this stuff.
    I'm making a simple game. You have to click bugs that randomly moves down the screen. When you click the bugs they will become invisible
    and if any of the bugs pass through the bottom of the screen, you will lose 1 live.
    But right now, im having trouble with the script. When i click the bugs and it dissapear, the lives are still reduced. I don't get it.
    And theres also error coming out. "TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at buh_fla::MainTimeline/tekan()".
    Down here is the script :
    ===================================
    stop();
    import flash.events.Event;
    import flash.events.MouseEvent;
    var iscore:int = 0;
    score.text = iscore.toString();
    var health:int;
    health=3;
    trace(health);
    for(var i:int = 0; i<10; i++){
        var f:bug = new bug();
        addChild(f);
        var fn = Math.round(Math.random()*2)+1;
        f.gotoAndPlay(fn);
        f.x = Math.random()*stage.stageWidth;
        f.sp = Math.random()*7;
        f.addEventListener(Event.ENTER_FRAME, animate);   
        f.addEventListener(MouseEvent.CLICK, klik);
    function klik(e:MouseEvent){
    e.target.visible = false;
        iscore += 1;
        score.text = iscore.toString();
    function animate(e:Event){
        e.target.y += e.target.sp;
        if(e.target.y > stage.stageHeight){
            health--;
            trace(health);
            e.target.y = -20;
            e.target.visible = true;
    if(health==0){
    gotoAndPlay("gameover")
    ============================================

    stop();
    import flash.events.Event;
    import flash.events.MouseEvent;
    var iscore:int = 0;
    score.text = iscore.toString();
    var health:int;
    health=3;
    trace(health);
    var f:Array = new Array(); // ***********************
    for(var i:int = 0; i<10; i++){
        f[i] = new bug();
        addChild(f[i]);
        var fn = Math.round(Math.random()*2)+1;
        f[i].gotoAndPlay(fn);
        f[i].x = Math.random()*stage.stageWidth;
        f[i].sp = Math.random()*7;
        f[i].addEventListener(Event.ENTER_FRAME, animate); 
        f[i].addEventListener(MouseEvent.CLICK, klik);
    function klik(e:MouseEvent){
    e.target.visible = false;
        iscore += 1;
        score.text = iscore.toString();
        e.target.removeEventListener(Event.ENTER_FRAME, animate);
        e.target.removeEventListener(MouseEvent.CLICK, klik);
        if(iscore == 10) {
            gotoAndPlay("NextLevel"); //******************************
    function animate(e:Event){
        e.target.y += e.target.sp;
        if(e.target.y > stage.stageHeight){
            health--;
            trace(health);
            e.target.y = -20;
            e.target.visible = true;
    if(health==0){
    for(var i:int = 0; i<10; i++){
        if(f[i].visible) {
        f[i].removeEventListener(Event.ENTER_FRAME, animate);
        f[i].removeEventListener(MouseEvent.CLICK, klik);
        f[i].visible = false;
    gotoAndPlay("gameover")

  • Help with AS3 drop down menu

    I'm new to AS3, this script is from an xml drop down menu. I
    need to change all the font to " Gil Sans Lite: I looked down the
    string and only see a place to change fonts twice which I did. But
    the original font remains in the 1st button, the drop downs were
    changed. I also needed to align the buttona as my stage is bigger
    looking for the x/y elements but I was so tired I must have missed
    them. The seperate xml script only lets you change the text, amount
    of menus and urls. Any help?

    Thanks for the info, as I said I'm new to AS3 so I would need
    to know exactly where in the script I would insert this
    (Also the font is on my mac so it would be the font folder/,
    font name "Gil Sans Lite" ='NavItemFont'
    package {
    import flash.display.Sprite;
    public class NavItemFont extends Sprite {
    [Embed(source='C:/WINDOWS/Fonts/FRAMDCN.TTF',
    fontName='NavItemFont', whats the unicode range?
    unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+006 1-U+007A,U+007B-U+007E')]
    public static var NavItemFont:Class;
    and second it says" Render this out - so it is now
    NavItemFont.swf" does that mean change the original fla name and
    export it as NavItemFont.swf"?
    Also " Then in another flash app - load the external swf as
    an asset, and on-load register the font - which will make it
    global. You can now change NavItemFont.swf externally and it will
    change in your app everywhere. Can you explain?
    thx

  • Need help with as3 for popup window

    I am nearing the end of the semester in my Flash Animation class. I have learned very simple AS3 things, code snippets etc. I am trying to find the actionscript for coding a very simple popup window, but have not found a clue.
    Here's what I want to do...I have a white box with some type on the stage. When a person clicks on the white box, I want a popup to open that is larger, that will contain the same type but larger. That box will have an x so it can be dismissed. I don't want to do this in html, only in Flash CS5. I don't want a browser window, I just want a bigger version of the smaller box. I know how to build both boxes, just don't know how to write the code. I know there will be an on-click mouse event listener, and then I am lost.
    Can anyone help with the code I might use? It would be most appreciated.

    It would be something along the lines of... (using instance names relative to your description)...
    popup.visible = false;
    whiteBox.addEventListener(MouseEvent.CLICK, showPopup);
    function showPopup(evt:MouseEvent):void {
         popup.visible = true;
    popup.popupX.addEventListener(MouseEvent.CLICK, hidePopup);
    function hidePopup(evt:MouseEvent):void {
         popup.visible = false;

  • Need help with AS3 to play movies

    Here is my what I'm working with: Flash CS3, AS3. I have 4
    buttons and 4 movies (each button will be asigned to play one of
    the 4 movies).
    Not sure if this is the best layout but here is what's
    included in my file. I have an Actions layer, 4 buttons (on 4
    different layers), 4 embedded movies (on 4 different layers...all
    about 5-8 seconds long). I'm sure this is simple but figuring out
    the code for AS3 is like learning Chinese....I need major help with
    this.
    Lets say that my buttons have instance names like button1,
    button2, button3, button4, and my movies have instance names like
    movie1, movie2, movie3 and movie4. Here's the catch. I don't want
    the movies viewable (or seen) until the user selects one of the
    buttons. So if the user selects button1 the movie will appear (next
    to the button without any contols...just a movie with a border) and
    play. If the user hovers off or moves the mouse off the button, I'd
    like for the movie to disappear.
    Can someone please give me the the code needed so that when I
    select button1 that it will play movie1, button2 w/ movie2....and
    so on.
    Thanks for your help!

    Here is the link to the fla file.
    http://joshhicks.com/flash/flashfile.html
    I updated the link to the latest swf
    http://joshhicks.com/flash/del2.html
    I added stop(); to the 1st frame of each moive and this fixed
    the movies from playing in the background unseen. If you can help
    me with one last question...then the file will be complete. As of
    now when you select one of the movies, it plays once thru and
    starts back at frame one (loops) which is the way I want it to
    play. But if you hover off one of the buttons while the movie plays
    (lets say when the movie is showing the number 2) when you go back
    to view the same movie, it will start where you left off (it will
    start on the fram showing 2 and not 1). How can this be set up to
    play from the beginning of each movie everytime you happen to go
    back and click on the button? Thanks

  • Help with AS3, loading multiple files into a movieclip in specific order in scrollbar

    Hello! I am in need of some advice. We are trying to build a site with these features:
    Our site will be built in Actionscript 3.
    1. A navigation menu that, when a button is clicked, will scroll the site quickly to a specific Y position using swfaddress.
    2. The entire site is controlled by a flash scroll bar, which will be scrolling a single movieclip.
        2A. The movieclip will load content corresponding to the navigation categories, all which is organized into zipped files (using this to extract the contents of each section, example: about.zip for the about         section of the site)
        2B. The movieclip will load multiple zipped files one by one that correspond to the navigation, in order, making the site appear to be very tall.
    **What we are in need of is understanding how to load multiple zipped files into a movie clip, in a specific order, and having them scroll between one another through the navigation. The separate navigation categories can be in movieclips instead of zipped files if that is easier.
    Here is a reference of something that works like this: http://swfc-shanghai.com/#/about/

    Hello kglad! I have set aside the idea of using zipped files, and am now just using multiple external swfs that I'd like to load into the movieclip in a specific order. Any thoughts?
    I'm new to AS3, and I'm  attempting to create a scrolling movieclip that will load multiple  external files, in order, into that movieclip. I'm using XML as well. At  this point, nothing is loading into my movieclip (contentMain) and it's  a bit frustrating! Thank you for your help!
    Current error: 1180: Call to a possibly undefined method load.
    AS3:
    //XML Loader
    var myXML:XML = new XML();
    myXML.ignoreWhite = true;
    myXML.load ("master.xml");
    myXML.onLoad =function(sucess) {
       if (sucess) {
    contentMain.loadAll();{
         load("1_Overview.swf")
         load("2_Webcam.swf")
         load("3_Twounion.swf")
         load("4_Oneunion.swf")
         load("5_Retail.swf")
         load("6_Nearby.swf")
         load("7_Courtyard.swf")
         load("8_Map.swf")
         load("9_Conference.swf")
         load("10_News.swf")
         load("11_Sustainability.swf")
         load("12_Contact.swf")
    addEventListener("complete",onLoad)
    onLoad();{
    //load all
         }else {
             trace("ERROR LOADING XML");

  • Help! - as3 IE preloader issues

    Ok,
    So, I work for the NPS, and they have an outdated CMS. I have no rights  to upload an .html file, or edit one that the CMS makes.
    SO, I am forced to use their little deal to display my .swf files.
    Problem:
    http://www.nps.gov/glca/photosmultimedia/ehikes.htm
    I made an eHike in as3 Flash CS4. It has two scenes, the first scene is  the preload, second is splash content and ehike content. The problem is I  cant get the preloader to display in IE. I have all actionscript  content exported to the second frame, as talked about here:
    http://www.senocular.com/flash/tutor...preloaderstart
    and it works fine in firefox.......
    GRRRR....
    I have tried many different ways to load the preloader..... Here is what  I'm currently using....
    there is a simple text field for the percentage, and a simple 100 frame  animation. preloader_mc
    stop();
    var preLoaderPercent:Number = 0;
    addEventListener(Event.ENTER_FRAME, loadComplete);
    function loadComplete(e:Event):void {
        if (this.loaderInfo.bytesLoaded == this.loaderInfo.bytesTotal) {
        removeEventListener(Event.ENTER_FRAME, loadComplete);
        this.loaderInfo.removeEventListener(Event.COMPLETE, loadComplete);
        this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, loadProgress);
        gotoAndPlay("splash", "content");
    }//loadComplete
    this.loaderInfo.addEventListener(Event.COMPLETE, loadComplete);
    this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
    function loadProgress(e:ProgressEvent):void {
        preLoaderPercent = e.bytesLoaded / e.bytesTotal;
        load_txt.text = Math.ceil(preLoaderPercent * 100) + "%";
        var animstop:Number = Math.floor(preLoaderPercent*100);
        preloader_mc.gotoAndStop(animstop);
    The CMS lets you decide in the popup window if it is resizeable or not.  This works in IE (stopping people from resizing), but not in firefox,  people can resize it. Is there any way to disable the resize in AS3?  Again, I understand that your supposed to export the .html file with  these settings, but I have no permissions to upload or create new .html  files.
    Anyone who will help me with this - Thanks
    David

    The problem is talked about here:
    http://stackoverflow.com/questions/460677/serving-raw-swf-files-displays-in-firefox-but-no t-in-ie
    Solution was to preload with an external .swf
    Cheers

  • Help changing AS3 -- AS2 please

    I was following a tutorial in AS3 with a MouseEvent but really want to use it in AS2.
    There is an Input Text box named boxOne that a user enters their name
    You click on myButton and in then in boxTwo should appear the test "Welcome to our class" and what
    was entered in boxOne.
    The error message says " the class or interface MouseEvent could not be loaded
    The AS3 code is :-
    stop();
    function handleClick(pEvent:MouseEvent):void {
    var myFirstVariable = boxOne.text;
    boxTwo.text = "Welcome to our class " + myFirstVariable;
    myButton.addEventListener(MouseEvent.MOUSE_UP, handleClick);
    I'd really appreciate some help - thanks
    ActionScript Beginner.....but trying

    Diavonex indicated how to change the avatar for this web site. My impression is that is not what you are trying to do.
    The iPad isn't set up with individual user accounts at the OS level. There is no function on it as you are describing. If I'm wrong, perhaps you could describe what you re referring to in more detail.

  • Urgent help in AS3

    Hi
    I'm new in new in this Forum and to As3.
    I would really appreciate it if you guys could help me with nuisance that have been bothering for a while now.
    I'm trying to make a simple registration page - where the user when typing the right password will go the next page - where he/she can fill in there name and E-mail.
    And once they do that and click on the (myNext) button they will be taken to a new page where - Name, Email and any other information is outraced in a new TextField.
    If the user would press the (myClear) button instead - then all TextFields should be reset.
    I have tried many different ways to solve this and yet I would always get the same error: [TypeError: Error #1009:]
    Hence I don't even know where to start to fix this.
    I have added my code below
    Please help
    package
    {//01
        import flash.display.MovieClip;
        import flash.events.*;
        import flash.text.TextField;
        import flash.text.TextFieldAutoSize;
        import flash.text.TextFormat;
        import flash.text.*;
        public class Flash15 extends MovieClip
        {//02
            private var mypassWordField:TextField;
            private var myNext:Next;
            private var myClear:Clear;
            private var mypassWordFormat:TextFormat = new TextFormat();
            private var myNamn:Namn;
            private var myMail:Mail;
            private var myNamnField:TextField;
            private var myMailField:TextField;
            private var myInfoField:TextField;
            private var myNamnFormat:TextFormat = new TextFormat();
            private var myMailFormat:TextFormat = new TextFormat();
            //private var myInfoFormat:TextFormat = new TextFormat();
                  public function Flash15()
                  {//03
                      mypassWordField = new TextField();
                      addChild(mypassWordField);
                      mypassWordField.width = 100;
                      mypassWordField.height = 24;
                      mypassWordField.border = true;
                      mypassWordField.borderColor = 0xFFFFFF;
                      mypassWordField.background = false;
                      mypassWordField.backgroundColor = 0xFFFFFF;
                      mypassWordField.textColor = 0x99FFCC;
                      mypassWordField.selectable = true;
                      mypassWordField.multiline = false;
                      mypassWordField.wordWrap = true;
                      mypassWordField.type = TextFieldType.INPUT;
                      mypassWordField.maxChars = 6;
                      mypassWordField.restrict = "0-9";
                      mypassWordField.displayAsPassword = true;
                      stage.focus = mypassWordField;
                      mypassWordFormat.font = "Verdana";
                      mypassWordFormat.color = 0xFF0000;
                      mypassWordFormat.size = 23;
                      mypassWordField.defaultTextFormat = mypassWordFormat;
                      mypassWordField.x = stage.stageWidth * .51;
                      mypassWordField.y = stage.stageHeight * .21;
                      myNext = new Next();
                      myNext.alpha = 0;
                      addChild(myNext);
                      myNext.x = stage.stageWidth * .5;
                      myNext.y = stage.stageHeight * .7;
                      myClear = new Clear();
                      myClear.alpha = 0;
                      addChild(myClear);
                      myClear.x = stage.stageWidth * .5;
                      myClear.y = stage.stageHeight * .9;
                      stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownEvent);
                      myNext.addEventListener(MouseEvent.CLICK, onNext);
                      myClear.addEventListener(MouseEvent.CLICK, onClear);
                  }//03
                 private function onKeyDownEvent(p_evt:KeyboardEvent):void
                     //trace(p_evt.keyCode);
                     if(mypassWordField.text == "123456" && p_evt.keyCode == 13)              
                         trace("You are Logged in");
                         myNext.alpha = 1;
                         myClear.alpha = 1;
                         CheckIn();
                         CheckEnter();
                         stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownEvent);
                     else
                         trace("WRONG");
                  private function CheckIn():void
                      var myNamn = new Namn();
                      addChild(myNamn);
                      myNamn.x = 250;
                      myNamn.y = 420;
                      var myMail = new Mail();
                      addChild(myMail);
                      myMail.x = 250;
                      myMail.y = 570;
                   private function CheckEnter():void
                       var myNamnField = new TextField();
                       addChild(myNamnField);
                       myNamnField.width = 110;
                       myNamnField.height = 23;
                       myNamnField.border = true;
                       myNamnField.borderColor = 0xFFFFFF,
                       myNamnField.selectable = true;
                       myNamnField.multiline = false;
                       myNamnField.wordWrap = true;
                       myNamnField.type = TextFieldType.INPUT;
                       myNamnField.maxChars = 20;
                       myNamnFormat.font = "Verdana";
                       myNamnFormat.color = 0xFFFFFF;
                       myNamnFormat.size = 15;
                       myNamnField.defaultTextFormat = myNamnFormat;
                       myNamnField.text = "Enter";
                       myNamnField.x = 550;
                       myNamnField.y = 351;
                       var myMailField = new TextField();
                       addChild(myMailField);
                       myMailField.width = 200;
                       myMailField.height = 23;
                       myMailField.border = true;
                       myMailField.borderColor = 0xFFFFFF,
                       myMailField.selectable = true;
                       myMailField.multiline = false;
                       myMailField.wordWrap = true;
                       myMailField.type = TextFieldType.INPUT;
                       myMailField.maxChars = 70;
                       myMailFormat.font = "Verdana";
                       myMailFormat.color = 0xFFFFFF;
                       myMailFormat.size = 15;
                       myMailField.defaultTextFormat = myMailFormat;
                       myMailField.text = "Enter";
                       myMailField.x = 550;
                       myMailField.y = 401;
                   private function onNext(evt:MouseEvent):void
                       // New code here!
        }//02
    }//01
    Message was edited by: Tray0001

    click file/publish settings/flash and tick "permit debugging".  the problematic line number will be in the error message.
    if that's not enough info for you to solve the problem, highlight the problematic line of code.

  • Help with AS3 for CP5.5

    Hi,
    It seems that nobody can help me with my question http://forums.adobe.com/message/4900688#4900688  regarding some AS3 coding for Captivate course, therefore I would like to ask if anyone can help me in this forum section.
    How can I achive this:
    I am trying to open Captivate published SWF and to navigate to a specific slide, slide number 5 for example.
    Now, I created blank swf in flash containing this code:
    var myRoot:MovieClip = MovieClip(root);
    var mainmov:MovieClip = MovieClip(myRoot.parent.root);
    var external:Loader = new Loader()
    external.load(new URLRequest("../introduction.swf"))
    addChild(external)
    I have inserted this swf into a blank Captivate slide, and it loads fine. It plays from the beginning. Now I need this external Captivate  swf to play from slide number 5, since this is crucial (it will trigger some advanced actions inside course and some menu buttons will become available since they are not available when this course SWF is opened through its htm wrapper, so I  skip LMS communication when I open just SWF file, this is in short what I am trying to achieve ).
    AS3 for standard SWF created with  Flash will use something like this to navigate to a certain frame or scene of that external file:
    this.addEventListener(Event.ADDED_TO_STAGE,  startExternal);
    function startExternal(e:Event):void
        this.externalfileinstance.gotoAndPlay('5');
    Does anyone have any idea how to do something like this with Captivate SWF file? How to "tell" to CP SWF file to jump to a certain slide or at least a frame number? I hope that perhaps someone here knows something about this.
    Thanks!

    you should be able to use frame numbers.  i don't know which frame number you want to navigate to but you should be able to determine that using trial and error.
    also, you'll need to ensure that frame is loaded before applying your gotoAndPlay. ie, use a loop (eg, enterframe) to repeatedly check your framesLoaded property.

  • HELP ADOBE AS3! Playing frame twice is not working

    okay so I'm almost done with my website, but i got really stuck on the last part.
    i have a main page that works perfectly wen i just open my site, in it are buttons that takes me to three other minor pages, there are buttons in the minor pages that takes you back to the main page. when i click on these buttons and get i succesfully get to the mainpage, the codes don't work anymore and i cant click on the buttons to go to the minor pages :S!!! WHAT IS THE PROBLEM :'(.. it works in the begining and then it does't this doesnt make sense:
    this is the code i use:
    stop();
    buttons.buttonmotion.addEventListener(MouseEvent.CLICK, klk);
    function klk(event:MouseEvent):void {
    gotoAndPlay("motionreal");
    stop();
    buttons.buttonmodeling.addEventListener(MouseEvent.CLICK, hhh);
    function hhh(event:MouseEvent):void {
    gotoAndPlay("modelingreal");
    stop();
    buttons.buttonprint.addEventListener(MouseEvent.CLICK, kjk);
    function kjk(event:MouseEvent):void {
    gotoAndPlay("printreal");
    stop();
    buttons.buttonweb.addEventListener(MouseEvent.CLICK, lkk);
    function lkk(event:MouseEvent):void {
    gotoAndPlay("webreal1");
    stop();
    buttons.buttonaboutme.addEventListener(MouseEvent.CLICK, sos);
    function sos(event:MouseEvent):void {
    gotoAndPlay("aboutmereal");

    i tried making it go back the the mainpage by frame number and by label, and it actually does but the codes don't work anymore, and the codes are on top of that frame number and label name. i have the mainpage and other pages, all inside a movieclip.. called "masterclip" could that be the problem?
    my buttons are inside two movieclips, could that be the problem?
    im desperate for help ive been trying to finish my website for 3 months now, thats crazy!!!
    thanks for the reply , i hope u can solve me problem

  • Help!  Need help translating AS3 to AS2!

    Good afternoon. I have a very simple roll over animation that
    I want to use in Captivate 3. However, all of my experience with
    Flash is with AS3 which is not recognized by C3. Attached is my
    code snippet for the event that is not being supported. Would
    anyone be willing to tell me where to start to make this into AS2
    (or 1)?
    Thank you in advance for any assistance.

    MrFrankZ,
    Here's the code from your first post, and I understand you'd
    like to
    convert it to ActionScript 2.0 (or even 1.0):
    >>> gotoAndPlay("notRolled");
    >>> rollBox.addEventListener(MouseEvent.MOUSE_OVER,
    onRoll);
    >>>
    >>> function onRoll(event:MouseEvent):void
    >>> {
    >>> gotoAndPlay("rolled");
    >>> }
    >>> stop();
    To that, someone replied this:
    >> It's using AS 2. Can you display all of the code?
    ... which turns out to be incorrect. The code you're showing
    is indeed AS3.
    Telltale signs include the MouseEvent class reference, the
    MOUSE_OVER event
    constant, and the lowercase :void reference.
    > The compiler is "The class or interface 'MouseEvent'
    could not be
    > loaded."
    That makes sense for a FLA file configured for AS2, because
    AS2 doesn't
    have a MouseEvent class. Fortunately, this is a simple
    scenario, so let's
    break it down.
    The first line doesn't change at all:
    gotoAndPlay("notRolled");
    That does the same thing in either AS2 or AS3; namely, it
    invokes the
    MovieClip.gotoAndPlay() method on a particular MovieClip
    instance (happens
    to be the timeline in which this code appears) and sends that
    movie clip's
    timeline to a frame labeled "notRolled".
    Wiring up the event handler is your biggest change. AS2 does
    support
    the addEventListener() method, but only for components. In
    AS2, there are
    (bewilderingly) five different ways to assign event handlers,
    and the one
    that's going to work here -- and feel most this AS3 version
    -- looks like
    this:
    rollBox.onRollOver = onRoll;
    In principle, it's doing the same thing. I'm assuming
    rollBox is a
    movie clip symbol, so to see what functionality has has
    available to it,
    you'll look up the MovieClip class in the ActionScript 2.0
    Language
    Reference. When you do, you'll see headings for Properties
    (characteristics
    of the object), Methods (things the object can do), and
    Events (things the
    object can react to). A mouse-over is something the movie
    clip will react
    to, which makes it an event. What I've shown in my sample
    suggestion is the
    MovieClip.onRollOver event, as associated with your rollBox
    instance.
    The syntax is different from AS3, but the basic
    functionality is the
    same: "rollBox, when the mouse rolls over you, perform the
    onRoll()
    function."
    And now for that function:
    function onRoll():Void {
    gotoAndPlay("rolled");
    Only two small changes: a) drop the event:MouseEvent
    parameter and b)
    change :void to :Void.
    Here it is altogether:
    // AS2
    gotoAndPlay("notRolled");
    rollBox.onRollOver = onRoll;
    function onRoll():Void {
    gotoAndPlay("rolled");
    And to make this work in AS2, all you have to do is drop the
    strong
    typing (in this case, the :Void):
    // AS1
    gotoAndPlay("notRolled");
    rollBox.onRollOver = onRoll;
    function onRoll() {
    gotoAndPlay("rolled");
    David Stiller
    Co-author, The ActionScript 3.0 Quick Reference Guide
    http://tinyurl.com/2s28a5
    "Luck is the residue of good design."

  • Help pause AS3.0 frame Change Timer on rollover

    could someone help me out on as to how I could go about pausing this timer on rollover of an object, stage... anything?
    I am just cycling images on the main timeline via this timer but would like the timer to pause if a user has mouse over one of the images.
    Thanks for your help.
    var frameTimer:Timer = new Timer(2000);
    frameTimer.addEventListener(TimerEvent.TIMER, changeFrame);
    function changeFrame(e:TimerEvent):void
        if(MovieClip(root).currentFrame == totalFrames)
            MovieClip(root).gotoAndStop(2);
        else
            MovieClip(root).nextFrame();
    frameTimer.start();

    One approach would be to make a movieclip that is stage-sized with an alpha of 0 and treat it like a button, p[lacing it atop all other content.  This would block interaction with items below if that was necessary.  You could place it below all content as long as the content above also had the same rollover/out event listeners.
    Another approach would be to use a stage ENTER_FRAME event listener to continuously check the position of the mouse, and take action depending if it is within the boundaries of the stage or not.

  • Need help with AS3

    Hello. I am building a media browser which will dsiplay all
    my work. I have got it almost done except for one major problem.
    The thumbnail I click on wont show me the full size image.
    Have a look at what I'm doing at
    Http://www.JgcCreations.com
    The thumbnails are doing exactly what I need them to do but
    when I click the thumbnails the pic is suposed to get big and show
    up on the right in the black area.
    The code Im using to call the thumbnails into action is
    supposed to make the full sieze pics invisible on the stage (the
    black area) then as I click them the pictures will become visible.
    That is not working so far. Im not sure why it is not working.
    Anyone have a clue as to why it is not working. I appreciate any
    help. Im no programmer so an error in code to me is like a period
    at the end of a sentence....its all over lol....
    Thanks.

    From what I can tell, the file does exactly what you have it
    designed to do, though it isn't what you've tried to describe it as
    doing.
    Your thumbnails are not coded with a click function that
    might make the big pics visible.
    If the big pic is invisible, you cannot click on it because
    it's essentially not there. If you were to use alpha (0 vs 1)
    instead of visible (false vs true), then you could click on the big
    image to make it appear.
    I would have thought the thumbnails would be used to make the
    big picture appear. That would be the normal expectation of someone
    using this thing... they would be unlikely to click on the big
    black area. But the only code you have for the thumnails only
    addresses their own over and out mouse states.
    That's pretty much why your story about how this is supposed
    to work doesn't tie together and why I assumed your thumbnails were
    named the same as the big pics. It doesn't make sense to have
    something that has to be visible to click on making itself visible
    when you click on it.
    So if you want to make this what I think would make it
    normal, then you should use...
    function Pic(evt:Event):void {
    pic0.visible=true;
    thumb0.addEventListener(MouseEvent.CLICK, Pic);
    pic0.visible=false;

  • Help in AS3 code of 24 hour countdown timer

    hello,
    i  just wanna ask if someone can help me,
    i created a 24 hour flash countdown timer here http://allofmyworks.weebly.com/flash.html
    the problem is when it reaches the desired time, the time still counts and became negative,
    what i want is to make it only 24hour countdown clock and when it reaches the time it will only stay in 00:00:00
    thanks
    here is the code i used
    var endDate:Date = new Date(2012,0,4);
    var countdownTimer:Timer = new Timer(1000);
    countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
    countdownTimer.start();
    function updateTime(e:TimerEvent):void
              var now:Date = new Date();
              var timeLeft:Number = endDate.getTime() - now.getTime();
              var seconds:Number = Math.floor(timeLeft / 1000);
              var minutes:Number = Math.floor(seconds / 60);
              var hours:Number = Math.floor(minutes / 60);
              seconds %= 60;
              minutes %= 60;
              var sec:String = seconds.toString();
              var min:String = minutes.toString();
              var hrs:String = hours.toString();
              if (sec.length < 2) {
                        sec = "0" + sec;
              if (min.length < 2) {
                        min = "0" + min;
              if (hrs.length < 2) {
                        hrs = "0" + hrs;
              var time:String = hrs + ":" + min + ":" + sec;
              time_txt.text = time;

    here is the code
    var endDate:Date = new Date(new Date().getTime()+24*60*60*1000);
    var countdownTimer:Timer = new Timer(1000);
    countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
    countdownTimer.start();
    function updateTime(e:TimerEvent):void
              var now:Date = new Date();
              var timeLeft:Number = endDate.getTime() - now.getTime();
              var seconds:Number = Math.floor(timeLeft / 1000);
              var minutes:Number = Math.floor(seconds / 60);
              var hours:Number = Math.floor(minutes / 60);
              seconds %= 60;
              minutes %= 60;
              var sec:String = seconds.toString();
              var min:String = minutes.toString();
              var hrs:String = hours.toString();
              if (sec.length < 2) {
                        sec = "0" + sec;
              if (min.length < 2) {
                        min = "0" + min;
              if (hrs.length < 2) {
                        hrs = "0" + hrs;
              var time:String = hrs + ":" + min + ":" + sec;
              time_txt.text = time;

Maybe you are looking for