[PS] AS3 suspendHistory() bug?
Hello,
I can be wrong (and that's a real possibility ), but there's something bizarre happening with CS SDK and the Photoshop suspendHistory() method working in ActionScript.
According to the API documentation, the parameters are:
historyString:String (String)The string to use for the history state.
javaScriptString:String — (String) A string of JavaScript code to execute during the suspension of history.
Currently I'm constantly getting this "Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop"
An excerpt of the code is as follows:
app.activeDocument.suspendHistory("Private stuff!", "app.activeDocument.duplicate()")
The Javascript string should be ok....
I would have liked to have an ActionScript:String instead (it'll be quite annoying to step in and out, AS3 and JS)... so just to try, I've substituted it with "var myDoc:Document = app.activeDocument.duplicate()" with no luck.
Could someone else try to test this method, please?
Thanks in advance,
Davide
The workaround I've found is to bounce from AS3 to JS to AS3.
My AS3 function calls a JS function within an embedded jsx (like in Zak's cookbook); this one contains a suspendHistory() method which in turn, calls another function back in the AS3 code.
Not ideal, but doable.
David, should I add the suspendHistory bug in the "CS SDK bugs" topic?
Thanks,
Davide
Similar Messages
-
Is there a bug in the as3 tween class
Is there a bug in the as3 tween class that causes tweens to stop before completing. I read that there is and that a 3rd party tween class should be used. I'm just starting out learning as3 and experimenting but this would be good to know when I move onto more complex projects.
Also the solution for this was to make your function global. Does this simply mean place your function in the top level of your movie.
I have done research on this topic but I found many conflicting answers.
Any assistance is welcome thanks in advance.the tween declaration (if you need one) must be placed within the scope of the function. so, if the below function f() is defined in a movieclip, you can use any of the 3 (but don't use the last):
///////// most common use ////////////////////////////////////////
var t:Tween;
function f(){
t=new Tween(...)
/////// next most common use /////////////////////////////////////////
//no declaration needed because the tween is not referenced anywhere outside the function so need not be assigned a variable
function f(){
new Tween(...)
/////////// least common, not good coding, but possible ////////////
// var t:Tween; // declared on the root timeline, for example
function f(){
MovieClip(root).t=new Tween(...)
p.s. please mark correct/helpful answers -
I found another serious AS 3 bug so i decided to write up a
verification script so anyone can verify these bugs and hopefully
someone over at adobe can squash them, as they are quite annoying
and require a considerable amount of effort to work around.
The first bug is a dynamically generated movieclip that has
various UI components to it will report its height incorrectly but
will display correctly
The second bug is when a combobox has its value changed it
generates a change event but for some reason, its parent
displayobject does not detect the event.
My project deals with auto layout of several dynamically
generated movieclips that contain dozens of comboboxes so these two
bugs combined are really getting on my nerves.
The code to reproduce these bugs is below. Just copy and
paste in a Flash IDE, add the combobox, checkbox and radiobutton
componets to the FLA's library and launch. I had a screen shot of
the height i measured with photoshop but doesn't look I can attach
it. At any rate, flash outputs 174 and i measured 99 for a
difference of 75.
-------------------------------Sample Code
Begin------------------------------------
//omnidogg - Jan 18,2008
//Code to illustrate 2 AS3 bugs
// 1. ComboBox change event does bubble up to parent
displayobject container
// 2. Dynamically sized movieclip's height property displays
correctly but the value returned from a get operation is incorrect
// just copy and paste into Flash IDE.
//import needed classes for example
import fl.controls.CheckBox;
import fl.controls.ComboBox;
import fl.controls.RadioButton;
import fl.controls.RadioButtonGroup;
//create a empty movie that will be the parent display
object, set backgroud to green, put around middle of stage
var mc1:MovieClip = new MovieClip();
this.stage.addChild(mc1);
mc1.opaqueBackground = 0x00FF00;
mc1.x = 50;
mc1.y = 60;
//create a combobox and add it to mc1. Add two choices to
illustrate change event bubbling bug.
//changing value in combo box generates an event but mc1 does
not detect it.
var cb1:ComboBox = new ComboBox();
mc1.cb1 = mc1.addChild(cb1);
mc1.cb1.x = 220;
mc1.cb1.y = 30;
mc1.cb1.addItem({label:"Choice 1"});
mc1.cb1.addItem({label:"Choice 2"});
//add a checkbox to mc1. This component behaves as expected.
var chkb1:CheckBox = new CheckBox();
chkb1.name = "chkb1";
mc1.chkb1 = mc1.addChild(chkb1);
mc1.chkb1.x = 220;
mc1.chkb1.y = mc1.cb1.y + mc1.cb1.height + 10;
mc1.chkb1.label = "Toggle";
//add two radio buttons in default radiobuttongroup to mc1.
selecting a new value generates 3 change events. I expected 2, 1
for each radiobutton.
//3rd from the radiobutton group? at least something is
generated which is better than nothing
var rb1:RadioButton = new RadioButton();
mc1.rb1 = mc1.addChild(rb1);
mc1.rb1.x = 180;
mc1.rb1.y = mc1.chkb1.y + mc1.chkb1.height + 20;
mc1.rb1.label = "Choice 1";
var rb2:RadioButton = new RadioButton();
mc1.rb2 = mc1.addChild(rb2);
mc1.rb2.x = 260;
mc1.rb2.y = mc1.chkb1.y + mc1.chkb1.height + 20;
mc1.rb2.label = "Choice 2";
//add a event listener to mc1 to detect any change events
mc1.addEventListener(Event.CHANGE,traceChange);
//trace the given text when a change event occurs
function traceChange(event:Event):void
trace("Change Event Detected");
//trace height of movie clip with various UI components
placed in it
trace(mc1.height); //outputs 174, measurements from photoshop
indicate 99. I can send a screenshot to anyone interested.
-------------------------------Sample Code
End--------------------------------------
Of course if these have already been found and squashed,
someone please point to me to the proper resources; seaches of the
knowledgebase don't turn up any revelant info.
ThanksThe incorrect height value you're getting is a timing issue.
Each these
components has a TextField somewhere in its heirarchy, which
is initialized
at 100x100. The resizing of the TextField doesn't occur until
after you've
checked the height of the container MovieClip.
If you listen for Event.ENTER_FRAME, you'll find that the
correct value is
returned once the component is fully rendered. In my test,
the correct value
was available on the 2nd ENTER_FRAME.
Try this:
this.addEventListener(Event.ADDED, _handler);
this.addEventListener(Event.ADDED_TO_STAGE, _handler);
this.addEventListener(Event.RENDER, _handler);
this.addEventListener(Event.ENTER_FRAME, _efhandler);
function _handler(event:Event)
trace(event.type, event.target, mc1.height)
var efcount:uint=0;
function _efhandler(event:Event)
efcount++;
trace(event.type, event.target, mc1.height)
if(efcount > 5) // i use 5, but can be fewer
this.removeEventListener(Event.ENTER_FRAME, _efhandler); -
I have got the answer for the problem of my previous post!
This bug is very annoying:
First check your version, mine is 11.0.0485. If yours are not, it could fixed. Anyway you can try:
1 create a new as3 file
2 create a MC
3 put one instance on frame 1 on the maintimeline, leave the name empty
4 put another instance on frame 2, name it "dog", whatever
5 on the frame2, write as followings:
trace(dog)
stop()
6 alt+enter
Oops! You got a "null" on output window!
Do we supposed to name every instance on the stage?
7 name or delete the instance on the first frame, see if the null turned into [Object MovieClip]!I get a bug
I wright some code in minetimeline
then edit a MovieClip
back timeline,the code intimeline is miss
my English is poor . sorry. -
An URLRequest url Problem or a Flash as3 bug?
hi, guys
I'm working with a Flash based HLS player. I am unable to locate a redirect url while the request server response a 302 redirect code.
is this a bug in Flash AS3 ?
var url:String = "http://aaa.company.com/xxxx"; (response a 302 code and redirect to http://bbb.company.com/yyyy)
var req:URLRequest = new URLRequest(url);
var dispatcher:URLLoader = new URLLoader(req);
dispatcher.addEventListener(Event.COMPLETE, handlefunction);
function handlefunction(event:Event):void
trace(req.url);
// the console outputs "http://aaa.company.com/xxxx"
// or trace((event.currentTarget as URLRequest).url); the output is same.
// it should be "http://bbb.company.com/yyyy"
// but the event.currentTarget.data is ok.
// so how can I get the new url ?
// is this a bug in flash as3?
thanks.I tried to use Socket instead of URLRequest.
_sock = new Socket();
_sock.addEventListener(Event.CONNECT,connectHandler);
_sock.addEventListener(Event.CLOSE,closeHandler);
_sock.addEventListener(ProgressEvent.SOCKET_DATA,socketDataHandler);
_sock.addEventListener(Event.COMPLETE,completeHandler);
_sock.addEventListener(SecurityErrorEvent.SECURITY_ERROR,function(e:SecurityErrorEvent):v oid{trace("security error");});
_sock.addEventListener(IOErrorEvent.IO_ERROR,function(e:IOErrorEvent):void{trace("io error");});
internal function connectHandler(event:Event):void {
trace("Connect...Ok");
//HTTP Request Header
var header:String = "GET "+_url+" HTTP/1.1\r\n";
header += "Accept: */* \r\n"
header += "Accept-Language: zh-cn \r\n";
header += "User-Agent: Mozilla/4.0 \r\n";
header += "Host: " + _host+":"+_port + " \r\n";
header += "Connection: Keep-Alive \r\n";
header += "Cache-Control: no-cache \r\n\r\n";
//write header string
_sock.writeUTFBytes(header);
_sock.flush();
internal function socketDataHandler(event:ProgressEvent):void {
//trace("socketDataHandler:"+event.bytesLoaded);
var data:String = _sock.readUTFBytes(_sock.bytesAvailable);
trace(data);
Outputs:
HTTP/1.1 302 Moved Temporarily
Date: Tue, 24 Apr 2012 07:25:35 GMT
Server: Apache-Coyote/1.1
Location: http://61.147.88.128/3/345/281/000
Content-Length: 0
X-Via: 1.1 nh227:9090 (Cdn Cache Server V2.0)
Connection: keep-alive
Finally, I got the 302 status, but I have some "sandbox" issue to solve.
Thanks. -
Timer Bug when repeatCount in Constructor is 0 (AS3)
I'm finding that, in some cases, creating a Timer (in AS3)
with the second parameter repeatCount = 0 causes the timer to fail
to trigger. I created a new .fla file and added the code below to
frame 1:
var fadeTimer:Timer = new Timer(100);
fadeTimer.addEventListener(TimerEvent.TIMER_COMPLETE,
onFadeOut);
fadeTimer.start();
function onFadeOut(event:TimerEvent):void {
trace("onFadeOut");
With this code the handler is never entered. Calling the
Timer constructor with only a single parameter (delay) causes the
default value of 0 to be used for the second parameter,
repeatCount. If I explicitly pass in repeatCount:
var fadeTimer:Timer = new Timer(100, 0);
the same problem occurs. However, if I change the 0 to a 1
the handler is called. I've used the 0 value for repeatCount in
other cases where it works correctly. In those cases, the code is
in an external ActionScript (.as) file instead of in the .fla. This
looks like a bug to me.
David SalahiOops, my bad! I was using the wrong event. Instead
TIMER_COMPLETE I should have been using TIMER. That works
correctly.
David Salahi -
Possible bug, at least serious problem, in the AS3.0 event architecture
Event bubbling causes a compiler error when it should not.
High up in the display list, a
listener has been added for TypeBEvent which extends
TypeAEvent.
Lower in the display list, a
different object dispatches a TypeAEvent, and sets bubbling to true
(and possibly, cancellable to false).
A Type Coercion error (#1034)
results! The listener receives the bubbled event which is of the
same type as the base class of the handler event type. The event
object "cannot be converted" to the TypeBEvent it is
receiving.
Circumstances
This situation came up in a real Flex project, where a video
player that had been loaded as a module within another module
dispatched a PROGRESS ProgressEvent, and a listener had been added
to the higher level module for its ModuleEvent PROGRESS event,
ModuleEvent subclasses ProgressEvent. The video player bubbled its
event, and the compiler threw this error: "TypeError: Error #1034:
Type Coercion failed: cannot convert
flash.events::ProgressEvent@1f2de0d1 to mx.events.ModuleEvent."
This compiler error does not make sense from a developer
perspective, because it means any class lower on the display list
can break the player (not the program, the player) simply by
dispatching an event.
Our team lost a great deal of (expensive) time trying to
locate the source of this problem, since nothing about the compiler
error – including the stack trace! – indicated the
high-level class. In fact, the module developer didn't know
anything about the high-level class which was compiled to a swc
library, and the event being dispatched was in the flex class
library, so neither end of the problem was very visible. Because
the error only pointed to the video player class the developer
naturally went into the flex classes first and tried to solve the
problem in their scope before finally giving up and bringing the
problem to others on the team.
Truly a case where the software defeated team workflow.
Our conclusion
We love the new event framework but, this seems to come
pretty close to qualifying as a bug. The high-level event listener
simply should NOT have received, then choked the player on the
bubbled base-class event. It should either receive it or not. If it
did receive the event, the code in the handler could check whether
the event target was appropriate... but instead the player breaks
and does not provide any clue as to where, it only indicates the
dispatching class as a culprit. Even short of fixing the problem,
improving the error message so that the receiving event handler is
clearly implicated would be a start.
Again I am of the opinion that this compiler error should not
take place at all because the top class subscribed specifically to
the subclassed event type. A bubbled event that breaks the player
due to an unrelated listener is just a huge black hole, especially
when multiple developers are working on different tiers of a
program.
Could we get a reply from someone at Adobe on this issue?
Thanks very much,
Moses GuneschIf you create a metadatatype with a single metdata block, and you reference that in your vm/cm cell attribute using a *one* based index, Excel seems to see the link and it honors it when saving the spreadsheet.
So, I ended up with something like:
<c ... cm="1"/> (I'm dealing with cell metadata, but the concept is equivalente to value metadata)
<metadataTypes count="1">
<metadataType name="MyMetaType" .../>
</metadataTypes>
<futureMetadata count="1" name="MyMetaType">
<bk>
<extLst><ext
uri="http://example" xmlns:x="http://example"><x:val>87</x:val></ext></extLst>
</bk>
</futureMetadata>
<cellMetadata count="1">
<bk><rc
t="1" v="0"/></bk> <!-- this is what gets referenced as cm=1 on the cell -->
</cellMetadata>
Hope this helps. -
AS3 rotation issue/bug need help.
Ok I have been converting a AS2 flash based sight to AS3. With the project I have to make new transitions for the pages. The client wants these transitions to be in 3d, which ive worked with before and have had no problems. However for the last few hours ive had this killer issue that wont go away.
When using rotationZ or rotationX on any element the rotation value is not based on 360 degrease but instead based on a random number. For example I can rotate a box on the stage by 0.03 and it will be ~rotated 180 degrease, but if I do the same rotation on another box on the stage it will go to ~40 degrease.
Im clueless to why this is happing and if I try to duplicate the error in another file it wont happen. So... anyone able to give me a heads up at what may be causing this?
For those asking how im rotating it.
box.rotationY = 45;
box2.rotationY = 90;Ok... heres the min code for the error to happen my side.
If you need an XML you can make your own to test this using the fallowing structer or just use this.
---------------------------- XML Bellow ------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<xml>
<page>
<name value="Home"/>
<background value=""/>
<content type="text">Hello this is random text? what the hell? what the duce?</content>
<x value="400"/>
<y value="20"/>
<content type="image">url to the image file</content>
<x value="400"/>
<y value="20"/>
</page>
</xml>
-------------------------------- AS3 Bellow -----------------------------
package {
import com.greensock.*; // this is a tweening class dont worrie about it
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
public class sps extends MovieClip {
var PAGES:MovieClip = new MovieClip();
var p_url:String="sps.xml"; // this generates content for pages loads and works fine dont worrie about it
var p_loader:URLLoader = new URLLoader();
var PageList:XMLList;
var rdy:Boolean = false;
public function sps() {
setFormats();
loadPages();
init();
public function init() {
addChild(PAGES);
PAGES.rotationY = 60; // This is were the problem is!
public function setFormats() {
ntf.color=0xFFFFFF;
ntf.font="Tahoma";
ntf.size=12;
ntf.align="center";
ntf.bold=true;
ntf.rightMargin=ntf.leftMargin=10;
public function loadPages() {
function onComplete(e:Event) {
p_loader.removeEventListener(Event.COMPLETE, onComplete);
var xmlData:XML=new XML(e.target.data);
PageList=xmlData.children();
var i:Number=0;
while (i < PageList.length()) {
makePage(PageList[i], PAGES);
i+=1;
p_loader.load(new URLRequest(p_url));
p_loader.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
public function makePage(pd:XML, p:MovieClip) {
var page:MovieClip =new MovieClip();
var pageCon:MovieClip = new MovieClip();
var i:Number=0;
while (i < pd.content.length()) {
if (pd.content[i].attributes()=="text") {
newText(pageCon, pd.content[i], pd.x[i].attributes(), pd.y[i].attributes());
}else if (pd.content[i].attributes()=="image") {
newImage(pageCon, pd.content[i], pd.x[i].attributes(), pd.y[i].attributes());
}else if (pd.content[i].attributes()=="video") {
}else if (pd.content[i].attributes()=="music") {
}else if (pd.content[i].attributes()=="subpage") {
}else if (pd.content[i].attributes()=="slider") {
i += 1;
pageCon.x-=472.5;
p.addChild(pageCon);
pageCon.addChild(page);
public function newText(p:MovieClip, t:String, x:Number, y:Number) {
var tf:TextField = new TextField();
tf.text = t;
tf.x=x;
tf.y=y;
p.addChild(tf);
return tf;
public function newImage(p:MovieClip, u:String, x:Number, y:Number) {
var f:URLRequest = new URLRequest(u);
var i:MovieClip = new MovieClip();
var l:Loader = new Loader();
i.x=x;
i.y=y;
l.load(f);
p.addChild(i);
function ps (e:ProgressEvent){
function lr(e:Event){
l.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, ps);
l.contentLoaderInfo.removeEventListener(Event.COMPLETE, lr);
i.addChild(l);
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, ps);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, lr);
return i; -
AS3 Masking with multiple objects bug
Hi again.
I have simplified my script to tell more about the problem.
I'm creating Sprite which holds other Sprites with graphics. The whole Sprite is used to mask MovieClip.
When I don't apply it as a mask, it shows, that objects are rendered correctly. But when I add it as a mask, flash fails to draw a mask where those Sprite objects overlap each other. You can see an example here:
With no masking applied: http://imageshack.us/photo/my-images/29/screenshot20110914at432.png/
With masking applied: http://imageshack.us/photo/my-images/233/screenshot20110914at433.png/
As i've seen, this bug doesn't occur everytime mask overlaps.
What could be the problem?bump...
-
Interval race condition - AS3 bug??
I have included the output and the two code segments that
trigger the output. I do not understand how this could happen.
Trace shows that clearInterval(19) occurs yet Wakeup seems to
trigger spontaneously still trying to clearInterval(19). This
occurs when user strums keypad triggering multiple calls to
KeyDownFunc. You can execute this code yourself by selecting
Lesson1 on page 1 of ItOnlyTakes1.org. It takes a few strumming
tries to trigger it but the following code demonstrates what is
happening within. Need help. (Interesting to note that 16 was never
cleared.)
Following code triggers the generation of a new display which
requires a user answer to be caught in KeyDownFunc. sleepID is a
global variable.
private function WakeUp():void {
clearInterval(sleepID);
trace("Wakeup calling: Cleared " + sleepID);
NewNumber();
Internal part of KeyDownFunc that calls WakeUp to trigger new
problem. The sleep interval is the time needed for the user to view
the correct answer was given BEFORE triggering a new WakeUP and
thus a new number
if (answer.length == subquanAnswer.length) {
if (answer == subquanAnswer && answerSign ==
subquanAnswerSign ) {
soundOutChannel = answerSound.play();
sleepID = setInterval(WakeUp, 1000);
trace("Call Wakeup: answer is " + answer + " " +
subquanAnswer + " New sleepID: " + sleepID);
gradeText.text=" CORRECT";
gradeText.setTextFormat(correctanswerformat);
} else {
gradeText.text=" INCORRECT";
gradeText.setTextFormat(incorrectanswerformat);
Output showing problem:
introListener calling
Call Wakeup: answer is 7 7 New sleepID: 2
Wakeup calling: Cleared 2
Call Wakeup: answer is 7 7 New sleepID: 4
Wakeup calling: Cleared 4
Call Wakeup: answer is 7 7 New sleepID: 6
Wakeup calling: Cleared 6
Call Wakeup: answer is 4 4 New sleepID: 8
Wakeup calling: Cleared 8
Call Wakeup: answer is 4 4 New sleepID: 10
Wakeup calling: Cleared 10
Call Wakeup: answer is 9 9 New sleepID: 12
Wakeup calling: Cleared 12
Call Wakeup: answer is 9 9 New sleepID: 14
Wakeup calling: Cleared 14
Call Wakeup: answer is 4 4 New sleepID: 16
Call Wakeup: answer is 4 4 New sleepID: 17
Wakeup calling: Cleared 17
Call Wakeup: answer is 6 6 New sleepID: 19
Wakeup calling: Cleared 19
Wakeup calling: Cleared 19
Wakeup calling: Cleared 19
Wakeup calling: Cleared 19
Wakeup calling: Cleared 19
Wakeup calling: Cleared 19
Wakeup calling: Cleared 19
Wakeup calling: Cleared 19To all,
I understand the insistence to clear before setting, but I
have not figured out how to get clearing and setting into the same
function. I am currently using a flag to avoid the race condition
that my code, not AS3, has created. This is what I am rethinking.
My current flow is like this.
1) generate a NewNumber()
2) check keys until correct number entered using KeyEvent.
Then set an interval to wait until the student has had time to
consider the correctness of this answer and to play the audio
feedback.
3) Interval timeout triggers WakeUp which clears the interval
then generates a NewNumber.
Only problem was, kids kept entering keys AFTER they had
answered correctly which, before my using a flag, was triggering
new setIntervals and the problem above.
I do not see how I can have my KeyEvent handler clear the
interval or how I can have my WakeUp functions set the interval.
They are two distinct functions.
If I do not clear the interval in WakeUp a long delay in
answering will trigger another NewNumber.
If I set it in WakeUp then I don't give the student enough
time to answer.
If I do not set it in keydown then I don't know how to ensure
they have time to see and hear the feedback
I can't clear it in KeyDownFunc because the kid may not push
a key and allow WakeUP to create a NewNumber()
I hope my brain isn't frying.
I do appreciate the continued effort in helping me and help
on this forum has improved my coding almost as much as if I had
someone watching over my shoulder. LOL, that would be
instantaneous. -
AS3 dynamic font embedding bug
Hi all,
Is there a known bug for the following case?
Case:
A project I'm working on doesn't seem to handle font embedding correctly when the font is added dynamically using actionscript. When I test my movie it does not display the embedded font at all. Curious about this is, that when I create an empty project using the same code and then embed the font and test the movie it displays the font without any problem.
Sometimes a reboot of the machine I'm working on will suffice to make the embedding work again, but sometimes is not all the time. So I was wondering if there was a memory related bug that causes this behavior. If so, is there any sight on a solution for this bug? It's more than annoying to reboot eight times a day, just to test a movie.
How did I embed the font:
1. Create a "New Font" in the Library, set the properties and give it a classname.
2. Using actionscript to embed the font in a dynamically generated TextField.
package{
import flash.display.MovieClip;
import flash.display.text.Font;
import flash.display.text.TextFormat;
import flash.display.text.TextField;
public class MyClass extends MovieClip{
var myFont:Font;
var myTextFormat:TextFormat;
var myTextField:TextField;
public function MyClass():void{
myFont = new Font1();
myTextFormat = new TextFormat();
myTextFormat.font = myFont.fontName;
myTextField = new TextField();
myTextField.defaultTextFormat = myTextFormat;
myTextField.embedFonts = true;
myTextField.text = "Lorem Ipsum...";
addChild(myTextField);
Cheers!
DoI don't have Flash IDE on this machine so I cannot say for sure but try to register font:
public function MyClass():void {
Font.registerFont(Font1);
myFont = new Font1();
// the rest... -
Try this:
Make a new AS3 project and in the actions in frame 1 write:
trace(10.3+0.3)
Now run it and get the result: 10.600000000000001
Trying the same with a AS2 project gives 10.6 as expected.
Please let me know if others can replicate this?Thanks. Did some research.
Didn't realise the unaccuracy kicks in with so few
decimals. -
Drag and Drop Bug (Flash, AS3)
Hello! Help, please! I'm making a game that involves dragging and dropping books. (Right now there is only one book.) While testing my game, I discovered by accident that no matter where I drag on the screen, the draggable book responds, moving around on screen despite the cursor not being on top of it. Here is my code. (It also snaps a larger book mc to the small one for purposes I intend to use later.)
// Making the small book dragable. //
small_book.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_6);
// when the mouse button is clicked...
function fl_ClickToDrag_6(event:MouseEvent):void
small_book.startDrag();
big_book_mc.x = small_book.x;///
big_book_mc.y = small_book.y;///-----> Makes the big book snap to the lil one when clicked.
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_6);
// when the mouse button is released...;
function fl_ReleaseToDrop_6(event:MouseEvent):void
small_book.stopDrag();
big_book_mc.x = small_book.x;///
big_book_mc.y = small_book.y;///-----> Makes the big book snap to the lil one when the mouse button is released.
stage.addEventListener(MouseEvent.MOUSE_DOWN, dragFn);
// if the mouse is currently dragging....;
function dragFn(event:MouseEvent):void
small_book.startDrag();
big_book_mc.x = small_book.x;///
big_book_mc.y = small_book.y;///-----> The big book follows while the mouse is dragging.
// the small book is now draggable and the big book snaps to it.your stage listeners should be added in the mousedown listener functions and then removed in the mouseup listener functions.
and just to clarify, your small book starts dragging no matter where there is a mousedown? -
This is the code of my document class:
public class FirstMask extends Sprite
private var maskedShape:Shape;
public function FirstMask() {
init();
private function init():void {
maskedShape = new Shape();
addChild(maskedShape);
maskedShape.graphics.beginFill(0xff0000);
maskedShape.graphics.drawRect(0,0,80,80);
maskedShape.graphics.endFill();
var maskShape:Sprite=new Sprite();
maskShape.graphics.beginFill(0x000000);
maskShape.graphics.drawRect(0, 0, 20,20);
maskShape.graphics.endFill();
maskedShape.mask=maskShape;
var bmd:BitmapData=new BitmapData(80,80);
bmd.draw(maskedShape);
When I do not use the bmd to draw the maskedShape,everything is ok.When I do that,it seems the maskShape is auto-transformed including its position and size.As a result,I can not see the maskedShape unless I adjusted the IE size.Can anybody tell me why?
ps:If I set this.stage.align=StageAlign.TOP_LEFT; I can see the small scaled maskedShape.If I add the maskedShape to the displaylist ,everythis is ok.But Why drawing has the effect on the drawn shape?Thanks again.But the "draw" itself is all right.
After " bmd.draw(maskedShape);",I code:
var bm:Bitmap=new Bitmap(bmd);
bm.x=100;
bm.y=0;
addChild(bm);
The bm can be shown.
So to make it clear,I print the screen:
1.No"mask" No "draw" at all.
2."mask" without "draw"
3."mask"and then "draw"---the IE shows nothing
4.If I drag the IE,adjust its size,then I can see a little thing on the top-left.
confusing...
PS:If I run the code as "air application",it seems all right. -
PS suspendHistory() workaround
Hello,
CS SDK 1.5 are out, and while I really like them a huge lot, the Photoshop document's method suspendHistory() in ActionScript is still bugged... sigh!
Waiting for an official fix (please, please ), I've come up with a (maybe obvious) workaround, which involves HostObject (as described by Zak Nelson in this CookBook entry) and a little tweak. Basically I bounce from AS3 to JSX and back to AS3 writing my own suspendHistory function.
If someone else is having troubles as I've had, this is possibly a viable solution to adopt.
Any suggestion to make it better: obviously welcome.
In a Controller.as class I embed a Javascript file
[ Embed (source="jsx/Bounce.jsx" , mimeType= "application/octet-stream" )]
private static var myScriptClass:Class;
Then I declare my own SuspendHistory function:
public function SuspendHistory(title:String, myFunction:String):void
var jsxInterface:HostObject = HostObject.getRoot(HostObject.extensions[0]);
jsxInterface.eval( new myScriptClass ().toString());
jsxInterface.init( this );
jsxInterface.Bounce(title,myFunction);
where title is the only History tag that will appear in the history states list, and myFunction is... the function that I'd like to call.
On the JSX side, I've a Bounce.jsx file
var asInterface = {};
function init(wrapper)
asInterface = wrapper;
function Bounce(title, myFunction)
var foo = "asInterface." + myFunction;
app.activeDocument.suspendHistory (title, foo)
The Bounce function takes the very same two parameters and bounces them back to ActionScript, calling the requested function wrapped inside a (natural working) ExtendScript suspendHistory call.
Using it in the AS3 class is straightforward, and you can even forget that there's some JSX action behind the scenes:
public function run():void
SuspendHistory("Stuff Happening", "myASFunction()");
public function myASFunction():void
app.activeDocument.activeLayer.duplicate();
app.activeDocument.activeLayer.duplicate(); // really fancy stuff...
The nice part is that the function called from within suspendHistory can have parameters as well (obviously, uh)
public function run():void
var loops:uint = 5
SuspendHistory("Stuff Happening", "myASFunction("+loops+")");
public function myASFunction(loops:uint)
for (var i:uint = 0; i<loops; i++)
app.activeDocument.activeLayer.duplicate();
even though to split with quotes the function code to add the parameter isn't that elegant... but as long as it works, I'm happy - and it's better than nothing.
Cheers,
Davide
Nevertheless a fix in the CSAW libraries would be betterForgot to mention you still have to have CS5 installed on your non-compliant laptop. Wouldn't it be funny if this is a PS bug requiring a toggled bit to be set in order to render in 3D?
Maybe you are looking for
-
Device issue with WLC (excluded client)
I have a single client that is having issues staying connected to my WLC running code 7.0.220.0 Here are the debugs, it just keeps on looping: *apfMsConnTask_0: Jul 18 10:41:06.352: 00:40:96:b8:78:7a Adding mobile on LWAPP AP 10:8c:cf:78:93:80(0) *ap
-
Remote / Home Sharing not working on a particular user account
I have recently purchased a new MacBook Pro 13" (Core i5) and I'm having issues using the Remote app on my iPhone 3GS, as well as using Home Sharing. I used Migration Assistant to transfer my account and files across from my previous MacBook (with wh
-
I lost all my playlists in iTunes. How do I restore them from a time machine backup? Didn't lose songs, just the playlists.
-
BAPI to get PO details of a VENDOR
Hi All, Is there any BAPI to get the PO details of a VENDOR ? While executong the BAPI it should ask for VENDOR number and for that vendor number it should show all the PO numbers. Let me know if their any BAPI similar to the above requirement. Thank
-
Hi Could anyone suggest how to take open service PO ? any reort or table available to download? Is PO closed indicator for service PO available? Kindly suggest Regards Arvind