Dit is de video Tutorial die we moesten maken voor het vak WebAnimatie Plus. Mijn onderwerp was het Stylen van TextFields.
Ik weet alleen niet waarom de video niet wilt inladen en afspelen... De docent zal op toledo moeten kijken.
De player in volledige grote is hier te vinden:
http://jorendesmet.ikdoeict.be/player.swf
Joren De Smet
vrijdag 29 mei 2009
vrijdag 22 mei 2009
getChildByName ()
Stel we hebben 5 feed knoppen (instanties) van de klasse Feed.
feed1:Feed = new Feed();
feed2:Feed = new Feed();
...
Wanneer we nu elke knop willen aanspreken voor een bepaalde eigenschap te veranderen, zouden we geneigd zijn een for lus te gebruiken zoals deze:
for(var i:Number = 1; i < 6; i++) {
feed+i.eigenschap = waarde;
}
Het probleem hier echter is dat flash deze manier van werken niet herkend. De foutmelding die we krijgen is "1050: Cannot assign to a non-reference value".
Wat we moeten doen is eerst elke feed een naam geven, en dan via getChildByName () werken.
feed1.name = "feed1";
feed2.name = "feed2";
...
for (var i:Number = 1; i < 6; i++) {
getChildByName("feed"+i).eigenschap = waarde;
}
Zo werkt alles perfect, meer info vind je hier: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html#getChildByName()
Joren De Smet
feed1:Feed = new Feed();
feed2:Feed = new Feed();
...
Wanneer we nu elke knop willen aanspreken voor een bepaalde eigenschap te veranderen, zouden we geneigd zijn een for lus te gebruiken zoals deze:
for(var i:Number = 1; i < 6; i++) {
feed+i.eigenschap = waarde;
}
Het probleem hier echter is dat flash deze manier van werken niet herkend. De foutmelding die we krijgen is "1050: Cannot assign to a non-reference value".
Wat we moeten doen is eerst elke feed een naam geven, en dan via getChildByName () werken.
feed1.name = "feed1";
feed2.name = "feed2";
...
for (var i:Number = 1; i < 6; i++) {
getChildByName("feed"+i).eigenschap = waarde;
}
Zo werkt alles perfect, meer info vind je hier: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html#getChildByName()
Joren De Smet
woensdag 20 mei 2009
TextFormat()
Voor ons project hadden we verschillende soorten van tekst nodig in verband met opmaak, afhankelijk van een mouseOver en mouseOut event.
Er was tekst die vet moest zijn, onderlijnd, vet en onderlijnd, of gewoon standaard tekst.
Wat ik echter ondervond is dat wanneer je een TextFormat() object toewijst aan een tekstvak, en je later een ander TextFormat eraan toekent, dat hij beide formaten combineert.
Stel, in het ene formaat zet je de tekst vet, en in het andere onderlijnd, wanneer je dan het na het 1ste formaat het 2de formaat toekent aan een tekstveld, zal dit tekstveld beide formaten bevatten. Zowel vet als onderlijnd dus, maar dit is soms niet de bedoeling.
Concreet betekend dit dat je in een Textformat() object ook eerder gespecifieerde eigenschappen terug op false moet zetten om te voorkomen dat hij ze beide opneemt.
Een voorbeeld:
var boldFormat:TextFormat = new TextFormat();
var boldFormat.bold = true;
var boldFormat.underline = false; //underline op false zetten zodat deze enkel bold is indien je dit formaat toekent aan een tekst met het lineFormat()
var lineFormat:TextFormat = new TextFormat();
var lineFormat.underline = true;
var lineFormat.bold = false; //bold zeker op false zetten, moet enkel onderlijnd zijn
var bothFormat:TextFormat = new TextFormat();
var bothFormat.underline = true;
var bothFormat.bold = true;
var noneFormat:TextFormat = new TextFormat();
var noneFormat.underline = false;
var noneFormat.bold = false;
Joren De Smet
Er was tekst die vet moest zijn, onderlijnd, vet en onderlijnd, of gewoon standaard tekst.
Wat ik echter ondervond is dat wanneer je een TextFormat() object toewijst aan een tekstvak, en je later een ander TextFormat eraan toekent, dat hij beide formaten combineert.
Stel, in het ene formaat zet je de tekst vet, en in het andere onderlijnd, wanneer je dan het na het 1ste formaat het 2de formaat toekent aan een tekstveld, zal dit tekstveld beide formaten bevatten. Zowel vet als onderlijnd dus, maar dit is soms niet de bedoeling.
Concreet betekend dit dat je in een Textformat() object ook eerder gespecifieerde eigenschappen terug op false moet zetten om te voorkomen dat hij ze beide opneemt.
Een voorbeeld:
var boldFormat:TextFormat = new TextFormat();
var boldFormat.bold = true;
var boldFormat.underline = false; //underline op false zetten zodat deze enkel bold is indien je dit formaat toekent aan een tekst met het lineFormat()
var lineFormat:TextFormat = new TextFormat();
var lineFormat.underline = true;
var lineFormat.bold = false; //bold zeker op false zetten, moet enkel onderlijnd zijn
var bothFormat:TextFormat = new TextFormat();
var bothFormat.underline = true;
var bothFormat.bold = true;
var noneFormat:TextFormat = new TextFormat();
var noneFormat.underline = false;
var noneFormat.bold = false;
Joren De Smet
maandag 23 maart 2009
rollOver and rollOut vs. mouseOver and mouseOut
Wat is het verschil tussen rollOver en mouseOver, en rollOut en mouseOut?
The InteractiveObject class (flash.display.InteractiveObject) in ActionScript 3 has both rollOver and rollOut events as well as mouseOver and mouseOut events.
Both sets of events determine when a mouse enters or leaves the graphics area of an interactive object. The rollOver and mouseOver events fire when the mouse comes in contact with an interactive object, while rollOut and mouseOut occur when the mouse leaves the interactive object.
Where they differ is with their interaction with interactive object children. The roll events (rollOver and rollOut) simplify the process and prevent interference with child events. Essentially, this is the same as using mouseOver and mouseOut with mouseEnabled set to false. mouseOver and mouseOut with mouseEnabled provide a parent sprite with events from its children. rollOver and rollOut keeps the events on the parent object.
Bron + een voorbeeld: http://www.kirupa.com/forum/showthread.php?p=1948052#post1948052
Joren De Smet
The InteractiveObject class (flash.display.InteractiveObject) in ActionScript 3 has both rollOver and rollOut events as well as mouseOver and mouseOut events.
Both sets of events determine when a mouse enters or leaves the graphics area of an interactive object. The rollOver and mouseOver events fire when the mouse comes in contact with an interactive object, while rollOut and mouseOut occur when the mouse leaves the interactive object.
Where they differ is with their interaction with interactive object children. The roll events (rollOver and rollOut) simplify the process and prevent interference with child events. Essentially, this is the same as using mouseOver and mouseOut with mouseEnabled set to false. mouseOver and mouseOut with mouseEnabled provide a parent sprite with events from its children. rollOver and rollOut keeps the events on the parent object.
Bron + een voorbeeld: http://www.kirupa.com/forum/showthread.php?p=1948052#post1948052
Joren De Smet
Document Class
Een mooie uitleg over de Document class die we gebruiken in Flash:
ActionScript 3 with Flash 9 lets you specify a "Document Class" (aka Application class) for the main timeline. This represents the class of the root object - the display object in which (essentially) all other display objects are placed.
You can set the Document class in the Document Class option of the Property Inspector for a document with nothing selected. You can also set the Document Class in the ActionScript 3 Settings dialog using File > Publish Settings > Flash [Tab] > Settings... [Button (for ActionScript 3)]. When defining the Document class, you simply provide the name of the class which is to pose as the class for your document. Note: This class should exist within your class path.
The Document Class for Flash needs to extend Sprite or any subclass of Sprite (flash.display.Sprite) to be valid. If you use the main timeline for ActionScript at all in Flash, you would want your document class to extend MovieClip (flash.display.MovieClip) since MovieClips, unlike Sprites, support frames.
A document class should also be public (along with its constructor which is inherently public). A non-public class will result in an error when you publish your movie.
When published from Flash, SWF meta tags within Document Classes are ignored and the settings within Flash are used.
Unlike other display object classes you make, the stage property of a Document class will always be accessible since the document class is inherently a child of the stage. Similarly, if you place any objects on the main timeline in Flash, the will already be children of the Document class when its instantiated.
Example of a Document class:
package {
import flash.events.Event;
import flash.display.MovieClip;
public class CustomDocument extends MovieClip {
public function CustomDocument() {
addEventListener(Event.ADDED, checkChildren);
checkChildren(new Event("initialize"));
}
private function checkChildren(evt:Event):void {
// only allow one child in root
if (numChildren > 1) {
throw (new Error("This movie can have only one child instance"));
}
}
}
}
This class only allows one child. If more are added, an error is thrown. Notice that the checkChildren method is also automatically called in the constructor since its possible that objects could have been added to the timeline within Flash which would have been before the added event listener was created.
Bron: http://www.kirupa.com/forum/showthread.php?p=1950401#post1950401
Joren De Smet
ActionScript 3 with Flash 9 lets you specify a "Document Class" (aka Application class) for the main timeline. This represents the class of the root object - the display object in which (essentially) all other display objects are placed.
You can set the Document class in the Document Class option of the Property Inspector for a document with nothing selected. You can also set the Document Class in the ActionScript 3 Settings dialog using File > Publish Settings > Flash [Tab] > Settings... [Button (for ActionScript 3)]. When defining the Document class, you simply provide the name of the class which is to pose as the class for your document. Note: This class should exist within your class path.
The Document Class for Flash needs to extend Sprite or any subclass of Sprite (flash.display.Sprite) to be valid. If you use the main timeline for ActionScript at all in Flash, you would want your document class to extend MovieClip (flash.display.MovieClip) since MovieClips, unlike Sprites, support frames.
A document class should also be public (along with its constructor which is inherently public). A non-public class will result in an error when you publish your movie.
When published from Flash, SWF meta tags within Document Classes are ignored and the settings within Flash are used.
Unlike other display object classes you make, the stage property of a Document class will always be accessible since the document class is inherently a child of the stage. Similarly, if you place any objects on the main timeline in Flash, the will already be children of the Document class when its instantiated.
Example of a Document class:
package {
import flash.events.Event;
import flash.display.MovieClip;
public class CustomDocument extends MovieClip {
public function CustomDocument() {
addEventListener(Event.ADDED, checkChildren);
checkChildren(new Event("initialize"));
}
private function checkChildren(evt:Event):void {
// only allow one child in root
if (numChildren > 1) {
throw (new Error("This movie can have only one child instance"));
}
}
}
}
This class only allows one child. If more are added, an error is thrown. Notice that the checkChildren method is also automatically called in the constructor since its possible that objects could have been added to the timeline within Flash which would have been before the added event listener was created.
Bron: http://www.kirupa.com/forum/showthread.php?p=1950401#post1950401
Joren De Smet
woensdag 11 februari 2009
start van arpus blogt!
Dit is de officiƫle start van mijn eigen blog, gemaakt voor het vak WebAnimatiePlus!
Abonneren op:
Posts (Atom)