AS3 oop problem

I am a beginner with oop. Can anyone help me to understand
what is wrong
with this:
public class MyClass{
//set some variables in constructor
public function myMethod():void{
//my code
myMethod();
The line that calls the function generates the error message:
Call to a possibly undefined method myMethod.
Why?
Doug

Doug,
> Thanks for that. I've got it working now. I only mention
> AS3 as I've never used oop techniques with AS2 and I
> thought it might be different.
AS3 refers to ActionScript 3.0, a bona fide new version of
the language
(in fact, only in beta release, as of yet). See LiveDocs for
details ...
http://livedocs.macromedia.com/specs/actionscript/3
... the approach you're using, even if you're aiming for OOP,
is still AS2.
David
stiller (at) quip (dot) net
Dev essays:
http://www.quip.net/blog/
"Luck is the residue of good design."

Similar Messages

  • Is AS3 OOP Dying/Dead? I'm Confused and Lost!

    I'm looking to start learning OOP so I can create Game User Interface Prototypes but I'm worried that resources for learning how to use AS3 and Flash is very thin on the ground and really out of date. Some articles I've seen online are many years old and the community for AS3 OOP seems to be really quiet, especially when you compare it to JS or other OOP languages.
    A lot of jobs I've seen for UI Artists require the use of Flash to prototype UX flow and animation - but getting started seems to be really confusing, I feel like I'm looking for a linear set of tutorials focused on Game UI Prototyping and Animation effects, using either the TImeline or AS3 or both (what do you think is considered best practice).
    If you know of any resource that could help me get started, which covers this type of thing that would be awesome. Also, your thoughts on how healthy Flash AS3 is currently.
    Best,
    Warren

    i'm not sure of the future of as3, but oop appears to have legs.  and learning one oop language makes it simple to learn others, i don't see much downside to learning as3.
    i learned as3 (my first oop) in my spare time on a 10-day vacation by using senocular's tutorials coupled with the flash help files.  i was very familiar with sequential programming, but had difficulty comprehending oop.
    senocular.com
    Learning ActionScript 3 | Adobe Developer Connection
    Adobe ActionScript® 3 (AS3) API Reference
    but i don't think a linear tutorial is a good way to learn any language, computer or otherwise.  i recommend you read a little and then 'practice' a little.
    with computer languages that means, read a little, and then write some code.  play with it a little and experiment with code.
    for me, when first learning something i like to read about the same topic from two different authors.  that's why i liked going back and forth between senocular's tutorial and adobe's help files.  if you hit a problem, skip around to find a solution.  don't feel compelled to stick with a linear learning path.
    having that last link (the api) is critical to learning a computer language.  once you learn the basics and you learn how to use the api, you're done with all the memory work.  from then on it's just a matter of logic and creativity to find solutions for problems you encounter.

  • Load AS2 swf into AS3 swf problem

    I have a flash with AS3 and inside this swf i load in a AS2 swf.
    to load swf works just fine, but the problem is when i load this i want to go to
    a specific part of it, for example i want to go to frame 3 in the loaded swf.
    i must control this from the AS3 swf, does someone know if this is possible?
    thanks in advance

    so can i do like this then to go to frame 3 in my loaded swf?
    MovieClip(ldr.content).gotoAndStop(3); ?
    sorry for being such an airhead
    thanks for helping me out =)
    Date: Sun, 7 Jun 2009 10:25:09 -0600
    From: [email protected]
    To: [email protected]
    Subject: load AS2 swf into AS3 swf problem
    no.
    if, in your loaded swf, you have a function f1() on the loaded swf's main timeline and you load that swf using a loader (say ldr), use:
    MovieClip(ldr.content).f1();   // to call f1() in the loaded swf
    >

  • Simple OOP Problem. Help!

