Flash Actionscript3 - error 1120 - actionscript-3

I wanted to ask for some help on an error I have in Flash Professional while using AS3.I keep getting a couple of errors and I am not sure how to correct them. Here are the errors below (5 in total):
Scene 1, Layer 'Content', Frame 4, Line 25, Column 3 1120: Access of undefined property grid.
Scene 1, Layer 'Content', Frame 4, Line 8, Column 1 1120: Access of undefined property grid.
Scene 1, Layer 'Content', Frame 4, Line 9, Column 1 1120: Access of undefined property grid.
Scene 1, Layer 'Content', Frame 4, Line 10, Column 1 1120: Access of undefined property grid.
Scene 1, Layer 'Content', Frame 4, Line 11, Column 1 1120: Access of undefined property grid.
Here is my code for this page, I basically wanna place parts of the XML document into a datagrid:
stop();
//Flash generated imports
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
//Datagrid added from components menu
grid.addColumn("Title");
grid.addColumn("Genre");
grid.addColumn("Runtime");
grid.addColumn("AgeRating");
var loader:URLLoader = new URLLoader(new URLRequest("movieList.xml"));
loader.addEventListener(Event.COMPLETE, onLoaded);
//Added a loop to handle the multiple movie instances
function onLoaded(e:Event):void
{
var xml:XML = new XML(loader.data);
var itemList:XMLList = xml..movie_info;
var len:int = itemList.length();
for(var i:int=0; i<len; i++)
{
grid.addItem({Title:itemList[i].Title,
Genre:itemList[i].Genre,
Runtime:itemList[i].Runtime,
AgeRating:itemList[i].AgeRating});
}
}
Any help would be greatly appreciated :)

Related

Errors with Gradients in ActionScript

I am currently receiving the following errors:
Scene 1, Layer 'Layer 1', Frame 1, Line 172 1119: Access of possibly undefined property joints through a reference with static type flash.display:GraphicsGradientFill.
Scene 1, Layer 'Layer 1', Frame 1, Line 173 1067: Implicit coercion of a value of type flash.display:GraphicsSolidFill to an unrelated type Array.
When trying to create gradients like this:
import flash.display.JointStyle;
var stroke:GraphicsGradientFill = new GraphicsGradientFill();
stroke.joints = JointStyle.MITER;
stroke.alphas = new GraphicsSolidFill(0x102020, 1);
var fill:GraphicsGradientFill = new GraphicsGradientFill();
fill.colors = [0x0000FF, 0xEEFFEE];
fill.matrix = new Matrix();
fill.matrix.createGradientBox(70, 70, Math.PI / 2);
var path:GraphicsPath = new GraphicsPath(new Vector.<int>(), new Vector.<Number>);
path.commands.push(1, 2, 2);
path.data.push(125, 0, 50, 100, 175, 0);
var drawing:Vector.<IGraphicsData> = new Vector.<IGraphicsData>();
drawing.push(stroke, fill, path);
graphics.drawGraphicsData(drawing);
What is causing these errors?
Try:
import flash.display.JointStyle;
JointStyle.MITER
Edit: Change stroke.joints = JoinStyle.MITER; => stroke.joints = JointStyle.MITER;
Edit for new errors:
GraphicsGradientFill does not have a property joints and the alphas property expects an array. I think maybe you are looking for GraphicsStroke instead of GraphicsGradientFill for the variable stroke?

AS3: How do I call a function with two arguments - (vBox, and vFile)

