Solved

Actionscript 3 sprite.graphics.drawPath function not working

Posted on 2011-03-24
3
839 Views
Last Modified: 2012-08-13
Here's my code and some of the errors i get - the omitted errors are the same as those listed.

protected function DrawArrow(oSprite:Sprite, nColorIndex:Number, nStyle:Number)
{
            var star_commands:Vector.<int> = new Vector.<int>();
            star_commands.push(1, 2, 2, 2, 2);
            
            var star_coord:Vector.<Number> = new Vector.<Number>();
            star_coord.push(66,10, 23,127, 122,50, 10,49, 109,127);
            
            oSprite.graphics.beginFill( m_aScrollerColors[nColorIndex] );
            oSprite.graphics.drawPath( star_commands, star_coord );
            ...

CMenuScroller.as, Line 114      1120: Access of undefined property int.
CMenuScroller.as, Line 114      1120: Access of undefined property Number.
CMenuScroller.as, Line 114      1061: Call to a possibly undefined method drawPath through a reference with static type flash.display:Graphics.

Any ideas why this won't work?
With Thanks
0
Comment
Question by:jasonb2
3 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35220390
I guess you are wrong here:
 var star_commands:Vector.<int> = new Vector.<int>();
star_commands.push(1, 2, 2, 2, 2);
           
var star_coord:Vector.<Number> = new Vector.<Number>();
star_coord.push(66,10, 23,127, 122,50, 10,49, 109,127);

You will have to push the values individually.
 
var star_commands:Vector.<int> = new Vector.<int>();
star_commands.push(1);
star_commands.push(2);
star_commands.push(2);
star_commands.push(2);
star_commands.push(2);
            
var star_coord:Vector.<Number> = new Vector.<Number>();
star_coord.push(66);
star_coord.push(10);
star_coord.push(23);
star_coord.push(127);
star_coord.push(122);
star_coord.push(50);
star_coord.push(10);
star_coord.push(49);
star_coord.push(109);
star_coord.push(127);

Open in new window


Warm Regards
Deepanjan Das
0
 
LVL 4

Accepted Solution

by:
ute_arbeit earned 125 total points
ID: 35224653
The code creating and filing the vectors seems ok. You don't have to push the values one by one, Vector.push takes multiple arguments.
Also the rest of your code with the call to drawPath seems ok to me.

The only thing I can imagine is that you did not set ActionScript 3.0 as the scripting language for your file. If it is set to ActionScript 2.0 all the Vector stuff is not supported and you get compiler errors.
Please make sure you have ActionScript 3.0 set in your settings for publishing.
0
 

Author Comment

by:jasonb2
ID: 35228221
thanks guys.
I got it to work.
I changed the 'player' setting in 'publish settings' from 'player 9' to 'player 10".
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now