A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Using Flash CS3 MovieClips classes in Flex Builder

  1. #1
    Developer
    Join Date
    Apr 2007
    Location
    UK
    Posts
    324

    Using Flash CS3 MovieClips classes in Flex Builder

    Hi,

    after seeing a tutorial on the gotoAndLearn website for using Flex Builder to code projects (the editor of which is vastly superior to Flash's) I've tried to migrate one of my projects to a Flex ActionScript project. However I've run into a problem.

    I have a MovieClip in my FLA which has a graphic and a button component. The button is called btn.
    I've linked that MovieClip to a class called 'tester'.
    In that class I use this simple code :
    Code:
    btn.label = "yay";
    Im able to compile into a SWF easily from Flash (and the button's label changes as expected).
    However when I move the project to Flex, Flex tells me in the tester class that 'btn' does not exist (which is understandable).
    However I CAN use code like this in my main class:
    Code:
    var t = new tester();
    t.btn.label = "yay"
    and that compiles fine (by the way, I've created an SWC that contains my tester MovieClip which I've told Flex to link to).

    Is there any way to get around this?
    I've tried creating a property called 'btn' in the tester class but this creates an error when I try and compile in CS3.

    Can anyone help?
    Last edited by Cortana; 01-23-2008 at 07:29 AM.
    now known as dVyper

  2. #2
    Developer
    Join Date
    Apr 2007
    Location
    UK
    Posts
    324
    bump?
    now known as dVyper

  3. #3
    The Cheeze to Your Macaroni ColbyCheeze's Avatar
    Join Date
    Dec 2007
    Location
    Texas
    Posts
    244
    Hey Cortana, I have been using Flash / Flex for a while now and have found a really simple way to work between the two.

    I'm not sure how you are linking the two but usually what I have to do is actually name the button in the .FLA (which I'm not sure if you have done.) I am not at my computer right now, so I'll have to look at my files when I get home and make sure that is all.

    Also IIRC I have an easier way of integrating the workflow than that of the tutorial on gotoandlearn website that you mentioned.

    more later....

  4. #4
    Developer
    Join Date
    Apr 2007
    Location
    UK
    Posts
    324
    Hi,

    excellent! I'll be waiting eagerly for more info
    now known as dVyper

  5. #5
    The Cheeze to Your Macaroni ColbyCheeze's Avatar
    Join Date
    Dec 2007
    Location
    Texas
    Posts
    244
    Okay I got home and found the code I use to work with objects in Flex.

    Alright so lets say we are going to load in a "title menu" in flash. I'll go ahead and make a Class for it in flex as follows:

    Code:
    [Embed(source="../assets/gameLib.swf", symbol = "GameMenu")]
    	public class TitleMenu extends MovieClip{
    Now inside of that swf file I have a symbol which I exported called GameMenu. Inside of THAT symbol I have a button on the stage which I named btn_playgame. In order to use that button in flex I have to do the following:

    Code:
    public var btn_playgame:SimpleButton;
    btn_playgame.addEventListener(MouseEvent.CLICK,clickButton);
    
    private function clickButton(e:Event):void{
    			//Play Game Code
    			}
    Simple as that! Hopefully that helps you. If you have any other questions about working in Flex msg me on MSN: colby [at] cheezeworld [dot] com

  6. #6
    Junior Member
    Join Date
    Dec 2007
    Posts
    1
    Hello,

    I'm new in here.
    I'm facing the same problem of accessing movieclip or button inside the swf which is embeded in flex.

    Can you pls provide any example for the same or any link to guide me through?

    Thanks in advance

    Trupti

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