Adobe Flash CC
Sort of confused here. I'm working on optimizing my code so that instead of calling launchVideo(); for every single video I can can simply call it once, while passing a new source string to the function.
How do I call the launchVideo function from within another function?
When I add an event listener, which calls the playMPMovie
buttonOne.addEventListener(MouseEvent.MOUSE_DOWN, playMPMovie, false, 0, true);
function playMPMovieOne(): void {
video_file = "/videos/MP_01.mp4";
launchVideo();
}
I get this...
Scene 1, Layer 'actions', Frame 1, Line 21, Column 2 1136: Incorrect number of arguments. Expected 2.
When I try adding (vBox, vFile) to launchVideo(); I get this...
Scene 1, Layer 'actions', Frame 1, Line 20, Column 20 1120: Access of undefined property vFile.
Scene 1, Layer 'actions', Frame 1, Line 20, Column 14 1120: Access of undefined property vBox.
Here is the full code.
stop();
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.Graphics;
import fl.video.*;
vinetteMC.visible = false;
// VARIABLES //
var video_holder: MovieClip = new MovieClip();
var video_file: String;
// EVENT LISTENERS //
buttonOne.addEventListener(MouseEvent.MOUSE_DOWN, playMPMovie, false, 0, true);
function playMPMovieOne(): void {
video_file = "/videos/MP_01.mp4";
launchVideo();
}
// Place Playback
function launchVideo(vBox, vFile): void {
var flvPlayer: FLVPlayback = new FLVPlayback();
import fl.video.*;
import flash.events.*;
flvPlayer.source = vFile;
flvPlayer.skinAutoHide = true;
flvPlayer.skinBackgroundColor = 0x000000;
flvPlayer.width = 1920;
flvPlayer.height = 1080;
flvPlayer.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
function completeHandler(event: Event): void {
removeChild(video_holder);
removeChild(flvPlayer);
flvPlayer.addEventListener(fl.video.VideoEvent.COMPLETE, completeHandler, false, 0, true);
trace("Complete handler called");
}
vBox.addChild(flvPlayer);
}
launchVideo(video_holder, video_file);
It looks like you are wanting to call
function playMPMovieOne(): void {
video_file = "/videos/MP_01.mp4";
launchVideo(video_holder, video_file)
}
Also from your example code the video holder is created but never added to the display list. You may need to add this to see anything.
addChild(video_holder);

Change textfield in movieclip with loop actionscript 3

I have six movieclips on the stage and I want to build a for loop that will change the text inside of the movieclips. I have an array with all the names in it that i want to be added to each clip.
var a_letters:Array = new Array('a','b','c','d','e','f');
for(var i = 0; i <= 6; i++ ){
var tempBTN = 'btn'+i+'_mc';
this.getChildByName(tempBTN).letter_txt.html = a_letters[i-1];
}
When I run this I get this error
Scene 1, Layer 'ACTIONS', Frame 1, Line 28
1119: Access of possibly undefined property letter_txt through a reference with static type flash.display:DisplayObject.

as3 TypeError: Error #1009: Cannot access a property or method of a null object reference. -enterframe

i'm making a simple game and i'm still learning as3
i want to hit test object on the stage , bila1 with omidae1 if hittestobject gotoframe
all the objects are on the stage with corect instancename, maintimeline as3 below
everything works fine but i get the null error
TypeError: Error #1009: Cannot access a property or method of a null
object reference. at
testpeframe_fla::MainTimeline/bling()[testpeframe_fla.MainTimeline::frame1:32]
So the problem is Event.ENTER_FRAME, bling
how can i fix that ?
import flash.events.MouseEvent ;
import flash.events.Event;
import fl.transitions.Tween;
import fl.transitions.easing.*;
btnt.visible = false;
butondrr.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler2);
function fl_MouseClickHandler2(event:MouseEvent):void
{
var myTween:Tween = new Tween(bila1, "x", Strong.easeOut, 500, 700, 1, true);
var myTweenm:Tween = new Tween(bila1, "y", Strong.easeOut, 250, 600, 8, true);
}
stage.addEventListener(Event.ENTER_FRAME, bling);
function bling(event:Event):void
{
if(bila1.hitTestObject(omidae1))
{
omidae1.visible = false;
btnt.visible = true;
}
}
removeEventListener(Event.ENTER_FRAME, bling);
stop();
btnt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(5);
}
Insert a new frame at frame 1 (move all the other frames up one, frame 1 -> frame 2, etc)
What might be happening is that you're trying to access things before the swf is completely loaded.
In frame one add:
addEventListener(Event.ADDED_TO_STAGE, ready);
stop();
function ready(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, ready);
gotoAndPlay(2);
}

converting Actionscript 2 code into Actionscript 3

