• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

please help. i have no idea what i'm doing

Participant ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

I've been trying to make something point in another things direction but it's saying unexpected packages then it's saying public funtion is only allowed in a package then access of undefined property then left paren before left brace and so on. here is the code. currently there it's not saying where or what the error is so just take a look:

 

import flash.display;
import flash.events;

class rHit extends MovieClip

{
rHit.addEventListener(Rat);
function Rat();
{
var angle:Number = Math.atan2 (r.Y, r.X);
var degrees:Number = angle * 180/Math.PI;
rHit.rotation = degrees;
trace();
}
}

Views

105

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jul 11, 2022 Jul 11, 2022

Hi.

 

Are you coding in a frame or a class file?

Votes

Translate

Translate
Community Expert , Jul 11, 2022 Jul 11, 2022

Got it.

 

So don't use class or package keywords/structure because they are reserved for class files.

 

I don't know exactly what you were trying to achieve, so I coded a generic "rotate to target" example.

 

AS3 code:

import flash.events.Event;
import flash.events.MouseEvent;

function enterFrameHandler(e:Event):void
{
	var angle: Number = Math.atan2(target.y - arrow.y, target.x - arrow.x);
	var degrees: Number = angle * 180 / Math.PI;
	
	arrow.rotation = degrees;
}

function mouseDownHandler(e
...

Votes

Translate

Translate
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Hi.

 

Are you coding in a frame or a class file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

frame. also "export to actionscript" is offcodestuff.JPG

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Got it.

 

So don't use class or package keywords/structure because they are reserved for class files.

 

I don't know exactly what you were trying to achieve, so I coded a generic "rotate to target" example.

 

AS3 code:

import flash.events.Event;
import flash.events.MouseEvent;

function enterFrameHandler(e:Event):void
{
	var angle: Number = Math.atan2(target.y - arrow.y, target.x - arrow.x);
	var degrees: Number = angle * 180 / Math.PI;
	
	arrow.rotation = degrees;
}

function mouseDownHandler(e:MouseEvent):void
{
	arrow.startDrag();
}

function mouseUpHandler(e:MouseEvent):void
{
	stopDrag();
}

stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

 

Please notice that the arrow artwork must be facing to the right because that's the 0 degree in Flash/AS3.

 

FLA / source / code / files:

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/as3/rotate_instance_to_target

 

Regards,

JC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Thank you so much, João! this is exactly what i wanted. this helps so much

 

-soft sheep

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 13, 2022 Jul 13, 2022

Copy link to clipboard

Copied

LATEST

You´re welcome!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

code snippets can be your best friend.

Screen Shot 2022-07-06 at 10.03.57 PM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines