Action script object
I would like to creare an object for third party developers
to report high score.
I dont want them to see my code.
So for example I will create a class highScore with API
sendScore and the developer will use it.
What is the best way to do it?
Is the only way to do it is to crearre action script file
that they can see my code?
Well, a good place to start:
http://www.adobe.com/devnet/flash/components/components.html
Similar Messages
-
Mapping action script object to mx:model object
Hi all,
I am having an action script class and an mx:model element
with same elements. I want to assign an action script object to
this mx:model. How can I do that one?
Let me state it clearly.
Say, my action script class contains two elements - user and
rollno with required getter and setter methods.
And I am having an mx:model element with the following
format.
<mx:model id="data">
<data>
<user/>
<rollno/>
</data>
</mx:model>
I want to assign an instance of action script class to this
model object.
I tried extending action action script class from Objectproxy
and used data=actionscriptinstance.
But it's not working properly.
Is there anyway I can do this one?
Thanks in advanceThe quick answer:
<mx:model id="data">
<data>
<user>{ myASObj.user }</user>
<rollno>{ myASObj.rollNo}</rollno>
</data>
</mx:model>
The bigger question might be, "Why have the mx:Model?"
The Model tag is all Strings, so you lose data typing.
Why not just create a value object (VO) for your user data
and pass that around?
package samples.user {
[Bindable]
[RemoteClass(alias="samples.user.User")]
public class User {
public var user:String;
public var rollNo:int;
Then when the result data returns, cast to the VO.
public var user:User = (eventObj.result as User) -
Action script objects not displayed
Hi,
I am creating an air application using Flex 4.5 compiler. The problem i am facing currently is that i have extended shape class to my custom class movingObject. in this class i have defined a function "drawcircleObj" in this class and calling this class function to display my customized circle on the stage.
But it is not behaving as desired. i.e. no object is being displayedAdding my code snippets
The as file code
package secondPackage
import flash.display.*;
public class movingObject extends Shape
private var xPos:Number;
private var yPos:Number;
private var radius:Number;
private var color:uint;
public function movingObject()
{// currently a stub will use it later
public function drawcircleObj(xInput:Number,
yInput:Number,
radInput:Number,
colorInput:uint): void
xPos = xInput;
yPos = yInput;
radius = radInput;
color = colorInput ;
this.graphics.beginFill(color);
this.graphics.drawCircle(xPos,yPos,radius);
The mxml file code
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="initApp()">
<fx:Script>
<![CDATA[
import secondPackage.movingObject;
import flash.display.*;
private var myMoving:movingObject = new movingObject();
public function initApp():void
//show the string
myMoving.drawcircleObj(500,500,30,0xFF0000);
mainText.text = myMoving.letsStart();
]]>
</fx:Script>
<s:TextArea id="mainText" x="390" width="50" y="133"/>
<s:Button id="button1" x="804" y="227" label="Button" width="45"/>
</s:WindowedApplication>
The problem which i suspect is that there should be a stage object holding the same object or circle created and then display it.
A faster reply will be highly appreciated. Thank you. -
Here's my idea but having problems with the actions scripting:
Accessories and build your car application in Flash.
I'm new to the Action Script 3 and I am trying to Action Script my custom graphics for a “build your own car”. Something similar to the Harley Davidson motorcycle builder https://www.harley-davidson.com/en_US/Content/Pages/H-D1/Bike-Builder.html#/locale__en_US/ model__FLD/year__2013
I have all the graphics (multiple photos, photoshopped and cut out for the different car body colors. I'm doing the same with the car rim choices, etc) All the graphics are sized so they will lay on top of one another seamlessly but I don't know how to Action Script 3 the buttons so you can click on (ex: rim1, or rim2 , etc and see how it looks on car by pulling up the photo on top of the existing background car photo) .
How would I Action Scrip my "color button" to come up with 10 color swatches I’ve designed and then when you click on the color swatch (ex: red). It will then put the graphic red of the car body that I have already made on top of the existing background photo of the car and so on for each color button?
Thanks for the help in advance!I'm not sure if I do know how to correctly create the Wheels classes and use action scripting. Are the classes you're referring to the parts I labeled btn1, btn2 below? Here's what I have under the main Timeline labeled actions:
stop() ;
// Color button code //
colorbtn.addEventListener(MouseEvent.CLICK, btn1);
function btn1 (event:MouseEvent) :void{
gotoAndStop (2);
// Rims button code //
rimsbtn.addEventListener(MouseEvent.CLICK, btn2);
function btn2 (event:MouseEvent) :void{
gotoAndStop (3);
//rim1 button code //
rim1.addEventListener(MouseEvent.CLICK, btn3);
function btn3 (event:MouseEvent) :void{
gotoAndStop (4);
I'm not sure how to fit your code in that you said in your first comment. The //rim1 button code // doesn't currently work.
I think if I had a sequence of the action script 3 with a button/movie clip layed out for me, I could organize accordingly for my buttons and movie clips. Since they would work the same just would have to have different labels. -
Error while loading an child movieclip if the child has any action script
Hi
I am developing an application where I need to load a child.swf . All works fine when I load the mc but as soon as I add Action Script (lets say trace("test")) to the Child.swf I get a Error #1009: Cannot access a property or method of a null object reference. On the addChild line.
Code
trace("Toothpaste click");
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("Child);
mLoader.load(mRequest);
mcContainer.addChild(mLoader);Sorry.Thanks
Typo on the forum.
I can load the child.swf see the image/text in the child displayed in the parent but as soon as I add as3 to the child page I receive the above mentioned error. If I run the child.swf from the IDE or by itself everything works fine .
trace("Toothpaste click");
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("Child.swf");
mLoader.load(mRequest);
mcContainer.addChild(mLoader); -
New to action script 3 and am really confused
Hello and thank you in advance for helping if you can. I have a website banner that I made in flash. Everything works great and the last thing I need to do is add some script to it. One code is simple the stop action. So I added a new layer, called it actions and then clicked on the last frame inserted a blank keyframe and then opened the action window and typed in stop(); It worked great the banner cycled through once then stopped.
Now here comes the part that has me stumped. I need to make this banner link to an external website. so this is what I did. On the actions layer I clicked the first frame and opened the actions window, Oh first I have a block of text converted to symbol (movie clip) and named the instance click_mc, then in the actions script window this is what I typed
var link:URLRequest = new URLRequest("http://www.mojaveampworks.com/dirtyboy/DirtyBoy/Dirty_Boy.html");
click_mc.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
navigateToURL(link);
click_mc.buttonMode = true;
Now when I run the movie it doesn't run at all. Any help with this would be greatly appreciated as I'm ready to through this whole project out the window. Sorry if this question is redundant but I am new with action script.
thanksHi Ned and thank you for responding.
I am not getting a compiler error but in the output I am getting this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at dirtyboybnr2_fla::MainTimeline/frame1() -
Action script 3 and adding code to buttons
When I open a new doc and selct action script 3 it won't
allow me to insert code by selcting the button on the stage. It
does if I select action script 2. All my old pages update ok but if
I make new buttons it wont take the code. CAn someone tell me what
is going on???
Thanks a lotIf your in a bind at the moment, I would suggest not
attempting to learn AS3. The system is very different, good, but
different, the syntax structure is much more strict and most things
have been revised to use a listener/broadcaster (or event
dispatcher) model, as well as most coding being class oriented,
additionally the graphic display structure is quite different.
Now did you change your publish settings back to AS2? If so,
you should still be able to apply the above code to a button
instance. However, as Dave stated, even in AS2 the code is best
used from the timeline, to do so with the code above (which the on
handler above is meant for Object attachment) you need to write it
like this:
my_btn.onPress = function() {
_root.loadMovie("graphic_arts/graphic_arts.swf");
I would also consider using a MovieClipLoader and the
loadClip method forloading swf files, as it gives you more control
over the load targeting, progress reporting, and event
notifications.
All this said, to use a button and load a file in AS3, you
need to add an event listener to the button instance and construct
a responding function to the event, in this case the loading of a
swf file. Additionally, in AS3 the MovieClipLoader class, as well
as the loadMovie methods have been replaced by the Loader classes
and must be used to load swf files. So construct a button in AS3
you must write something like the following: -
Difference in using the same component made in mxml or action-script
Hi,
I made a sample project to show a kind of bug in the SuperTabNavigator component of FlexLib
In this sample you can see that using the same component (made in both mxml or action-script) can make a difference
I'm just wondering why ?
Thanks
Here is what i've posted :
What steps will reproduce the problem?
1. Create a button to dynamically add new tab with icon on a SuperTabNavigator
2. Click on this button to add new tabs
What is the expected output?
- The expected output is tabs added without abnormal behavior
What do you see instead?
- Every time a new tab is created the one who had the focus has its content
(icon + label) moving from the top-left of the tab to its original position
Please provide any additional information below.
Configuration:
- Flex Builder 3 in Eclipse
- FlexLib 2.3
Sample:
(see attached file)
There is two type of tab, one in action-script and one in mxml
They both are equal
- Adding a new action-script tab to SuperTabNavigator works fine
- Adding the same tab but an mxml one doesn't
- Adding a new action-script or mxml tab to TabNavigator works fine
-> meanings that the issue comes with SuperTabNavigator
- Adding a new mxml tab to both SuperTabNavigator and TabNavigator at the
same time makes TabNavigator to get the same bad behavior
Remarks:
- Tried everything but i'm really stuck
- Weirdly, removing the PopUpButton correct the issue
- In the same way if you keep adding action-script tab it automatically scroll to the
last tab. And if you do the same with mxml tab then it add the tab at the end and
scroll to the first one.
=> what could be the difference between using action-script or mxml object ?Here is one possible solution:
You can use the ExternalInterface (
http://livedocs.macromedia.com/flex/2/langref/flash/external/ExternalInterface.html)
class to communicate with JavaScript. JavaScript can then popup the
media player very easily like this:
http://www.webreference.com/programming/javascript/jf/column5/index.html
The documentation on the ExternalInterface class has a nice
example (in the bottom of the page) on how to communicate with
JavaScript in a browser. Hope this helps,
-george -
CS3 action script 2.0: compiled clip components do not appear in the component panel
Hi,
I have a FLA file containing 3 compiled clip components.
I use a MXP file to copy this file to the components panel,
this works fine when using Macromedia Flash 8 or Macromedia MX
2004, but when using CS# the components do not appear in the
components panel, only if a use regular component or SWC component
it appears in the panel, any reason why?any ideas?
Thanks
MayaI can use this code from html. I'm able to say where the swf
and xml file are. I just don't know how to do this using action
script.
<object
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="
http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
width="768" height="576" id="tech" align="middle">
<param name="movie"
value="slideshow.swf?xml_path=musicbox_slideshow/slideshow.xml"
/>
<param name="quality" value="high" />
<embed
src="slideshow.swf?xml_path=musicbox_slideshow/slideshow.xml"
quality="high" width="768" height="576" name="tech" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="
http://www.macromedia.com/go/getflashplayer"
/>
</object>. -
DRM Import, Action Script
Hi All,
I am new to Hyperion DRM 11.1.2, I am confused about concepts such as metadata and data still not able to understand difference between them. What I understand is all Versions hold is set of independent hierarchies which have nodes and their property values, which is nothing but metadata.
Please help me understand difference between data and metadata?
There are different task groups like Import, Action script and Migration Utility all the these are essentially used for importing metadata and data in the DRM Application.
Migration Utility - Provides the ability to bulk load metadata and security objects in DRM applications. Other operations which can be performed in migration utility are extract and difference.
Import- It provides a way to import data in DRM Applications, but it creates new version after import
Action Script - Used to process a bulk set of changes in an automated fashion.
Can anyone help me understand best case scenario for when to use which utility to import metadata and data?
Thanks in advance.
Regards,
AniketMigration Utility: When you are trying to Export/Import Properties, Validations, Export Definitions, Import Definitions etc to an XML or from another server.
Import: This function Imports a whole new Version once you have the load file in a specific Import format that you define.
Blendor: The Version you imported Can be blended with the Actual current existing version
Action Script: This is used when updating the current Hierarchies. Like Adding nodes, updating Properties etc. -
In Acrobat Pro you can create a document script as follows:
function Hello()
app.alert("Hello World")
And call this Hello.
If you create button on the page then create an action on Mouse Up Run a JavaScript which looks like this:
Hello();
A message box appears saying Hello World click OK and press the button and it keeps coming back.
Now in Designer this is a little different.
I create a new page, insert a script object rename it to Hello and type:
function Hello()
app.alert("Hello World")
I then create a button and on the mouse up action type;
Hello();
If I try this I get the following mesaage:
TypeError: Hello is not a function
1:XFA:form1[0]:#subform[0]:Button1[0]:mouseUp
Why is it so?
Even removing the script object and going to the Form properties Variables tab and entering the function script there does not seem to work.Thanks Steve,
It works without a hitch. Im still getting my head around JavaScript and 2 weeks, 6 hours a day of reading and testing and reading is slowly getting clearer I think.
Just to make sure Im getting this clear in my head. The way I had the script before was when it was applied to the field that showed the value it was referring to this as the field itself. So it worked not worries because it was point to the itself.
When I tried to apply the same script in a script object field (variables) that the whole documents can reference it was only in as a variable. The line form1.variables.setTotals.Totals(); did not do anything because it did not see the totals as a function and refer to it, and as a result nothing would appear in the filed. By adding obj to the script it tells the form that its an object and the objects formula is spei1 + spei2. This now means that the script can be applied to any filed and that is where form1.variables.setTotals.Totals(this); comes in. It tells the filed apply the object (Totals [spei1 + spei2] ) to this filed.
Does this mean that any script placed in the Variables field needs to be referred to as objects?
The reason I was taking this approach was to resolve a problem posted earlier.
I thought by having the script as a script object that was applied to the document rather than the field it would update the other fields that refer to it. Which I now realize will not happen. Could you suggest a conditional statement that I could put in to:
If special item 1 = $12.00 the result in the total = $12.00. If I then click on one of the fields in the special column say in Monday for example the result should be $12.00. If I then decide to enter another $12.00 in special item 2 the total will now be $24.00 but the Monday result will still say $12.00.
Is there a way to have it check that it the figure which may appear in the Special column, to update that result as well?
Should I be look at a message box instead telling the user there is a difference and for them to re-click on the Monday field to update it?
Any suggestions would be appreciated.
Regards, John. -
Hi to all,
I am new to action scripting.. i would like to know how to
start programming in flash.. what are all basic things need to
know..What is the Object Oriented Programming... is there any good
tutorials to understand.. i am having basic knowledge please any
one help me on this..
Thank you all
Satish Kumar Rajula
Textyou can start by reading the flash help files which include
many examples of oop. -
Hello,
I try to center my gif image on streching banner.
What i make:
1. Click F8 on image layer and transform into symbol ("img1"). Registration is centered.
2. Add a name for this copy in properties ("img2")
3. On the layer "Action Script" i got a code:
Stage.scaleMode = "noScale";
Stage.align = "LT";
var obResize:Object = new Object();
Stage.addListener(obResize);
obResize.onResize = function() {Resize()};
function Resize(){
back._width=Stage.width;
img2._x=Stage.width/2;
Resize();
Gif image is not centered. When i use static image, for ex. JPG, that's ok.
Please, help me if you know how to solve this problem.
Thank you!how is your banner stretching? is that javascript?
-
Error in action script and button
I have a page that i have designed for practice. i have three
buttons on each page and have been tring to get them to link to the
proper page/frame. For instance the button for ABOUT US should link
to the second page/frame. The code i am using is as follows.
on (release) {gotoAndStop(2);
This should have it go to page/frame 2 and stop but when i
test it it gives me this error.
Scene 1, Layer 'about', Frame 1, ... 1087: Syntax error:
extra characters fou... on (release) {gotoAndStop(2);
I am using action script 1.0 & 2.0. I am not sure what to
do.The way that this function is written, on (release), it
should be
directly attached to a button or movieClip instance. However,
the
gotoAndStop(2) command is telling the button or clip to go to
frame 2,
not the main timeline. If you change that line to
_parent.gotoAndStop(2), you'll get the playback head on the
main
timeline to move, not the playback head in that button or
clip.
A far better method is to assign instance names to each
button or
movieClip that you want to react to actionscript. Then you
can write the
function(s) for those instance names. You would write the
actionscript
to a frame instead of directly on the button or clip. This
makes the
actionscript much easier to find when you need to edit.
So, for instance, you could then write a set of functions to
move the
playback head. Something like this:
// we'll assume that the buttons are named button1, button2,
button3
button1.onRelease = function() {
gotoAndStop(X);
button2.onRelease = function() {
gotoAndStop(Y);
button3.onRelease = function() {
gotoAndStop(Z);
// where X,Y and Z are the frame numbers that you want to
move to
// you don't need an explicit reference for the timeline for
the
playback head to use here. The code and the objects are all
on the same
timeline. -
Where do I find anm experienced Action Scripted fast?
Hi,
I have a Flash presentation which needs completed. Basically,
all of the buttons need programmed and as a newbie who is running
out of time to learn, I need some help.
First, I'd like to know where you find people who can do this
(here?)
Secondly, how long it would take to programme approx 875
buttons (many of which are repetitions (e.g home button, help
button, exit button appearing on every screen). There are
approximately 109 screens which need to be linked.
Thirdly, what would be a realistic price to expect to pay for
someone to do this? It is a non-profitmaking project for a
voluntary organisation.
Thanksnicknamesaretaken,
> I think I see what the problem is, but still struggling
to
> get it to work.
Okay.
> I now have:
>
> stop(); {
> on (release)
> this.gotoAndPlay("CS1"); // this is the correct code.
> }
Okay, the on() event handler may not belong here. The on()
and
onClipEvent() functions are an older (Flash 5 era) way to
handle events in
ActionScript. They're still available in Flash 8, and they
work just fine,
even in AS2, but these are applied *directly to* the object
in question; as
in, you click your button to select it, then type into the
Actions panel
while the button is selected. In such a case, no instance
name is needed
for the button (or whatever object). The above code would
have to be
attached to each button -- which really gets old with a large
number of
buttons -- and the stop(); action would have ben appear
inside the on()
function.
Your earlier approach -- where you referenced the button's
instance name
and assign a function to the Button.onRelease event -- is the
recommended
best practice, and has been available since Flash MX (aka
Flash 6). There's
nothing about your earlier code that shouldn't have worked --
it's just you
*might* have been experiencing the Scenes-related bug I
mentioned.
I would change your previous code as follows:
// in a frame script ...
stop();
skipintro_btn.onRelease = function() {
this._parent.gotoAndStop("frame label here");
That stops the timeline in which this ActionScript appears.
Then it
assigns a function literal to the Button.onRelease event of
the button
symbol whose instance name is skipintro_btn (if that object
is actually a
movie clip, then it assigns a function literal to the
MovieClip.onRelease
event of that instance -- funtionally the same thing). Then
it refers to
the parent of this object, which is the timeline in which the
object
appears, and tells that timeline to gotoAndStop() at the
named frame label
you provide -- even if that frame label is in another scene.
Make sense?
> Are there any good Action Script books you could
> recommend?
There are quite a few good ones on the market lately, but
the last I can
think of that I enjoyed -- from a general programming
standpoint -- is
Object-Oriented ActionScript For Flash 8 (Friends of ED), by
Peter Elst and
Todd Yard.
> I'm also a bit worried about bug comment. Does it mean
> that I will have difficulty playing this project in
Flash Player
> 9 as it's not written in Action Script 3.0?
You shouldn't have any problems. As long as you use the
frame labels
approach and avoid Scene names, Flash Player 9 will run it
the same as older
Players. Flash Player 9 is the first to feature *two* virtual
machines for
ActionScript. One is the overhauled AS3-lovin' machine; the
other maintains
backward compatability for AS1 and AS2.
> If so, that's a big problem isn't it as people will need
to
> download older versions of Flash Player to view it - or
> I'll need to include older version on the disc.
Right, but you don't have to worry about that. :) The Scenes
issue is
an old one, and it is a big problem, but at least the
workaround is easy
(frame labels).
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design."
Maybe you are looking for
-
After setting preferences and clicking "OK" The items you have selected change. If you open the preference window again they all reset to the default and any changes you had made are no longer present. Thus you have to reset all of the preferences ea
-
Connecting ps3 to U350 via hdmi
I've had my laptop for a good 6 months and still haven't removed any of the stickers it came with. One of the stickers reads: HDMI Supports High Definition video and audio output and input. I've had no problems with the output to my hdtv using hdmi,
-
There is a red light...
There is a red light coming from my headphone port and sound will only come when they are plugged in and not through the speakers in the Mac. Any suggestions? Thanks.
-
LastModified() to millisec
Hi form Is there a API to convert date/time format for File.lastModified() to milli sec starting from 01-01-1970 or How can this be achieved ??? --- ( : + ] Thx in advance
-
Can I chose to pay 'over the limit' charges
Hi there. Nine times out of ten my 10gb broadband usage is fine however i occasionally watch films and tv shows on my laptop which can take my usage close to the 10gb then i find i spend about a week not really being able to do much online. To upgrad