    This is just a simple OOP problem that i cant decide on a best
    implementation for.
    im passing an object to an instance of, 'TabbedFrame', which is just
    a frame with a Tabbed Pane in it that is holding custom panels.
    however, these custom panels need access to the object being
    passed to 'TabbedFrame' and to some methods in it.
    i cant make them static however so how do i gain access to them?
    is my only option to pass the 'TabbedFrame' to each panel?
    like - jtabbedpane.add( "Panel 1", new mypanel1(this));
    here is code:
    new TabbedFrame( DataObject );
    public class TabbedFrame{
    public TabbedFrame(DataObject do){
    this.do = do;
    jtabbedpane.add( "Panel 1", new mypanel1() );
    DataObject do;
    public class mypanel1{
    public mypanel1(){
    // need access to DataObject of the 'TabbedFrame' object that instantiated
    // this 'mypanel1' and to some of its methods
    }i would just pass the DataObject to evey panel (there are 12) but
    i also need to be able to call methods in the 'TabbedFrame'.
    Any help would be appreciated!

    Modify mypanel1's constructor:
    public class mypanel1{
    TabbedFrame tf;
    public mypanel1(TabbedFrame tf){
    this.tf = tf;
    // need access to DataObject of the 'TabbedFrame' object that instantiated
    // this 'mypanel1' and to some of its methods
    DataObject theDo = tf.getDataObject();
    tf.someMethod(); // Call method on the TabbedFrame
    }In TabbedFrame:
    public TabbedFrame(DataObject do){
    this.do = do;
    // Modify call to constructor to pass "this" TabbedFrame.
    jtabbedpane.add( "Panel 1", new mypanel1(this) );
    }

  • AS3 SCORM problem

    Hi there,
    Hope someone can assist!
    I am publishing my Captivate 4 project with AS3 settings, as I have created a few animations in AS 3 that are inserted. Now I am publishing it and putting it on our scorm compliant LMS, it is not communicating with the LMS.
    I have also published a file in AS2, which worked just fine in communicating with the LMS. Just took a course with one slide published it with AS2, then tried the same content exactly same settings only selecting AS3 and it didn't work.
    One of the differences is that with AS3 settings it also wants to open a new empty window, which it doesn't do with the AS2 setting.
    I have done some checking with the firebug in Firefox and it looks like it loads just fine, but when it starts playing it misses the communication with the LMS.
    I was wondering if there are any solutions out there...
    Thanks a lot!
    Annemarie

    No such thing as a stupid question....
    Yes I did check those settings... and that seems to be causing the problem.
    I just took an empty, new presentation (just for the process of elimination, no other values/factors involved) set the captivate settings to AS2 published tried it on the LMS, worked fine.
    Then same empty slide, set the captivate settings to AS3, all other settings remained exactly the same, tried it on the LMS, it plays fine, but there is no communication to the LMS.
    It loads all the swf files correctly, then with AS2 published file, it starts the "soaplms.php?op=initialize" and you can see in firebug (net) that the "scorm_support.swf?invokemethod etc" communicates with the LMS every few seconds, so it is reporting my progress and all that I do in the course.
    With the AS3 settings, it never does the "soaplms.php?op=initialize", and actually at that moment it should display this message, it opens a new emtpy window. The course continues to play and all the buttons work, but it doesn't communicate to the LMS what my progress is or what I have done in the course.
    There is a document that talks about the scorm compliance of Captivate and it mentioned that you might need to check that the API can be found, so I did that edited the html file, added the alert,  and the API can be found when launching the AS3 published file.
    I have also tried it on the scorm tracker site from rustici, which is a great resource by the way: http://www.scorm.com/scorm-solved/testtrack/
    You can upload your zip files and see the debug reports so you know exactly what happens in terms of communication to the LMS.
    ActusxReus wrote:
    stupid question, but did you double check that you selected Actionscript 3 in your Captivate preferences?
    ActusXreus, have you succesfully used AS3 settings in a course and published it and used it on an LMS where it did track the results? Or if there is anyone else out there that did use these settings successfully, I would really like to know and maybe see what type of settings you have used in the other areas...
    Thank you so much!
    Best regards from the Bahamas
    Annemarie

  • AS3 comboBox problem.

    Ok, I have a simple ComboBox with instance name of dragonCombo
    A Lable with an instance name of dragonLabel
    Using a an AS3 called Dragon.as
    When the ComboBox is clicked, a picture should pull up.   The problem is, there are no errors, but The ComboBox is not listing any of the Labels I loaded.  This is my AS3 code, maybe someone can see the mistake I have made somewhere.
    package
    import flash.display.MovieClip;
    import flash.display.Loader;
    import fl.controls.ComboBox;
    import fl.data.DataProvider;
    import flash.events.Event;
    import flash.text.TextFieldAutoSize;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    import fl.controls.Label;
    public class Dragons extends MovieClip{
    public var dragonCombo:ComboBox;
    public var dragonLabel:Label;
    var comboDP:DataProvider;
    var dragonLoader:Loader;
    public function Dragons() {
    setupComboDP();
    setupdDragonCombo();
    setupLabels();
    private function setupComboDP():void{
    comboDP = new DataProvider();
    comboDP.addItem({ Label:"Fire"});
    comboDP.addItem({ Label:"IceNFire"});
    comboDP.addItem({ Label:"Ghost"});
    private function setupDragonCombo():void{
    dragonCombo.width = 150;
    dragonCombo.prompt = "Choose a Dragon";
    dragonCombo.dataProvider = comboDP;
    dragonLoader = new Loader();
    dragonLoader.x = 200.00;
    dragonLoader.y = 60.00;
    addChild(dragonLoader);
    dragonCombo.addEventListener(Event.CHANGE,loadData);
    public function setupLabels():void{
    dragonLabel.text="";
    dragonLabel.autoSize = dragonLabel.autoSize = TextFieldAutoSize.LEFT;
    public function loadData(e:Event):void{
    dragonLoader.load(new URLRequest("dragons3/"+e.target.selectedItem.Label.toLowerCase()+".png"));

    Your Dragons class is creating its own dragonCombo (it is not the one on the stage)...
           public var dragonCombo:ComboBox;
    that has no association with the combobox you placed on the stage manually as far as I can see.
    Assuming this is not your document class, if all you are doing is importing the Dragons class, then you are not implementing it at all.  You would have to have a line...
         var dragons:Dragons = new Dragons();
    in you fla in order to instantiate the class.  At that point you might start seeing error messages because in doing that your class is trying to target an object that doesn't exist because it only declared the combobox, it did not create an instance of it, as in...
          dragonCombo = new ComboBox();

  • AS3 text problem

    Hi,
    Just playing with some AS3; and encountered the following
    problem (CODE IS ATTACHED):
    Wanted to create a MC button I seen done on the
    gotoandlearn.com site, but wanted to change it from AS2 to AS3;
    Everything works fine, but where I am assigning a value to a
    dynamic text field it not working.
    b1_mc.buttText_mc.buttonText_txt.text = "Lynda.com";
    When I test movie, lynda.com is the text on my MC button, but
    Upon ROLL_OVER etc... it displays the test text, not
    Lynda.com.
    Can someone please help me out here. It would be appreciated.
    Kind Regards,
    Boxing Boom

    Hi,
    Yes. Well spotted. I had the instance name of buttText_mc,
    missing the _mc part on a few frames with motion tweens applied, on
    the button animation. I do not remember renaming it differently ;)
    - must blame tools ;)
    Kind Regards,
    Boxing Boom

  • Tlftextfiled in textarea as3 component problem?

    i customize as3 textarea component (in source : fl.control.TextArea)
    i chnage textField in source to tlfTextFiled and i cand see RTL text in textArea component, but i have a problem , and i can not see affect my change in Direction
    please help me to change direction in this component
    excuse me for my poor english

    i customize as3 textarea component (in source : fl.control.TextArea)
    i chnage textField in source to tlfTextFiled and i cand see RTL text in textArea component, but i have a problem , and i can not see affect my change in Direction
    please help me to change direction in this component
    excuse me for my poor english

  • As3 preloader problem - Captivate5

    Hello all,
    Been searching around for this for a bit in a the forums and cant find anything on it here goes:
    I have a project that i built with a ToC for my company.  And i have a as3 preloader as well.
    Problem:
    Preloader is fine and centered in the middle of my project with out a ToC but when i add the Toc the preloader will not center in my project i have tried to alter it in the html file insterting <center> tags and such and also externalizing the skin or FMR SWF also removing and placing it back in and not getting a fix for it. I realize this maybe a simple fix but i cant find anything in the forums here discribing exactly this issue.
    can anyone help
    thanx
    bobby

    Hi,
    Going out on a stretch here but did you, by any chance, added external swf or widgets that would have set the values of either Stage.scaleMode or Stage.align. That could explain the effects you are seeing.
    Whyves
    www.flash-factor.com

  • AS3: Timing problem

    Hey,
    I have an 2 animations that I need to syncronize. The first animation is a projector screen entering stage, the second is few text layers and images.
    I timed the second animation 2.2 sec after the screen animation starts (using timer event) and it worked. When I tested it in other computers and on the internet the screen movment was much slower so the second animation entered the stage too fast.
    I want to order the second animation to enter only when the projector screen reach it's destination on stage. The screen animations has 2 parts, in animation and out animation connected by a stop(); commend in the middle.
    How can I do it without timer events?

    let say you want second_mc to play when first_mc is at frame 10.
    get in first_mc and add actionscript keyframe at frame 10 (you can add another blank script layer for this keyframe)
    to it's as3 code paset:  (root as MovieClip).second_mc.play();
    at frame one of second_mc add stop();
    shuld work now....
    אם אתה לא מסתדר שלח לי במייל את הבאנר ואת הפריים ממנו האנימציה צריכה להתחיל
    [email protected]

  • AS3 Loading problem

    Hello All,
                 I have written a simple AS3 Code to load a SWF File on he Stage. The file is loading properly but the Within the stage. The Width and height of the SWF file change. Like LoaderInfo return file size 200X200 , but after adding child the Width and height changes to 150.23 X150.23. I'm accessing the length of the loader.content property. At what ratio the change is a happening? I have attached the code...  Document property show content radio button clicked.
    stage.scaleMode=StageScaleMode.EXACT_FIT;
    //stage.scaleMode=StageScaleMode.NO_SCALE;
    //stage.scaleMode=StageScaleMode.SHOW_ALL;
    var Clip:Loader = new Loader();
    var req:URLRequest=new URLRequest("1.swf");
    Clip.contentLoaderInfo.addEventListener(Event.INIT,initListener);
    Clip.contentLoaderInfo.addEventListener(Event.COMPLETE,LoadingDone);
    Clip.load(req);
    var info:LoaderInfo;
    function initListener(event:Event):void {
         var SwfClip:Loader=Loader(event.target.loader);
         info=LoaderInfo(SwfClip.contentLoaderInfo);
         trace("File properties :- \n" + "width :- " + info.width + "\nHeight :- " + info.height);
    function LoadingDone(event:Event):void {     
         this.addChild(Clip);          
         trace(Clip.width + "  " + Clip.height + " " + (event.target.content).width + "  " +(event.target.content).height);

    You have stage.scaleMode set to EXACT_FIT which is causing the container to scale... and causing the loaded swf to scale as well. Remove that, or use No_SCALE and it will return the proper size.

  • Flash AS3 OOP = Can 1 objects class find and change another objects xy properties?

    What I have is a game with a Level object, inside the Level is a Player object, and they don't have instance names given, what I'm trying to figure out is how to do is make it so that the player can change the x or y properties of the Level object.
    To be more precise, I'm making it so that when the player moves in a certain direction, he either moves accross the stage, or he starts moving the Level object around the stage, it'd be in an Event kind of function, now I can easily make the Player move, but I don't know how to make the Level object move which the player is inside of.
    Is anyone able to help me on this please?

    I tried a simple getter setter idea, but it doesn't seem to work
    public class Mover
      private var _moveValue:Number = 5;
    public function Mover()
      Player.shift = _moveValue;
    public class Player
    private var _vx = 0;
    public static function set shift (_move:number):void
      _vx = _move;
    public function Player
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    function onEnterFrame(event:Event):void
    x += _vx;
    Thats with my limited imagination and knowledge of AS3 here so far... is that going completely wrong? If so are there any good examples or tutorials I could check out to get a better idea of what I'm trying to do?

  • AS3 + FMS2 = problem with "stream" MP3

    I use AS3!
    I can not get mp3 "duration" (Net Stream)
    where event: onID3??????? how it works???? and it works?????
    help plz :)

    My guess is that its to do with your embedding code. Check a)
    you have an id attribute assigned to the resulting object tag from
    whatever embedding method you use and b) for good measure make sure
    its unique in your html page.
    Javascript needs to have a valid reference to return the
    value from the javascript function back to flash. In my experience
    IE is more sensitive to issues here.
    If you get stuck post a test page somewhere.
    Tools to use to help with javascript debugging and view the
    html embed results (e.g. from swfobject or activecontent.js):
    In firefox : Firebug
    In IE: IE Developer Toolbar , Companion JS, and DebugBar are
    all helpful and , combined, get close to Firebug.

  • Slow as3 website problem

    Hello,
    My as3 flash website is too slow. If you click the top menu too quickly, the menu is not working properly and the website is getting slower. (And CPU usage is going up to %100) (Especially in Firefox) You can see here;
    http://gulhangulez.com/avas/
    So while coding as3 what can i do for best performance?
    For example should i create an external as. file? or internal is fine?

    Slow motion is going to look jittery and not fluid if you footage was shot normally and then slowed down in FCP. I've found that for normal motions, I can only get it to slow down about 80% before it starts to break down.
    However, if you're looking at a tree blowing in the wind or something like that (not human or animal motion) 50% speed works great.
    Slow motion simply can't create more information that what you originally shot. It does what it can, but the rest is where the footage isn't fluid.
    Hope that helps!
    ~Luke

  • AS3 Code problem

    I wrote this code:
    match = new Array();
    matchHoriz = new Array();
    row = 0;
    while (row < gridRows)
          col = 0;
         while (col < gridCols)
              match = getHorizMatch (row, col);
              if (match.length > 1)
                   match.unshift(grid[row][col]);
                   matchHoriz.push(match);
                  // ***1        
              if (match.length == 0)
                   col++;
              else
                   col = col + match.length;
              match.length = 0;
         row ++;
    // ***2
    If I place trace(matchHoriz) on position // ***1 it shows the correct result (an array with matched objects).
    If I place trace(matchHoriz) on position // ***2 it doesn't show anything.
    What is wrong about my code???

    Before I clear the match array, the array is added to the array matchHoriz so the data should be there no matter what I do with match array data. I figured out what was happening: when I add the match array with push, the data in the matchHoriz array doesn't look as I expected. I changed push with concat and everything is going right now.
    Thanks.

Maybe you are looking for