A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Confused about Classes

  1. #1
    Junior Member
    Join Date
    May 2007
    Posts
    21

    Confused about Classes

    when you set the linkage for a movie clip, the base class is set for you, usually?
    then how do you know what Class to set?
    I made a rect on the stage. Converted it to mc.
    Set linkage for as3 and it said it would set the class automatically.
    No matter what I ask it to return
    this was simply a trace for x
    when I run it

    1119: Access of possibly undefined property x through a reference with static type Class.

    I know this is stupid but is there a clear tutorial on this somewhere?
    If the base class is set, why set the other if the mc is not really doing anything...
    cant find any as3 tuts on this to clear it up for me..
    any help is welcome..
    thanks

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    You convert something into movie clip. In the library it will have name "mymc". You set the linkage options and class is created for you automatically. The class name will be same as your name in the library. To show the movie clip on stage you write:

    othermc:mymc=new mymc();
    this.addChild(othermc);

    Now new instance of mymc will be visible on stage. You can access its properties whenever you need:

    othermc.x=100;
    trace(othermc.x);

  3. #3
    Senior Member
    Join Date
    Feb 2006
    Posts
    107
    I cant get this to work from my class..

    any additional help?
    Last edited by mpalma; 07-01-2007 at 03:03 PM.

  4. #4
    Senior Member
    Join Date
    Feb 2006
    Posts
    107
    Page.as
    Page.fla
    movieClip in the Library named "Page" and linked to Page class

    var nPage:Page = new Page()?
    nPage.addChild(nPage);
    nPage.x=100?

    what am I doing wrong?

    thanks in advance...

  5. #5
    hippie hater Cimmerian's Avatar
    Join Date
    Oct 2006
    Location
    over there
    Posts
    599
    Quote Originally Posted by mpalma
    what am I doing wrong?
    nPage.addChild(nPage);

  6. #6
    Senior Member
    Join Date
    Feb 2006
    Posts
    107
    Quote Originally Posted by mpalma
    Page.as
    Page.fla
    movieClip in the Library named "Page" and linked to Page class

    var nPage:Page = new Page()?
    nPage.addChild(nPage);
    nPage.x=100?

    what am I doing wrong?

    thanks in advance...

    sorry should have been
    Page.fla
    movieClip in the Library named "Page" and linked to Page class

    (in the class .as)
    var nPage:Page = new Page()?

    this.addChild(nPage);
    nPage.x=100?

  7. #7
    Senior Member
    Join Date
    Nov 2005
    Posts
    192
    var nPage:Page = new Page()
    addChild(nPage);
    nPage.x=100

    if you put that code in the main document class, page will be attached to the route stage. to change where its attached, you use dot syntax, for example

    pagelayer.addChild(nPage)

    Wait are you the same person as the thread starter? or did you just hijack his thread.... .........

    As for the thread STARTER, head over here to learn about classes

    http://www.kirupa.com/forum/showthread.php?t=223798
    and
    http://www.adobe.com/devnet/actionsc..._excerpts.html

    There are plenty of other tutorials on classes, but i only saved the links of those 2.
    Last edited by Flyingcow; 07-01-2007 at 09:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center