Actionscript 3 When components (text) failed to appear in ScrollPane…
As title suggests, when you add components such as radio box, combo box, etc. in a ScrollPane. Initially, you only see the UI frames; labels and texts are not shown.
Then TRY THIS:
Select the components and change the DISPLAY property of that component to Layer. ![]()
Or in the coding:
import flash.display.DisplayObject.blendMode;
myComponent.blendMode = BlendMode.LAYER;
(Undo) Windows 7 System Restore and Actionscript files
On Thursday I was working on a flash simulation. After some minor changes on some movieclips, I compiled the fla file. To my surprise the compiled swf file went completely nuts.
My first reaction was:
“oh, it looks like the document class is missing, none of the function works…”
Indeed!!!
The document class which contains days of work is GONE!!! Together with some classes that draw specific shapes contains hours of calculation are missing!!!!
Since I backup my files on daily basis I did not panic immediately, I went to the folder that contains the work of the day before, THE SAME THING!!! The document class and other classes, basically all the actionscript files are missing.
I haven’t touched the document class, what the * happened??
I think anyone who has some experience with Actionscript and Flash would understand my shock and frustration. There were hundreds of functions in the document class, especially some of the features in the document class were written days ago, I am not sure if I still remember the exact construction.
….
Then I realized I had done a system restore the night before. I restored the system to the state of March 23. Indeed, the actionscript files that were written before March 23 are there.
So the system restore must be the cause
Just before I started to rewrite the document file all over again I managed to calm down. I decided to see if it’s possible to solve the problem in the same way the problem was caused (the Chinese wisdom here). In this case, it means to undo the system restore. And to my surprise it is BEAUTIFULLY DONE. After I undo the system restore, all actionscript files went back.
I guess what happened was that the system restore considers Actionscript files as some sort of system files or registration files. All other documents and files (that I have) are intact. Only Actionscript files are affected.
I think it must be some miscommunication between Microsoft and Adobe. Everything changes so fast; Microsoft is busy building new and newer operation systems; Adobe is busy with CS5…
Anyway, lessons learned here is that ALWAYS BACKUP before performing such kind of tasks.
Undo system restore:
Go to Control panel –> System –> System Protection –> System Restore: (the exact same way you perform a system restore)
Just find the system restore you want to undo and press next.
It’s just that simple.
AS3: ScrollPane, Mask & Dynamic TextField
Lately I ran into an issue that really had puzzled me. Now that I finally figured out what the * had happened. I just want to write it down so that I won’t waste any time on it later.
Here is what happened. I need to use dynamic text in the source of a ScrollPane component. So I did the usual way. Add the dynamic textField to a MovieClip called: contents. And then I initiate a ScrollPane called: sp, then:
sp.source = contents
And ctrl+Enter, to my surprise the textField does not show up!!
… several hours later …
Here is the problem: Mask!!!
Mask is used in the ScrollPane component. So, in order for dynamic text to work properly in a ScrollPane it has to bend to the rules of what Mask demands.
When used under a mask, a dynamic textField has to embed fonts.
After I embedded the font to the dynamic textfield, I can finally see the text.
So, it’s It is the Mask but not the ScrollPane that caused the problem. The ScrollPane component is perfectly fine with containing dynamic text.
AS3: Use Dynamic TextField in Buttons
When you develop Flash animation for a while you’re bond to run into this issue: How can I use dynamic textField in a button and make it behave like a button?
To make any Sprite or MovieClip a button is as simple as telling AS3 that:
mc.buttonMode = true;
However, if you happen to use a dynamic textField in the MovieClip or Sprite then you have a problem. Whenever mouse hovers the textField, the mouse cursor changes to the cursor that typically associate to text input field. While that’s not what you want for a button.
I’m sure there are many solutions, the solution I use is kind of quick and dirty. I call it Button Mask.
Here are the steps (use timeline):
- Draw a shape that covers the entire button mc.
- Make in a MovieClip itself, give it an instance name, i.e. “btnMask”
- Make sure the “btnMask” object is on the top layer.
- Make sure that the “btnMask” object is there but invisible: either set the Alpha value of the “btnMask” object to zero or make sure that the fill Alpha of the object is zero.
- In the actionscript code:
mc.btnMask.buttonMode = true; //mc is the instance name of the MovieClip
mc.btnMask.addEventListener(MouseEvent.CLICK, mcClicked);
function mcClicked(e:MouseEvent):void{
e.target.parent.gotoAndStop(2); //when clicked, mc goes to frame 2
}
The key here is that you have to remember to manipulate on the e.target.parent (which is the mc), instead of e.target (which is the btnMask). If you encounter any problem, such as the compiler complains no such object, then it’s always useful to first use :
trace(e.target.name);
to find out what exactly is the object that hovered by mouse.
If you construct everything from actionscript 3 code, then what you need to do is
- draw a shape
- give it an instance name
- add it to MovieClip
- set the index of this shape to the top
- Then the same code.
leave a comment