PDA

View Full Version : Flash 8 Pro will not setInstanceAlpha on created text?


Atom
09-29-2006, 06:28 PM
Hi all,

Just discovering jsfl, I did a search on setInstanceAlpha and nothing.

Here is what I am trying to do.
I want to create a command that automagically creates a block of text that fades in.

Flash itself seems to not execute setInstanceAlpha in my command

Try this:
New document
F6 on frame 1
F6 on frame 10
Right click create motion tween.
Click on frame 10.
Create a new text object
Use the info TAB and set it's x,y to 0,0.

Put this code in command and run it.

//Set the fade in.
fl.getDocumentDOM().getTimeline().setSelectedFrame s(0,0,true);
fl.getDocumentDOM().mouseClick({x:10, y:10}, false);
fl.getDocumentDOM().setInstanceAlpha(0);


Quite simple, it selects frame 1.
Clicks on the text.
Then sets it alpha to zero.

Only it does no work. Does anyone know why?

Try this before you execute the command:
Click on frame 20 and press F5, this will create an empty frame and move the playback head to frame 20.
Now click in the white space of the stage, this deselects the text.
Run the command again and you will see that the playback head does move to frame 1 and the text object is selected. So it only the final setInstanceAlpha that seems to fail.

I would really like for this to work...:(

Atom

Atom
09-29-2006, 06:30 PM
Here is my command to date with a fade in fade out that does not work either.

var temp = prompt("Enter The Text:", "");
if (temp != null)
{
//Create the text.
fl.getDocumentDOM().addNewText({left:0, top:0, right:100, bottom:100});
fl.getDocumentDOM().setTextString(temp);

//The parameters that define static text.
fl.getDocumentDOM().setFillColor('#000000');
fl.getDocumentDOM().setElementTextAttr('indent', 0);
fl.getDocumentDOM().setElementTextAttr('lineSpacin g', -2);
fl.getDocumentDOM().setElementTextAttr('alignment' , 'left');
fl.getDocumentDOM().setElementTextAttr('size', 16);
fl.getDocumentDOM().setElementTextAttr('face', 'Myriad Pro');
fl.getDocumentDOM().setElementProperty('textType', 'static');
fl.getDocumentDOM().setElementTextAttr('letterSpac ing', 0);
fl.getDocumentDOM().setElementTextAttr('characterP osition', 'normal');
fl.getDocumentDOM().setElementTextAttr('bold', false);
fl.getDocumentDOM().setElementTextAttr('italic', false);
fl.getDocumentDOM().setElementProperty('orientatio n', 'horizontal');
fl.getDocumentDOM().setElementProperty('fontRender ingMode', 'advanced');

//Make some keys.
fl.getDocumentDOM().getTimeline().convertToKeyfram es(0);
fl.getDocumentDOM().getTimeline().convertToKeyfram es(10);
fl.getDocumentDOM().getTimeline().convertToKeyfram es(30);
fl.getDocumentDOM().getTimeline().convertToKeyfram es(40);

//Clear this extra keyframe created by the interface?
fl.getDocumentDOM().getTimeline().clearKeyframes(1 );

//Create motion tweens.
fl.getDocumentDOM().getTimeline().createMotionTwee n(0, 9);
fl.getDocumentDOM().getTimeline().createMotionTwee n(10,29);
fl.getDocumentDOM().getTimeline().createMotionTwee n(30, 39);

//Set the fade in.
fl.getDocumentDOM().getTimeline().setSelectedFrame s(0,0,true);
fl.getDocumentDOM().mouseClick({x:10, y:10}, false);
fl.getDocumentDOM().setInstanceAlpha(0);

//Set the fade out.
fl.getDocumentDOM().getTimeline().setSelectedFrame s(40,40,true);
fl.getDocumentDOM().mouseClick({x:10, y:10}, false);
fl.getDocumentDOM().setInstanceAlpha(0);
}
else
{
fl.trace ("User canceled text creation.");

}

Atom
09-29-2006, 07:34 PM
Got it,

It seems the JSFL does not report syntax errors?
I had a missing parameter on my mouse click.

Here is my working Create Text that fades in, then back out.

var temp = prompt("Enter The Text:", "");
if (temp != null)
{
//Create the text.
fl.getDocumentDOM().addNewText({left:0, top:0, right:100, bottom:100});
fl.getDocumentDOM().setTextString(temp);

//The parameters that define static text.
fl.getDocumentDOM().setFillColor('#000000');
fl.getDocumentDOM().setElementTextAttr('indent', 0);
fl.getDocumentDOM().setElementTextAttr('lineSpacin g', -2);
fl.getDocumentDOM().setElementTextAttr('alignment' , 'left');
fl.getDocumentDOM().setElementTextAttr('size', 16);
fl.getDocumentDOM().setElementTextAttr('face', 'Myriad Pro');
fl.getDocumentDOM().setElementProperty('textType', 'static');
fl.getDocumentDOM().setElementTextAttr('letterSpac ing', 0);
fl.getDocumentDOM().setElementTextAttr('characterP osition', 'normal');
fl.getDocumentDOM().setElementTextAttr('bold', false);
fl.getDocumentDOM().setElementTextAttr('italic', false);
fl.getDocumentDOM().setElementProperty('orientatio n', 'horizontal');
fl.getDocumentDOM().setElementProperty('fontRender ingMode', 'advanced');

//Make some keys.
fl.getDocumentDOM().getTimeline().convertToKeyfram es(0);
fl.getDocumentDOM().getTimeline().convertToKeyfram es(10);
fl.getDocumentDOM().getTimeline().convertToKeyfram es(30);
fl.getDocumentDOM().getTimeline().convertToKeyfram es(40);

//Clear this extra keyframe created by the interface?
fl.getDocumentDOM().getTimeline().clearKeyframes(1 );

//Create motion tweens.
fl.getDocumentDOM().getTimeline().createMotionTwee n(0, 9);
fl.getDocumentDOM().getTimeline().createMotionTwee n(10,29);
fl.getDocumentDOM().getTimeline().createMotionTwee n(30, 39);

//Set the fade in.
fl.getDocumentDOM().getTimeline().setSelectedFrame s(0,0,true);
fl.getDocumentDOM().mouseClick({x:10, y:10}, false,true);
fl.getDocumentDOM().setInstanceAlpha(0);

//Set the fade out.
fl.getDocumentDOM().getTimeline().setSelectedFrame s(40,40,true);
fl.getDocumentDOM().mouseClick({x:10, y:10}, false,true);
fl.getDocumentDOM().setInstanceAlpha(0);

}
else
{
fl.trace ("User canceled text creation.");

}


You may want to eliminate some of the setElementTextAttr. You could also map them to an XML field if you felt the need to create a more robust text fader.