0
votes

I'm new to Adobe Flash. I'd like to create a button or component in Flash Professional using MovieClip and add label to it, and build my own button with special functions.

And i'd like use ActionScript to edit code. I faced a problem: i can not edit all code of my component (that cotains several ui-elements) in one AS3 class. I create empty document, add rectangle to it, then convert it to symbol. Next, i go to Advanced ActionScript 3.0 Settings of IDE, add path to folder where i put my Class. Then add MyClass to Document class in that window. But when i add new elements to the document, it doesn't appear in MyClass.as

Is it possible to edit complex component in Flash IDE in one ActionScript class ?

Sorry for a long explanation and for my poor english.

1
I think you have to make component with code. Of course you can sketch it in IDE (noting color values, sizes and x/y positions etc). Create a blank AS document and create shapes there, add any mouse events etc and anything to display on screen must have addChild ( the_visual_object ). Save this code as yourClass.as In a new Flash document you can use import yourClass; and to initialise it you do someVarName : yourClass = new yourClass; and to add that class content to stage you say stage.addChild( someVarName )... someVarName will be a reference to your code in yourClass file. - VC.One
Thank you! I just thought that there is some kind of two way binding between AS3 class declared in Advanced ActionScript 3.0 Settings and working stage of Flash IDE. In any case, thank you very match for you response! - andrew
Yes there is but right now I feel we are talking of any 3 possibilities. I think you've confused using an object's class file (not even sure how) as the actual document class file... I will elaborate an answer soon. - VC.One

1 Answers

0
votes

I create empty document, add rectangle to it, then convert it to symbol.

Make sure symbol is type: MovieClip. Give it a name you prefer (no space is good idea). Further down (see Advanced section?) there is section called Linkage click "Export for ActionScript" and remember the name shown in Class box (you can edit it) and just click OK. No need for folder paths etc.

Lets assume the name used for Class is : myComponent

Now you can use it in your code. To make a document class open the Properties panel (ctrl+F3) and just type a name example Main (no extensions) and press enter and then save FLA and secondly also save the class code (it will ask for a file name so use as Main.as).

Now If you click that pencil icon in properties you will be editing class code (Main.as) for the FLA document and it knows your component if you reference it by code:

public var test_comp : myComponent = new myComponent (); here test_comp is just a quick reference name. Use your own preferred reference name.

You can edit the MovieClip of myComponent by right-clicking and choosing "edit" (not "edit Class"). Now you can add/draw different things and even convert them to Graphic or MovieClip and give them instance names. A MovieClip object is like a mini-stage so it has its own unique timeline and you can work exactly like if this was the main stage (but without actually affecting main stage).

If you add something to Component MC such as drawing a circle (as some button?) and convert that circle to MC or Graphic type with instance name circle1, in the code you access that as:

test_comp.circle1.alpha = 0.5; since test_comp is your code's reference name for that myComponent MC in the Library.

After testing the above example... now begin your own component.

Remember... If an object is inside the MC access it via it's instance name and if you need to addChild it from the Library instead then use its AS3 linkage name.