Recently I followed and made the 3d carousel in AS2, but I'm looking to use it and make it in AS3. Is there any possible way of converting the code so the carousel can work in AS3?
Below is the code for the AS2 carousel:
import mx.utils.Delegate;
var numOfItems:Number;
var radiusX:Number = 300;
var radiusY:Number = 75;
var centerX:Number = Stage.width / 2;
var centerY:Number = Stage.height / 2;
var speed:Number = 0.05;
var perspective:Number = 130;
var home:MovieClip = this;
var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
tooltip._alpha = 0;
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function()
{
var nodes = this.firstChild.childNodes;
numOfItems = nodes.length;
for(var i=0;i<numOfItems;i++)
{
var t = home.attachMovie("item","item"+i,i+1);
t.angle = i * ((Math.PI*2)/numOfItems);
t.onEnterFrame = mover;
t.toolText = nodes[i].attributes.tooltip;
t.icon.inner.loadMovie(nodes[i].attributes.image);
t.r.inner.loadMovie(nodes[i].attributes.image);
t.icon.onRollOver = over;
t.icon.onRollOut = out;
t.icon.onRelease = released;
}
}
function over()
{
home.tooltip.tipText.text = this._parent.toolText;
home.tooltip._x = this._parent._x;
home.tooltip._y = this._parent._y - this._parent._height/2;
home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
home.tooltip._alpha = 100;
}
function out()
{
delete home.tooltip.onEnterFrame;
home.tooltip._alpha = 0;
}
function released()
{
trace(this._parent.toolText);
}
function moveTip()
{
home.tooltip._x = this._parent._x;
home.tooltip._y = this._parent._y - this._parent._height/2;
}
xml.load("icons.xml");
function mover()
{
this._x = Math.cos(this.angle) * radiusX + centerX;
this._y = Math.sin(this.angle) * radiusY + centerY;
var s = (this._y - perspective) /(centerY+radiusY-perspective);
this._xscale = this._yscale = s*100;
this.angle += this._parent.speed;
this.swapDepths(Math.round(this._xscale) + 100);
}
this.onMouseMove = function()
{
speed = (this._xmouse-centerX)/2500;
}
When I add this code in AS3 I get the following error:
Scene 1, Layer 'Layer 1', Frame 1, Line 1 1172: Definition mx.utils:Delegate could not be found.
Scene 1, Layer 'Layer 1', Frame 1, Line 1 1172: Definition mx.utils:Delegate could not be found.
Scene 1, Layer 'Layer 1', Frame 1, Line 41 1120: Access of undefined property Delegate.
Scene 1, Layer 'Layer 1', Frame 1, Line 6 1119: Access of possibly undefined property width through a reference with static type Class.
Scene 1, Layer 'Layer 1', Frame 1, Line 7 1119: Access of possibly undefined property height through a reference with static type Class.
I'm quite new to AS2 and AS3 but after some research I understand that import mx.utils.Delegate; is no longer need in AS3 as it already has delegate and they are already built in so in the code so I delete the delegate which are line 1 and line 41 and got two errors:
Scene 1, Layer 'Layer 1', Frame 1, Line 6 1119: Access of possibly undefined property width through a reference with static type Class.
Scene 1, Layer 'Layer 1', Frame 1, Line 7 1119: Access of possibly undefined property height through a reference with static type Class.
Now I cant figure out what to do so can someone help me convert this code from AS2 to AS3?
You have quite a few things to address here:
Your mouse events need to be changed to as3 calls
t.icon.onRollOver = over, in as3 looks more like t.icon.addEventListener(MouseEvent.ROLL_OVER, over);
attachMovie is no longer used in as3.
you need to export for actionscript the movie you want to get from the library with a unique class name, then use new someName(); to create it. Then it must be added to the display list with addChild
onEnterFrame is not used in as3, you need to create an enterframe event more like this: **addEventListener(Event.ENTER_FRAME, someFunction);
delegate is not used in as3.
flags on _x, _y, _parent, _alpha etc have been removed in as3. just use x,y, parent, alpha etc.
swapDepths has been removed from as3, You need to use the display list to add/remove/swap levels.
sounds like you might need to study up a little on as3 before you can properly tackle this one! try checking out this link for comparisons between as2 and as3 functionality.
http://www.actionscriptcheatsheet.com/downloads/as3cs_migration.pdf