dcsimg
A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: [RESOLVED] Learning from books; adding Display Objects from the Symbol Library and ohter things

  1. #1
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193

    resolved [RESOLVED] Learning from books; adding Display Objects from the Symbol Library and ohter things

    (Taking up a topic from another thread)

    Here we have a case where it seems Koolmoves and Flash differ. I've run into a problem. I am working out of the book ActionScript 3.0 by Ypenburg. Pages (Chapter 5)The exercise is basically as follows:

    1.) Create a Button and save to the Symbol Library. Give it the Class name MenuItem which is to be an extension (as I understand it ) of the SimpleButton Class.

    2.) Create a MovieClip save to the Symbol Library. Give it a Class name of ShapeContainer which is an extension (as I understand it) of the MovieClip Class

    3.) Add a child object (in this case a MovieClip) to the ShapeContainer by editing its timeline via the edit in the symbol Library, give it animation and save this MovieClip to the Symbol Library. Give it a Class Name of CircleContent which itself is an extension (again as I understand it) of the MovieClip Class.



    With me so far?

    So in the Symbol Library there is one button and two MovieClips. All have class names as they are suppose to and the proper base classes.

    Here is the code put into the timeline. Doesn't work in Koolmoves and I'm not sure how to fix it. So in this example so far:

    Code:
    var miChapterOne:MenuItem = 
    	new MenuItem(); 
    
    var scShapeContainer:ShapeContainer = 
    	new ShapeContainer(); 
    
    var ccCircle:CircleContent = 
    	new CircleContent();  
    
    
    miChapterOne.x = 15;
    miChapterOne.y = 60;
    
    scShapeContainer.x =180;
    scShapeContainer.y = 60;
    
    
    addChild(miChapterOne);
    addChild(scShapeContainer);
    scShapeContainer.addChild(ccCircle);
    It would be very helpful if someone could explain how this needs to be written for Koolmoves in order to work. Apparently in Flash (which I don't have) there are some features which create classes automatically for you.

    I should also mention this is not the complete exercise but should work at this point.

    Thanks in advance
    Last edited by etuom; 08-07-2009 at 01:15 PM.

  2. #2
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    The code itself looks fine. Maybe you can attach the .fun file to your post to look at. It's possible you did something else wrong.

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    is there anything in these objects?

    I just checked and I created a movieclip with a simple shape in it. Added it to the symbol library and make sure to assign it class name, in my case was star.

    then in AS panel I just did

    var star1:star=new star();

    addChild(star1);

    and it works

  4. #4
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    The code itself looks fine. Maybe you can attach the .fun file to your post to look at. It's possible you did something else wrong.
    I completed the exercise so everything is there and will look a little different than what I have posted on this thread.

    Here is the fun file. I did have some trouble giving class names in the symbol library but I think i got that right. you may want to check there as well.



    is there anything in these objects?
    Yes these are are shapes that have been converted to either button or MovieClip and then saved to the symbol library.

    I'll try your star example and see if it works for me.
    Attached Files Attached Files

  5. #5
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    ok I did the star thing and it worked. One thing I learned in it that i didn't quite understand is that the description can be anything as long as the class name you are constructing is right.

    I had trouble with this until I started from scratch in a fresh fun file. doesn't make sense.

  6. #6
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    While Wilbert and Blanius are helping me out ....

    Just to clarify the topic of this thread is about adding movieclips and buttons to the library, giving them a class name, and adding them to the display with ActionScript at runtime. Exercise from Chapter 5 ActionScript 3.0 by Derrick Ypenburg. The book is written from the standpoint of Flash to teach ActionScript to the novice (me!). Part of the purpose of these threads is to address the issue of using these books for learning AS3 in Koolmoves. Stay tuned!

  7. #7
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Going Back and taking it slow . . .

    I have been able to add a Movie Clip Object from the symbol library but not a Button Object.

  8. #8
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Quote Originally Posted by etuom
    Here is the fun file. I did have some trouble giving class names in the symbol library but I think i got that right. you may want to check there as well.
    I don't understand where the problem comes from.
    KM shows a message
    Code:
    There are duplicate symbol names shown below. This needs to be corrrected.
    
    CircleContent
    but I don't see it named twice.
    Maybe Bob can take a look at the fun file

  9. #9
    Super Moderator
    Join Date
    Jun 2000
    Posts
    3,441
    I'll take a look at it.

  10. #10
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Bob, that was my first try which I stumbled through. Since then I reproduced the exercise and didn't get the CircleContent error. Here is a new file. I think the problem resides in the display of the button with class "MenuItem". I have not been able to add a button to the stage like with MovieClips as Bret showed.

    I'll also post the simple ButtonTest. Hope this helps
    Attached Files Attached Files

  11. #11
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    I think the issue is one of two things. If using button from GUI components then that already is in symbol library, that is the nature of them already you don't have to create it from the menu to add it.

    If you are trying to use the older style buttons from the menu they don't seem to work from as3 SYMBOL library as they are not really AS3 components so they don't inherit from Sprite. They will work if you switch to AS1.

  12. #12
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Quote Originally Posted by blanius View Post
    I think the issue is one of two things. If using button from GUI components then that already is in symbol library, that is the nature of them already you don't have to create it from the menu to add it.

    If you are trying to use the older style buttons from the menu they don't seem to work from as3 SYMBOL library as they are not really AS3 components so they don't inherit from Sprite. They will work if you switch to AS1.
    I am drawing a rectangle, converting it to a button, saving it to the Symbol Library with a class name of MenuItem and then Displaying on the stage with AS3.

    It is the same as your star example, but rather than a MovieClip, it is a Button, and it doesn't work with a Button. At least not for me.

    It seems you should be able to do this in this way.

  13. #13
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Maybe, but the issue I still believe is that that kind of button is not AS3, try this start by changing to AS1 then do that and it will work but not ask for class name but has linkage name.

    To be honest I don't use buttons much. It's more flexible to use a movieclip or sprite in most cases. and if you set buttonMode to true it gets the hand cursor on rollover. Also you can create them easily enough in script.

  14. #14
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Maybe, but the issue I still believe is that that kind of button is not AS3
    Ah! Because a button by it's very nature has AS, and that when using Koolmoves convert to button it converts it with AS1 Script? Do I understand correctly?

    Code:
    It's more flexible to use a movieclip or sprite in most cases. and if you set buttonMode to true it gets the hand cursor on rollover. Also you can create them easily enough in script.
    edit (hey! I made a sliding text box! how's that?)


    I'm beginning to see that! I just completed a Chapter that did that as an example of navigating to frame labels. It used "over" and "off" which could easily be expanded to the familiar "up", "over" and "down".

    So in AS1 when I use the edit Button state, am I really manipulating three frames with the GUI?
    Last edited by etuom; 08-07-2009 at 11:11 AM.

  15. #15
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    For now it looks like the button problem might be a KM bug.

    A button has states, not frames and it doesn't have to contain actionscript.
    An AS3 (non component) button is the equivalent of the SimpleButton class when you script things. When you are using AS3, these buttons are not converted to AS1.

    Bret has a point that a MovieClip is more flexible compared to a button. It can even simulate a button to some extent. If you set the buttonMode property of a movieclip to true, you can even use _up, _over and _down labels ( see http://help.adobe.com/en_US/AS3LCR/F...tml#buttonMode ).

  16. #16
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    Thanks for clarifying

  17. #17
    Senior Member etuom's Avatar
    Join Date
    Sep 2006
    Location
    Minnesota
    Posts
    193
    For now it looks like the button problem might be a KM bug.

    I see this problem has been addressed in KM 7.2!

    Thank you!

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