Output and Compiler Errors Window not working in CS6 - actionscript-3

Since I've updated Flash CS5 to CS6, my trace function doesn't show anything in Output window.
I've checked my code, even inserting errors, and no tracks or errors showed in both windows. This is the code:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Main extends MovieClip {
public function Main() {
trace("Hello World");
btn1a.addEventListener(MouseEvent.CLICK, salute);
}
private function salute(e:MouseEvent){
trace("Hello World 2");
/*trace(e.target.x);
trace(e.target.y);
trace(e.target.width);
trace(e.target.height);
trace(e.target.valueOf());*/
}
}
}

Try to verify if the filter level of your output panel is NOT "None" which prevent any information from appearing in the Output panel; and select "Verbose" which send all information to the Output panel.
Hope that can help.

Related

How to access class functions during events from currentTarget object in AS3

I have loaded movieClip to stage and was performing some events on that movieClip. Movie clip has own public functions and variables, and those are NOT accessible through currentTarget object in events.
Here is sample class:
package {
import flash.display.MovieClip;
import flash.display.Shape;
public class SampleClass extends MovieClip {
var str:String;
public function SampleClass() {
str="Some string";
/* draw just a sample rectangle to click on it */
var rectangle:Shape=new Shape ;
rectangle.graphics.beginFill(0x000000);
rectangle.graphics.drawRect(0,0,100,100);
rectangle.graphics.endFill();
}
public function getStr():String {
return str;
}
}
}
And here is loading on the stage and creating event:
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class MainClass extends MovieClip {
var a:SampleClass;
public function MainClass() {
a=new SampleClass();
addChild(a);
a.addEventListener(MouseEvent.CLICK,clickEvent);
}
function clickEvent(evt:MouseEvent):void {
var Obj=evt.currentTarget;
trace (Obj.getStr());
}
}
}
Tracing will return null instead of string value cause currentTarget is an Object, not a Class (movieClip). Any idea how to solve this?
//use this code it will work
function clickEvent(evt:MouseEvent):void {
var Obj:SampleClass = evt.currentTarget as SampleClass;
trace (Obj.getStr());
}
I dont know if your problem is solved now but the code you posted in your question worked okay for me..
What I did to test it..
In a new blank document, open Library (ctrl+L) and right-clicked to make symbol (MovieClip)
In linkage section, tick Export for Actionscript and call it SampleClass
Right click symbol item now added in Library list and choose Edit Class option
In that SampleClass I replace all with a paste of your code BUT NOTE: after that line rectangle.graphics.endFill();.. I also added the line addChild(rectangle);
Now when I test (Debug: Ctrl+Shift+Enter).. I see a black square that traces "Some string" everytime I click it..
Your MainClass.as was attached to the FLA as the Document Class (see Properties with Ctrl+F3)
I hope this is useful to you or anyone else trying this kind of code. Any issues just add a comment. Thanks.

how to work with button in class and packages at AS3

I am a beginner of action script. working with button in action script class file not working.
i have created two file one is stream.as and another is main.as
main.as is the main class file of my frame.
i have drawed a button and converted it in button and gave instance name play_btn.
but the compiler giving me 1120: access of undefined property play_btn.
the both codes are given below;
main.as
package {
import flash.display.MovieClip;
import stream.stream;
public class main extends stream {
public function main() {
}
// constructor code
}
}
stream.as
package {
import flash.events.MouseEvent;
import flash.display.MovieClip;
public class stream extends MovieClip {
public function main() {
play_btn.addEventListener(MouseEvent.CLICK, pausevedio);
function pausevedio(event:MouseEvent):void{
play_btn.visible=false;
}
// constructor code
}
}
}
Correct me if I'm wrong but it's because the play_btn belongs solely to your main class and you're trying to access it through the stream class, to do this properly try to instantiate it through code in the class you wish to use it in instead of on the timeline like so:
playBtn: play_btn = new play_btn();
playBtn.x = x;
playBtn.y = y;
addChild(playBtn);
This is my best guess I'm not exactly sure how your classes are structured but this might be your issue. I hope this helps (I'm new too but I figured my two-cents might help!)!
~Cheers!

AS3 Class Error

I am trying to make a game in flash using AS3. I am making a class file that set the parameters for creating a new planet, but when I then add the actions to the first frame of the timeline, it immediately gives me an error. I am new to action script and would love any help. My code should work as far as I know. Here it is:
The actions menu contains this code on the first frame -
var zuun:MovieClip = new Planet();
The class "Planet" looks like this, and is saved in a file name "Planet.as" and is targeted at my main file.
package {
import flash.display.MovieClip;
public class Planet extends MovieClip {
private var planetname:String;
public function Planet() {
// constructor code
}
public function setName(a:String):void {
planetname = a;
}
public function getName():String {
return planetname;
}
}
}
EDIT
The error i'm getting is this -
Error: Error #2136: The SWF file file:///Users/mike/Desktop/jonah/bindings.swf contains invalid data.
at Planet/frame1()[Planet::frame1:1]
Thanks

Facebook.init() doesn't work and I don't see any errors.

I'm creating a flash application and I downloaded GraphAPI_web_1.8.1.swc. And I am using adobe flash professional cs6 and created a project with as3. I have a log in button and when I click it, it should connect me to the Facebook by my application. It doesn't work and I don't see any errors on compiler window. But I traced every steps and I saw the init and login functions doesn't work. I was trying Facebook desktop instead of Facebook web and I worked with air but not with flash professional. And I decided to This is my code.
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import com.facebook.graph.Facebook;
public class Main extends MovieClip {
private var APP_ID:String = "466097573423642";
public var permissions:Array = ["user_birthday","read_stream","publish_stream","email"];
public function Main() {
// constructor code
loginout.addEventListener(MouseEvent.CLICK, _login);
Facebook.init(APP_ID, loginHandler);
}
private function _login(e:MouseEvent):void
{
Facebook.login(loginHandler, permissions);
trace("clicked");
}
protected function loginHandler(success:Object, fail:Object):void
{
trace("Hey");
if(success) {
trace("Login successful!");
}
}
}
}
I'm not sure but try importing this also:
import com.facebook.graph.net.FacebookRequest;
import com.facebook.graph.utils.FacebookDataUtils;
import com.facebook.graph.controls.Distractor;

Flash AS3 Help detecting a loaded file

I'm trying to load an external and local XML file to read its data, but I don't really know how to detect when the file has been loaded, I'm just able to open the broser window,
here is what I have done
package {
import flash.display.Sprite;
import flash.events.;
import flash.net.;
import flash.net.URLRequest;
public class cargadorXML extends Sprite {
public var cuadro:Sprite = new Sprite();
public function cargadorXML() {
cuadro.graphics.beginFill(0xFF0000);
cuadro.graphics.drawRoundRect(0,0,100,100,10);
cuadro.graphics.endFill();
cuadro.addEventListener(MouseEvent.CLICK,init);
addChild(cuadro);
}
public function init(e:Event) {
var file:FileReference;
file = new FileReference();
file.browse();
file.addEventListener(Event.COMPLETE,bien);
}
public function bien(e:Event) {
trace("cargado");
}
}
}
but no "cargado" message appears, also I don't really think the Event.COMPLETE is the correct event at all xD
could some one help me here??
thanks
done, it's Event.SELECT instead of Event.COMPLETE