• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

Flash 8

I am new to flash and need to create a swf file that has an arrow that moves across the canvus and then climbs to the top right. I have never done anything like this before and was wondering if someone could provide some guidance.

Thank you
0
jimseiwert
Asked:
jimseiwert
  • 3
  • 3
1 Solution
 
emphaticDigitalCommented:
Here you go:

go to Insert>New Symbol ... to create a new symbol making sure to first give it the name 'arrow' and then check the box labeled, 'Export for Actionscript'. (If you don't see the checkbox with that label, click the advanced button and then you will see it) Use the drawing tools to make a right facing arrow and then click, 'Scene 1' at the top of the interface to return to the main timeline. Click in the first frame on the timeline and then open the Actions panel (Window>Actions) and type this code exactly:

var hLevel = Stage.height/2;//change to any positive value
var turnAt = Stage.width/2;//change to any value greater than 10
var speed = 5;//change to any positive value
var end = 0;//change to any value less than hLevel
var
rotate = 1;//don't change

var clip = attachMovie('arrow', 'myarrow', getNextHighestDepth());
clip._x = 10;
clip._y = hLevel;
onEnterFrame = function(){
    if(clip._x < turnAt){
        clip._x+=speed;
    }else if(clip._y > end){
        clip._y-=speed;
        if(rotate){
            clip._rotation -= 90;
            rotate = 0;
        }
    }
};

Go to Control>Test Movie to view.
0
 
jimseiwertAuthor Commented:
Instead of just having the image move is there a way it can look like it is being drawn?
0
 
emphaticDigitalCommented:
That would involve using this code for just the arrow head and then adding code that uses the Flash Drawing API to draw the path of the arrow head as it moves. A little more involved, of course, but possible. Although it's outside of the original scope of your question, here is the updated code:

(Be sure to update your 'arrow' symbol by removing the tail!)

var hLevel = Stage.height/2;//change to any positive value
var turnAt = Stage.width/2;//change to any value greater than 10
var speed = 5;//change to any positive value
var end = 0;//change to any value less than hLevel
var rotate = 1;//don't change

var clip = attachMovie('arrow', 'myarrow', getNextHighestDepth());
clip._x = 10;
clip._y = hLevel;

//begin drawing code
lineStyle(5, 0xFF0000, 100);
moveTo(clip._x,clip._y);

onEnterFrame = function(){
    if(clip._x < turnAt){
        clip._x+=speed;
        lineTo(clip._x,clip._y);//drawing code
    }else if(clip._y > end){
        clip._y-=speed;
        lineTo(clip._x,clip._y);//drawing code
        if(rotate){
            clip._rotation -= 90;
            rotate = 0;
        }
    }
};
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
jimseiwertAuthor Commented:
Sorry for the change in question but your solution is perfect. Thank you very much.
0
 
jimseiwertAuthor Commented:
Question is there a way to make it go on an angle ?
0
 
emphaticDigitalCommented:
Glad I could help. There are a couple of ways you can get angles with this effect, but using this code would be inefficient. The best would be to use trigonometry. Also the easiest. I wish I had time to give you some info to get you started but I'm working so ... I will look out for questions from you and try to slip in the information where apporpriate. I should be checking the site later tonight and through the weekend. Have a great day!

K.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now